blob: a680be0d45340858f70c96989fd4e9b13088502c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020062 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020074 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200103 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200104 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200105 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100116 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100133 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000134 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100135 ALC269_AUTO,
136 ALC269_MODEL_LAST /* last tag */
137};
138
Kailang Yangdf694da2005-12-05 19:42:22 +0100139/* ALC861 models */
140enum {
141 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200142 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100143 ALC861_3ST_DIG,
144 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200145 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200146 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200147 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100148 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 ALC861_AUTO,
150 ALC861_MODEL_LAST,
151};
152
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153/* ALC861-VD models */
154enum {
155 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200156 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100157 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158 ALC861VD_3ST,
159 ALC861VD_3ST_DIG,
160 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200161 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200162 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200163 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100164 ALC861VD_AUTO,
165 ALC861VD_MODEL_LAST,
166};
167
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200168/* ALC662 models */
169enum {
170 ALC662_3ST_2ch_DIG,
171 ALC662_3ST_6ch_DIG,
172 ALC662_3ST_6ch,
173 ALC662_5ST_DIG,
174 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200175 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100176 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200177 ALC663_ASUS_M51VA,
178 ALC663_ASUS_G71V,
179 ALC663_ASUS_H13,
180 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200181 ALC662_ECS,
182 ALC663_ASUS_MODE1,
183 ALC662_ASUS_MODE2,
184 ALC663_ASUS_MODE3,
185 ALC663_ASUS_MODE4,
186 ALC663_ASUS_MODE5,
187 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200188 ALC662_AUTO,
189 ALC662_MODEL_LAST,
190};
191
Kailang Yangdf694da2005-12-05 19:42:22 +0100192/* ALC882 models */
193enum {
194 ALC882_3ST_DIG,
195 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200196 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200197 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200198 ALC882_TARGA,
199 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200200 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100201 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200202 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200203 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100205 ALC882_MODEL_LAST,
206};
207
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200208/* ALC883 models */
209enum {
210 ALC883_3ST_2ch_DIG,
211 ALC883_3ST_6ch_DIG,
212 ALC883_3ST_6ch,
213 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200214 ALC883_TARGA_DIG,
215 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200216 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200217 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800218 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200219 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200220 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100221 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200222 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200223 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200224 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200225 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200227 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100228 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100229 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100230 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100231 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800232 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200233 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200234 ALC888_ASUS_M90V,
235 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100236 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200237 ALC883_AUTO,
238 ALC883_MODEL_LAST,
239};
240
Kailang Yangdf694da2005-12-05 19:42:22 +0100241/* for GPIO Poll */
242#define GPIO_MASK 0x03
243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244struct alc_spec {
245 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200251 * don't forget NULL
252 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200253 */
254 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
Takashi Iwai16ded522005-06-10 19:58:24 +0200256 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 struct hda_pcm_stream *stream_analog_playback;
258 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100259 struct hda_pcm_stream *stream_analog_alt_playback;
260 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200262 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 struct hda_pcm_stream *stream_digital_playback;
264 struct hda_pcm_stream *stream_digital_capture;
265
266 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 struct hda_multi_out multiout; /* playback set-up
268 * max_channels, dacs must be set
269 * dig_out_nid and hp_nid are optional
270 */
Takashi Iwai63300792008-01-24 15:31:36 +0100271 hda_nid_t alt_dac_nid;
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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001040 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001041 case 0x10ec0660:
1042 case 0x10ec0662:
1043 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001044 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001045 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001046 snd_hda_codec_write(codec, 0x14, 0,
1047 AC_VERB_SET_EAPD_BTLENABLE, 2);
1048 snd_hda_codec_write(codec, 0x15, 0,
1049 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001050 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001051 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001052 switch (codec->vendor_id) {
1053 case 0x10ec0260:
1054 snd_hda_codec_write(codec, 0x1a, 0,
1055 AC_VERB_SET_COEF_INDEX, 7);
1056 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1057 AC_VERB_GET_PROC_COEF, 0);
1058 snd_hda_codec_write(codec, 0x1a, 0,
1059 AC_VERB_SET_COEF_INDEX, 7);
1060 snd_hda_codec_write(codec, 0x1a, 0,
1061 AC_VERB_SET_PROC_COEF,
1062 tmp | 0x2010);
1063 break;
1064 case 0x10ec0262:
1065 case 0x10ec0880:
1066 case 0x10ec0882:
1067 case 0x10ec0883:
1068 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001069 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001070 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 snd_hda_codec_write(codec, 0x20, 0,
1072 AC_VERB_SET_COEF_INDEX, 7);
1073 tmp = snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001076 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001077 snd_hda_codec_write(codec, 0x20, 0,
1078 AC_VERB_SET_PROC_COEF,
1079 tmp | 0x2010);
1080 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001081 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001082 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001083 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001084 case 0x10ec0267:
1085 case 0x10ec0268:
1086 snd_hda_codec_write(codec, 0x20, 0,
1087 AC_VERB_SET_COEF_INDEX, 7);
1088 tmp = snd_hda_codec_read(codec, 0x20, 0,
1089 AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001091 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001092 snd_hda_codec_write(codec, 0x20, 0,
1093 AC_VERB_SET_PROC_COEF,
1094 tmp | 0x3000);
1095 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001096 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001097 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 break;
1099 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001100
Kailang Yang8c427222008-01-10 13:03:59 +01001101 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001102 * when the external headphone out jack is plugged"
1103 */
Kailang Yang8c427222008-01-10 13:03:59 +01001104 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001105 return;
1106 /*
1107 * 10~8 : Jack location
1108 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1109 * 14~13: Resvered
1110 * 15 : 1 --> enable the function "Mute internal speaker
1111 * when the external headphone out jack is plugged"
1112 */
1113 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001114 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001116 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 else
1118 return;
1119 }
1120
1121 if (!spec->autocfg.hp_pins[0]) {
1122 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1123 if (tmp == 0)
1124 spec->autocfg.hp_pins[0] = porta;
1125 else if (tmp == 1)
1126 spec->autocfg.hp_pins[0] = porte;
1127 else if (tmp == 2)
1128 spec->autocfg.hp_pins[0] = portd;
1129 else
1130 return;
1131 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001132 if (spec->autocfg.hp_pins[0])
1133 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1134 AC_VERB_SET_UNSOLICITED_ENABLE,
1135 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001136
Takashi Iwai4605b712008-10-31 14:18:24 +01001137#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001138 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1139 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1140 snd_hda_codec_write(codec,
1141 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1142 AC_VERB_SET_UNSOLICITED_ENABLE,
1143 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001144#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001145
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001147}
1148
Takashi Iwai41e41f12005-06-08 14:48:49 +02001149/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001150 * Fix-up pin default configurations
1151 */
1152
1153struct alc_pincfg {
1154 hda_nid_t nid;
1155 u32 val;
1156};
1157
1158static void alc_fix_pincfg(struct hda_codec *codec,
1159 const struct snd_pci_quirk *quirk,
1160 const struct alc_pincfg **pinfix)
1161{
1162 const struct alc_pincfg *cfg;
1163
1164 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1165 if (!quirk)
1166 return;
1167
1168 cfg = pinfix[quirk->value];
1169 for (; cfg->nid; cfg++) {
1170 int i;
1171 u32 val = cfg->val;
1172 for (i = 0; i < 4; i++) {
1173 snd_hda_codec_write(codec, cfg->nid, 0,
1174 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1175 val & 0xff);
1176 val >>= 8;
1177 }
1178 }
1179}
1180
1181/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001182 * ALC888
1183 */
1184
1185/*
1186 * 2ch mode
1187 */
1188static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1189/* Mic-in jack as mic in */
1190 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1191 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1192/* Line-in jack as Line in */
1193 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1194 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1195/* Line-Out as Front */
1196 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1197 { } /* end */
1198};
1199
1200/*
1201 * 4ch mode
1202 */
1203static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1204/* Mic-in jack as mic in */
1205 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1206 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1207/* Line-in jack as Surround */
1208 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1209 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1210/* Line-Out as Front */
1211 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1212 { } /* end */
1213};
1214
1215/*
1216 * 6ch mode
1217 */
1218static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1219/* Mic-in jack as CLFE */
1220 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1221 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1222/* Line-in jack as Surround */
1223 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1224 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1225/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1226 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1227 { } /* end */
1228};
1229
1230/*
1231 * 8ch mode
1232 */
1233static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1234/* Mic-in jack as CLFE */
1235 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1236 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1237/* Line-in jack as Surround */
1238 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1239 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1240/* Line-Out as Side */
1241 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1242 { } /* end */
1243};
1244
1245static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1246 { 2, alc888_4ST_ch2_intel_init },
1247 { 4, alc888_4ST_ch4_intel_init },
1248 { 6, alc888_4ST_ch6_intel_init },
1249 { 8, alc888_4ST_ch8_intel_init },
1250};
1251
1252/*
1253 * ALC888 Fujitsu Siemens Amillo xa3530
1254 */
1255
1256static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1257/* Front Mic: set to PIN_IN (empty by default) */
1258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1259/* Connect Internal HP to Front */
1260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1263/* Connect Bass HP to Front */
1264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1267/* Connect Line-Out side jack (SPDIF) to Side */
1268 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1269 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1270 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1271/* Connect Mic jack to CLFE */
1272 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1274 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1275/* Connect Line-in jack to Surround */
1276 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1277 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1278 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1279/* Connect HP out jack to Front */
1280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1281 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1283/* Enable unsolicited event for HP jack and Line-out jack */
1284 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1285 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1286 {}
1287};
1288
1289static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1290{
1291 unsigned int present;
1292 unsigned int bits;
1293 /* Line out presence */
1294 present = snd_hda_codec_read(codec, 0x17, 0,
1295 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1296 /* HP out presence */
1297 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1299 bits = present ? HDA_AMP_MUTE : 0;
1300 /* Toggle internal speakers muting */
1301 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1302 HDA_AMP_MUTE, bits);
1303 /* Toggle internal bass muting */
1304 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1305 HDA_AMP_MUTE, bits);
1306}
1307
1308static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1309 unsigned int res)
1310{
1311 if (res >> 26 == ALC880_HP_EVENT)
1312 alc888_fujitsu_xa3530_automute(codec);
1313}
1314
1315
1316/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001317 * ALC888 Acer Aspire 4930G model
1318 */
1319
1320static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1321/* Front Mic: set to PIN_IN (empty by default) */
1322 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1323/* Unselect Front Mic by default in input mixer 3 */
1324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001325/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001326 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1327/* Connect Internal HP to front */
1328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1330 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1331/* Connect HP out to front */
1332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1335 { }
1336};
1337
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001338static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001339 /* Front mic only available on one ADC */
1340 {
1341 .num_items = 4,
1342 .items = {
1343 { "Mic", 0x0 },
1344 { "Line", 0x2 },
1345 { "CD", 0x4 },
1346 { "Front Mic", 0xb },
1347 },
1348 },
1349 {
1350 .num_items = 3,
1351 .items = {
1352 { "Mic", 0x0 },
1353 { "Line", 0x2 },
1354 { "CD", 0x4 },
1355 },
1356 }
1357};
1358
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001359static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001360 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1362 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1363 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1364 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1365 HDA_OUTPUT),
1366 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1367 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1368 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1369 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1370 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1371 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1372 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1378 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1379 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1380 { } /* end */
1381};
1382
1383static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1384{
1385 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001386 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001387 present = snd_hda_codec_read(codec, 0x15, 0,
1388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001389 bits = present ? HDA_AMP_MUTE : 0;
1390 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1391 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001392}
1393
1394static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1395 unsigned int res)
1396{
1397 if (res >> 26 == ALC880_HP_EVENT)
1398 alc888_acer_aspire_4930g_automute(codec);
1399}
1400
1401/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402 * ALC880 3-stack model
1403 *
1404 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001405 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1406 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 */
1408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001409static hda_nid_t alc880_dac_nids[4] = {
1410 /* front, rear, clfe, rear_surr */
1411 0x02, 0x05, 0x04, 0x03
1412};
1413
1414static hda_nid_t alc880_adc_nids[3] = {
1415 /* ADC0-2 */
1416 0x07, 0x08, 0x09,
1417};
1418
1419/* The datasheet says the node 0x07 is connected from inputs,
1420 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001421 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423static hda_nid_t alc880_adc_nids_alt[2] = {
1424 /* ADC1-2 */
1425 0x08, 0x09,
1426};
1427
1428#define ALC880_DIGOUT_NID 0x06
1429#define ALC880_DIGIN_NID 0x0a
1430
1431static struct hda_input_mux alc880_capture_source = {
1432 .num_items = 4,
1433 .items = {
1434 { "Mic", 0x0 },
1435 { "Front Mic", 0x3 },
1436 { "Line", 0x2 },
1437 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439};
1440
1441/* channel source setting (2/6 channel selection for 3-stack) */
1442/* 2ch mode */
1443static struct hda_verb alc880_threestack_ch2_init[] = {
1444 /* set line-in to input, mute it */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1447 /* set mic-in to input vref 80%, mute it */
1448 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1449 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 { } /* end */
1451};
1452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001453/* 6ch mode */
1454static struct hda_verb alc880_threestack_ch6_init[] = {
1455 /* set line-in to output, unmute it */
1456 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1457 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1458 /* set mic-in to output, unmute it */
1459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1461 { } /* end */
1462};
1463
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001464static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 { 2, alc880_threestack_ch2_init },
1466 { 6, alc880_threestack_ch6_init },
1467};
1468
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001469static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001472 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001473 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001474 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001476 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1477 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1479 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1484 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1486 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1487 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001489 {
1490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1491 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001492 .info = alc_ch_mode_info,
1493 .get = alc_ch_mode_get,
1494 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001495 },
1496 { } /* end */
1497};
1498
1499/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001500static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1501 struct snd_ctl_elem_info *uinfo)
1502{
1503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1504 struct alc_spec *spec = codec->spec;
1505 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001507 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001508 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1509 HDA_INPUT);
1510 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001511 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001512 return err;
1513}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001515static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1516 unsigned int size, unsigned int __user *tlv)
1517{
1518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1519 struct alc_spec *spec = codec->spec;
1520 int err;
1521
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001522 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001523 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1524 HDA_INPUT);
1525 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001526 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001527 return err;
1528}
1529
1530typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1531 struct snd_ctl_elem_value *ucontrol);
1532
1533static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1534 struct snd_ctl_elem_value *ucontrol,
1535 getput_call_t func)
1536{
1537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1538 struct alc_spec *spec = codec->spec;
1539 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1540 int err;
1541
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001542 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001543 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1544 3, 0, HDA_INPUT);
1545 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001546 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001547 return err;
1548}
1549
1550static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1551 struct snd_ctl_elem_value *ucontrol)
1552{
1553 return alc_cap_getput_caller(kcontrol, ucontrol,
1554 snd_hda_mixer_amp_volume_get);
1555}
1556
1557static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1558 struct snd_ctl_elem_value *ucontrol)
1559{
1560 return alc_cap_getput_caller(kcontrol, ucontrol,
1561 snd_hda_mixer_amp_volume_put);
1562}
1563
1564/* capture mixer elements */
1565#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1566
1567static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1568 struct snd_ctl_elem_value *ucontrol)
1569{
1570 return alc_cap_getput_caller(kcontrol, ucontrol,
1571 snd_hda_mixer_amp_switch_get);
1572}
1573
1574static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1576{
1577 return alc_cap_getput_caller(kcontrol, ucontrol,
1578 snd_hda_mixer_amp_switch_put);
1579}
1580
1581#define DEFINE_CAPMIX(num) \
1582static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1583 { \
1584 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1585 .name = "Capture Switch", \
1586 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1587 .count = num, \
1588 .info = alc_cap_sw_info, \
1589 .get = alc_cap_sw_get, \
1590 .put = alc_cap_sw_put, \
1591 }, \
1592 { \
1593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1594 .name = "Capture Volume", \
1595 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1596 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1597 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1598 .count = num, \
1599 .info = alc_cap_vol_info, \
1600 .get = alc_cap_vol_get, \
1601 .put = alc_cap_vol_put, \
1602 .tlv = { .c = alc_cap_vol_tlv }, \
1603 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001604 { \
1605 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1606 /* .name = "Capture Source", */ \
1607 .name = "Input Source", \
1608 .count = num, \
1609 .info = alc_mux_enum_info, \
1610 .get = alc_mux_enum_get, \
1611 .put = alc_mux_enum_put, \
1612 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001613 { } /* end */ \
1614}
1615
1616/* up to three ADCs */
1617DEFINE_CAPMIX(1);
1618DEFINE_CAPMIX(2);
1619DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001620
1621
1622/*
1623 * ALC880 5-stack model
1624 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001625 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1626 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001627 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1628 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1629 */
1630
1631/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001632static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001633 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001634 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635 { } /* end */
1636};
1637
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001638/* channel source setting (6/8 channel selection for 5-stack) */
1639/* 6ch mode */
1640static struct hda_verb alc880_fivestack_ch6_init[] = {
1641 /* set line-in to input, mute it */
1642 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1643 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001644 { } /* end */
1645};
1646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647/* 8ch mode */
1648static struct hda_verb alc880_fivestack_ch8_init[] = {
1649 /* set line-in to output, unmute it */
1650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1652 { } /* end */
1653};
1654
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001655static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001656 { 6, alc880_fivestack_ch6_init },
1657 { 8, alc880_fivestack_ch8_init },
1658};
1659
1660
1661/*
1662 * ALC880 6-stack model
1663 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001664 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1665 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1667 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1668 */
1669
1670static hda_nid_t alc880_6st_dac_nids[4] = {
1671 /* front, rear, clfe, rear_surr */
1672 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001673};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001674
1675static struct hda_input_mux alc880_6stack_capture_source = {
1676 .num_items = 4,
1677 .items = {
1678 { "Mic", 0x0 },
1679 { "Front Mic", 0x1 },
1680 { "Line", 0x2 },
1681 { "CD", 0x4 },
1682 },
1683};
1684
1685/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001686static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001687 { 8, NULL },
1688};
1689
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001690static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001691 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001692 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001694 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001695 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1696 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001697 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1698 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001699 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001700 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001701 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1702 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1703 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1704 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1709 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1710 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001711 {
1712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1713 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001714 .info = alc_ch_mode_info,
1715 .get = alc_ch_mode_get,
1716 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001717 },
1718 { } /* end */
1719};
1720
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001721
1722/*
1723 * ALC880 W810 model
1724 *
1725 * W810 has rear IO for:
1726 * Front (DAC 02)
1727 * Surround (DAC 03)
1728 * Center/LFE (DAC 04)
1729 * Digital out (06)
1730 *
1731 * The system also has a pair of internal speakers, and a headphone jack.
1732 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001733 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734 * There is a variable resistor to control the speaker or headphone
1735 * volume. This is a hardware-only device without a software API.
1736 *
1737 * Plugging headphones in will disable the internal speakers. This is
1738 * implemented in hardware, not via the driver using jack sense. In
1739 * a similar fashion, plugging into the rear socket marked "front" will
1740 * disable both the speakers and headphones.
1741 *
1742 * For input, there's a microphone jack, and an "audio in" jack.
1743 * These may not do anything useful with this driver yet, because I
1744 * haven't setup any initialization verbs for these yet...
1745 */
1746
1747static hda_nid_t alc880_w810_dac_nids[3] = {
1748 /* front, rear/surround, clfe */
1749 0x02, 0x03, 0x04
1750};
1751
1752/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001753static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001754 { 6, NULL }
1755};
1756
1757/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001758static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001762 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1764 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001765 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1766 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1768 { } /* end */
1769};
1770
1771
1772/*
1773 * Z710V model
1774 *
1775 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001776 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1777 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001778 */
1779
1780static hda_nid_t alc880_z71v_dac_nids[1] = {
1781 0x02
1782};
1783#define ALC880_Z71V_HP_DAC 0x03
1784
1785/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001786static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001787 { 2, NULL }
1788};
1789
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001790static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001794 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1796 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1799 { } /* end */
1800};
1801
1802
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803/*
1804 * ALC880 F1734 model
1805 *
1806 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1807 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1808 */
1809
1810static hda_nid_t alc880_f1734_dac_nids[1] = {
1811 0x03
1812};
1813#define ALC880_F1734_HP_DAC 0x02
1814
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001815static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001816 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001817 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001818 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1819 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001824 { } /* end */
1825};
1826
Takashi Iwai937b4162008-02-11 14:52:36 +01001827static struct hda_input_mux alc880_f1734_capture_source = {
1828 .num_items = 2,
1829 .items = {
1830 { "Mic", 0x1 },
1831 { "CD", 0x4 },
1832 },
1833};
1834
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001836/*
1837 * ALC880 ASUS model
1838 *
1839 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1840 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1841 * Mic = 0x18, Line = 0x1a
1842 */
1843
1844#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1845#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1846
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001847static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001850 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001851 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001852 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1853 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001854 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1855 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001862 {
1863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1864 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001865 .info = alc_ch_mode_info,
1866 .get = alc_ch_mode_get,
1867 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001868 },
1869 { } /* end */
1870};
1871
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001872/*
1873 * ALC880 ASUS W1V model
1874 *
1875 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1876 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1877 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1878 */
1879
1880/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001881static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001882 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1883 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001884 { } /* end */
1885};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001886
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001887/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001888static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001889 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1890 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1891 { } /* end */
1892};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001893
Kailang Yangdf694da2005-12-05 19:42:22 +01001894/* TCL S700 */
1895static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1897 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1899 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1900 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1903 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1904 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001905 { } /* end */
1906};
1907
Kailang Yangccc656c2006-10-17 12:32:26 +02001908/* Uniwill */
1909static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001910 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1911 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1912 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1913 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001914 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1915 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1916 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1917 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1928 {
1929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1930 .name = "Channel Mode",
1931 .info = alc_ch_mode_info,
1932 .get = alc_ch_mode_get,
1933 .put = alc_ch_mode_put,
1934 },
1935 { } /* end */
1936};
1937
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001938static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1948 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1949 { } /* end */
1950};
1951
Kailang Yangccc656c2006-10-17 12:32:26 +02001952static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001953 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1954 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1956 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1959 { } /* end */
1960};
1961
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001963 * virtual master controls
1964 */
1965
1966/*
1967 * slave controls for virtual master
1968 */
1969static const char *alc_slave_vols[] = {
1970 "Front Playback Volume",
1971 "Surround Playback Volume",
1972 "Center Playback Volume",
1973 "LFE Playback Volume",
1974 "Side Playback Volume",
1975 "Headphone Playback Volume",
1976 "Speaker Playback Volume",
1977 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001978 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001979 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001980 NULL,
1981};
1982
1983static const char *alc_slave_sws[] = {
1984 "Front Playback Switch",
1985 "Surround Playback Switch",
1986 "Center Playback Switch",
1987 "LFE Playback Switch",
1988 "Side Playback Switch",
1989 "Headphone Playback Switch",
1990 "Speaker Playback Switch",
1991 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001992 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001993 NULL,
1994};
1995
1996/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001997 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001999
2000static void alc_free_kctls(struct hda_codec *codec);
2001
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002static int alc_build_controls(struct hda_codec *codec)
2003{
2004 struct alc_spec *spec = codec->spec;
2005 int err;
2006 int i;
2007
2008 for (i = 0; i < spec->num_mixers; i++) {
2009 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2010 if (err < 0)
2011 return err;
2012 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002013 if (spec->cap_mixer) {
2014 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2015 if (err < 0)
2016 return err;
2017 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002019 err = snd_hda_create_spdif_out_ctls(codec,
2020 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021 if (err < 0)
2022 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01002023 err = snd_hda_create_spdif_share_sw(codec,
2024 &spec->multiout);
2025 if (err < 0)
2026 return err;
2027 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028 }
2029 if (spec->dig_in_nid) {
2030 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2031 if (err < 0)
2032 return err;
2033 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002034
2035 /* if we have no master control, let's create it */
2036 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002037 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002038 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002039 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002040 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002041 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002042 if (err < 0)
2043 return err;
2044 }
2045 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2046 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2047 NULL, alc_slave_sws);
2048 if (err < 0)
2049 return err;
2050 }
2051
Takashi Iwai603c4012008-07-30 15:01:44 +02002052 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 return 0;
2054}
2055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002056
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057/*
2058 * initialize the codec volumes, etc
2059 */
2060
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061/*
2062 * generic initialization of ADC, input mixers and output mixers
2063 */
2064static struct hda_verb alc880_volume_init_verbs[] = {
2065 /*
2066 * Unmute ADC0-2 and set the default input to mic-in
2067 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002068 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002070 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002072 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2076 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002077 * Note: PASD motherboards uses the Line In 2 as the input for front
2078 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002080 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089 /*
2090 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002092 /* set vol=0 to output mixers */
2093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2094 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2095 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2097 /* set up input amps for analog loopback */
2098 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002101 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2104 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107
2108 { }
2109};
2110
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002111/*
2112 * 3-stack pin configuration:
2113 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2114 */
2115static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2116 /*
2117 * preset connection lists of input pins
2118 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2119 */
2120 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2121 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2122 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2123
2124 /*
2125 * Set pin mode and muting
2126 */
2127 /* set front pin widgets 0x14 for output */
2128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2130 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2131 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2133 /* Mic2 (as headphone out) for HP output */
2134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2136 /* Line In pin widget for input */
2137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2139 /* Line2 (as front mic) pin widget for input and vref at 80% */
2140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2142 /* CD pin widget for input */
2143 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2144
2145 { }
2146};
2147
2148/*
2149 * 5-stack pin configuration:
2150 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2151 * line-in/side = 0x1a, f-mic = 0x1b
2152 */
2153static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2154 /*
2155 * preset connection lists of input pins
2156 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2157 */
2158 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2159 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2160
2161 /*
2162 * Set pin mode and muting
2163 */
2164 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2168 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 /* unmute pins for output (no gain on this amp) */
2170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2172 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2173 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2174
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002176 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2178 /* Mic2 (as headphone out) for HP output */
2179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002180 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 /* Line In pin widget for input */
2182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2184 /* Line2 (as front mic) pin widget for input and vref at 80% */
2185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2186 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2187 /* CD pin widget for input */
2188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189
2190 { }
2191};
2192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002193/*
2194 * W810 pin configuration:
2195 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2196 */
2197static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 /* hphone/speaker input selector: front DAC */
2199 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2200
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2205 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2206 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2207
2208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 { }
2212};
2213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214/*
2215 * Z71V pin configuration:
2216 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2217 */
2218static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002223
Takashi Iwai16ded522005-06-10 19:58:24 +02002224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002228
2229 { }
2230};
2231
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232/*
2233 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002234 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2235 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236 */
2237static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2238 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2239
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002246 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2248
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002258
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 { }
2260};
Takashi Iwai16ded522005-06-10 19:58:24 +02002261
Kailang Yangccc656c2006-10-17 12:32:26 +02002262/*
2263 * Uniwill pin configuration:
2264 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2265 * line = 0x1a
2266 */
2267static struct hda_verb alc880_uniwill_init_verbs[] = {
2268 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2269
2270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2275 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2284
2285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2291 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2292 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2294
2295 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2296 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2297
2298 { }
2299};
2300
2301/*
2302* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002303* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002304 */
2305static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2306 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2307
2308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2313 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2320
2321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2323 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2324 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2327
2328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2329 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2330
2331 { }
2332};
2333
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002334static struct hda_verb alc880_beep_init_verbs[] = {
2335 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2336 { }
2337};
2338
Kailang Yangccc656c2006-10-17 12:32:26 +02002339/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002340static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002341{
2342 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002343 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002344
2345 present = snd_hda_codec_read(codec, 0x14, 0,
2346 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002347 bits = present ? HDA_AMP_MUTE : 0;
2348 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2349 HDA_AMP_MUTE, bits);
2350 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2351 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002352}
2353
2354/* auto-toggle front mic */
2355static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2356{
2357 unsigned int present;
2358 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002359
2360 present = snd_hda_codec_read(codec, 0x18, 0,
2361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002362 bits = present ? HDA_AMP_MUTE : 0;
2363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002364}
2365
2366static void alc880_uniwill_automute(struct hda_codec *codec)
2367{
2368 alc880_uniwill_hp_automute(codec);
2369 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002370}
2371
2372static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2373 unsigned int res)
2374{
2375 /* Looks like the unsol event is incompatible with the standard
2376 * definition. 4bit tag is placed at 28 bit!
2377 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002378 switch (res >> 28) {
2379 case ALC880_HP_EVENT:
2380 alc880_uniwill_hp_automute(codec);
2381 break;
2382 case ALC880_MIC_EVENT:
2383 alc880_uniwill_mic_automute(codec);
2384 break;
2385 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002386}
2387
2388static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2389{
2390 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002391 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002392
2393 present = snd_hda_codec_read(codec, 0x14, 0,
2394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002395 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002397}
2398
2399static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2400{
2401 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002402
Kailang Yangccc656c2006-10-17 12:32:26 +02002403 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002404 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2405 present &= HDA_AMP_VOLMASK;
2406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2407 HDA_AMP_VOLMASK, present);
2408 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2409 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002410}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002411
Kailang Yangccc656c2006-10-17 12:32:26 +02002412static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2413 unsigned int res)
2414{
2415 /* Looks like the unsol event is incompatible with the standard
2416 * definition. 4bit tag is placed at 28 bit!
2417 */
2418 if ((res >> 28) == ALC880_HP_EVENT)
2419 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002420 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002421 alc880_uniwill_p53_dcvol_automute(codec);
2422}
2423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424/*
2425 * F1734 pin configuration:
2426 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2427 */
2428static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002429 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002430 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2431 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2432 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2433 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2434
2435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2439
2440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2441 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002442 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2444 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2445 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2447 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002449
Takashi Iwai937b4162008-02-11 14:52:36 +01002450 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2451 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2452
Takashi Iwai16ded522005-06-10 19:58:24 +02002453 { }
2454};
2455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456/*
2457 * ASUS pin configuration:
2458 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2459 */
2460static struct hda_verb alc880_pin_asus_init_verbs[] = {
2461 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2462 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2463 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2464 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2465
2466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474
2475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2479 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2483 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002485 { }
2486};
2487
2488/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002489#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2490#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491
Kailang Yangdf694da2005-12-05 19:42:22 +01002492/* Clevo m520g init */
2493static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2494 /* headphone output */
2495 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2496 /* line-out */
2497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2499 /* Line-in */
2500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 /* CD */
2503 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2504 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2505 /* Mic1 (rear panel) */
2506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2508 /* Mic2 (front panel) */
2509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2510 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2511 /* headphone */
2512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 /* change to EAPD mode */
2515 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2516 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2517
2518 { }
2519};
2520
2521static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002522 /* change to EAPD mode */
2523 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2524 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2525
Kailang Yangdf694da2005-12-05 19:42:22 +01002526 /* Headphone output */
2527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2528 /* Front output*/
2529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2530 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2531
2532 /* Line In pin widget for input */
2533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2534 /* CD pin widget for input */
2535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2537 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2538
2539 /* change to EAPD mode */
2540 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2541 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2542
2543 { }
2544};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545
2546/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002547 * LG m1 express dual
2548 *
2549 * Pin assignment:
2550 * Rear Line-In/Out (blue): 0x14
2551 * Build-in Mic-In: 0x15
2552 * Speaker-out: 0x17
2553 * HP-Out (green): 0x1b
2554 * Mic-In/Out (red): 0x19
2555 * SPDIF-Out: 0x1e
2556 */
2557
2558/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2559static hda_nid_t alc880_lg_dac_nids[3] = {
2560 0x05, 0x02, 0x03
2561};
2562
2563/* seems analog CD is not working */
2564static struct hda_input_mux alc880_lg_capture_source = {
2565 .num_items = 3,
2566 .items = {
2567 { "Mic", 0x1 },
2568 { "Line", 0x5 },
2569 { "Internal Mic", 0x6 },
2570 },
2571};
2572
2573/* 2,4,6 channel modes */
2574static struct hda_verb alc880_lg_ch2_init[] = {
2575 /* set line-in and mic-in to input */
2576 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2577 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2578 { }
2579};
2580
2581static struct hda_verb alc880_lg_ch4_init[] = {
2582 /* set line-in to out and mic-in to input */
2583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2585 { }
2586};
2587
2588static struct hda_verb alc880_lg_ch6_init[] = {
2589 /* set line-in and mic-in to output */
2590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2592 { }
2593};
2594
2595static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2596 { 2, alc880_lg_ch2_init },
2597 { 4, alc880_lg_ch4_init },
2598 { 6, alc880_lg_ch6_init },
2599};
2600
2601static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2603 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2605 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2614 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2615 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2616 {
2617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2618 .name = "Channel Mode",
2619 .info = alc_ch_mode_info,
2620 .get = alc_ch_mode_get,
2621 .put = alc_ch_mode_put,
2622 },
2623 { } /* end */
2624};
2625
2626static struct hda_verb alc880_lg_init_verbs[] = {
2627 /* set capture source to mic-in */
2628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2631 /* mute all amp mixer inputs */
2632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002635 /* line-in to input */
2636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 /* built-in mic */
2639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2641 /* speaker-out */
2642 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 /* mic-in to input */
2645 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2646 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2648 /* HP-out */
2649 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2652 /* jack sense */
2653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2654 { }
2655};
2656
2657/* toggle speaker-output according to the hp-jack state */
2658static void alc880_lg_automute(struct hda_codec *codec)
2659{
2660 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002661 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002662
2663 present = snd_hda_codec_read(codec, 0x1b, 0,
2664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002665 bits = present ? HDA_AMP_MUTE : 0;
2666 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2667 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002668}
2669
2670static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2671{
2672 /* Looks like the unsol event is incompatible with the standard
2673 * definition. 4bit tag is placed at 28 bit!
2674 */
2675 if ((res >> 28) == 0x01)
2676 alc880_lg_automute(codec);
2677}
2678
2679/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002680 * LG LW20
2681 *
2682 * Pin assignment:
2683 * Speaker-out: 0x14
2684 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002685 * Built-in Mic-In: 0x19
2686 * Line-In: 0x1b
2687 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002688 * SPDIF-Out: 0x1e
2689 */
2690
Takashi Iwaid6815182006-03-23 16:06:23 +01002691static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002692 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002693 .items = {
2694 { "Mic", 0x0 },
2695 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002696 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002697 },
2698};
2699
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002700#define alc880_lg_lw_modes alc880_threestack_modes
2701
Takashi Iwaid6815182006-03-23 16:06:23 +01002702static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2705 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2706 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2707 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2708 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2709 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2710 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2715 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2716 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002717 {
2718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2719 .name = "Channel Mode",
2720 .info = alc_ch_mode_info,
2721 .get = alc_ch_mode_get,
2722 .put = alc_ch_mode_put,
2723 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002724 { } /* end */
2725};
2726
2727static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002728 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2729 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2730 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2731
Takashi Iwaid6815182006-03-23 16:06:23 +01002732 /* set capture source to mic-in */
2733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002737 /* speaker-out */
2738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2740 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2742 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 /* mic-in to input */
2744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2746 /* built-in mic */
2747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 /* jack sense */
2750 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2751 { }
2752};
2753
2754/* toggle speaker-output according to the hp-jack state */
2755static void alc880_lg_lw_automute(struct hda_codec *codec)
2756{
2757 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002758 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002759
2760 present = snd_hda_codec_read(codec, 0x1b, 0,
2761 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002762 bits = present ? HDA_AMP_MUTE : 0;
2763 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2764 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002765}
2766
2767static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2768{
2769 /* Looks like the unsol event is incompatible with the standard
2770 * definition. 4bit tag is placed at 28 bit!
2771 */
2772 if ((res >> 28) == 0x01)
2773 alc880_lg_lw_automute(codec);
2774}
2775
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002776static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2777 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2778 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2780 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2781 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2782 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2783 { } /* end */
2784};
2785
2786static struct hda_input_mux alc880_medion_rim_capture_source = {
2787 .num_items = 2,
2788 .items = {
2789 { "Mic", 0x0 },
2790 { "Internal Mic", 0x1 },
2791 },
2792};
2793
2794static struct hda_verb alc880_medion_rim_init_verbs[] = {
2795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2796
2797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2799
2800 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2803 /* Mic2 (as headphone out) for HP output */
2804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2806 /* Internal Speaker */
2807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2809
2810 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2811 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2812
2813 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2814 { }
2815};
2816
2817/* toggle speaker-output according to the hp-jack state */
2818static void alc880_medion_rim_automute(struct hda_codec *codec)
2819{
2820 unsigned int present;
2821 unsigned char bits;
2822
2823 present = snd_hda_codec_read(codec, 0x14, 0,
2824 AC_VERB_GET_PIN_SENSE, 0)
2825 & AC_PINSENSE_PRESENCE;
2826 bits = present ? HDA_AMP_MUTE : 0;
2827 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2828 HDA_AMP_MUTE, bits);
2829 if (present)
2830 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2831 else
2832 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2833}
2834
2835static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2836 unsigned int res)
2837{
2838 /* Looks like the unsol event is incompatible with the standard
2839 * definition. 4bit tag is placed at 28 bit!
2840 */
2841 if ((res >> 28) == ALC880_HP_EVENT)
2842 alc880_medion_rim_automute(codec);
2843}
2844
Takashi Iwaicb53c622007-08-10 17:21:45 +02002845#ifdef CONFIG_SND_HDA_POWER_SAVE
2846static struct hda_amp_list alc880_loopbacks[] = {
2847 { 0x0b, HDA_INPUT, 0 },
2848 { 0x0b, HDA_INPUT, 1 },
2849 { 0x0b, HDA_INPUT, 2 },
2850 { 0x0b, HDA_INPUT, 3 },
2851 { 0x0b, HDA_INPUT, 4 },
2852 { } /* end */
2853};
2854
2855static struct hda_amp_list alc880_lg_loopbacks[] = {
2856 { 0x0b, HDA_INPUT, 1 },
2857 { 0x0b, HDA_INPUT, 6 },
2858 { 0x0b, HDA_INPUT, 7 },
2859 { } /* end */
2860};
2861#endif
2862
Takashi Iwaid6815182006-03-23 16:06:23 +01002863/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002864 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002866
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867static int alc_init(struct hda_codec *codec)
2868{
2869 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 unsigned int i;
2871
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002872 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002873 if (codec->vendor_id == 0x10ec0888)
2874 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002875
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876 for (i = 0; i < spec->num_init_verbs; i++)
2877 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002878
2879 if (spec->init_hook)
2880 spec->init_hook(codec);
2881
Linus Torvalds1da177e2005-04-16 15:20:36 -07002882 return 0;
2883}
2884
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002885static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2886{
2887 struct alc_spec *spec = codec->spec;
2888
2889 if (spec->unsol_event)
2890 spec->unsol_event(codec, res);
2891}
2892
Takashi Iwaicb53c622007-08-10 17:21:45 +02002893#ifdef CONFIG_SND_HDA_POWER_SAVE
2894static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2895{
2896 struct alc_spec *spec = codec->spec;
2897 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2898}
2899#endif
2900
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901/*
2902 * Analog playback callbacks
2903 */
2904static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2905 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002906 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907{
2908 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002909 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2910 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911}
2912
2913static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2914 struct hda_codec *codec,
2915 unsigned int stream_tag,
2916 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002917 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002918{
2919 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002920 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2921 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922}
2923
2924static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2925 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002926 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002927{
2928 struct alc_spec *spec = codec->spec;
2929 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2930}
2931
2932/*
2933 * Digital out
2934 */
2935static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2936 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002937 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938{
2939 struct alc_spec *spec = codec->spec;
2940 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2941}
2942
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002943static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2944 struct hda_codec *codec,
2945 unsigned int stream_tag,
2946 unsigned int format,
2947 struct snd_pcm_substream *substream)
2948{
2949 struct alc_spec *spec = codec->spec;
2950 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2951 stream_tag, format, substream);
2952}
2953
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2955 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002956 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957{
2958 struct alc_spec *spec = codec->spec;
2959 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2960}
2961
2962/*
2963 * Analog capture
2964 */
Takashi Iwai63300792008-01-24 15:31:36 +01002965static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966 struct hda_codec *codec,
2967 unsigned int stream_tag,
2968 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002969 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970{
2971 struct alc_spec *spec = codec->spec;
2972
Takashi Iwai63300792008-01-24 15:31:36 +01002973 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002974 stream_tag, 0, format);
2975 return 0;
2976}
2977
Takashi Iwai63300792008-01-24 15:31:36 +01002978static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002980 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002981{
2982 struct alc_spec *spec = codec->spec;
2983
Takashi Iwai888afa12008-03-18 09:57:50 +01002984 snd_hda_codec_cleanup_stream(codec,
2985 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002986 return 0;
2987}
2988
2989
2990/*
2991 */
2992static struct hda_pcm_stream alc880_pcm_analog_playback = {
2993 .substreams = 1,
2994 .channels_min = 2,
2995 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997 .ops = {
2998 .open = alc880_playback_pcm_open,
2999 .prepare = alc880_playback_pcm_prepare,
3000 .cleanup = alc880_playback_pcm_cleanup
3001 },
3002};
3003
3004static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003005 .substreams = 1,
3006 .channels_min = 2,
3007 .channels_max = 2,
3008 /* NID is set in alc_build_pcms */
3009};
3010
3011static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3012 .substreams = 1,
3013 .channels_min = 2,
3014 .channels_max = 2,
3015 /* NID is set in alc_build_pcms */
3016};
3017
3018static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3019 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 .channels_min = 2,
3021 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003022 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003024 .prepare = alc880_alt_capture_pcm_prepare,
3025 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003026 },
3027};
3028
3029static struct hda_pcm_stream alc880_pcm_digital_playback = {
3030 .substreams = 1,
3031 .channels_min = 2,
3032 .channels_max = 2,
3033 /* NID is set in alc_build_pcms */
3034 .ops = {
3035 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003036 .close = alc880_dig_playback_pcm_close,
3037 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07003038 },
3039};
3040
3041static struct hda_pcm_stream alc880_pcm_digital_capture = {
3042 .substreams = 1,
3043 .channels_min = 2,
3044 .channels_max = 2,
3045 /* NID is set in alc_build_pcms */
3046};
3047
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003048/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003049static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003050 .substreams = 0,
3051 .channels_min = 0,
3052 .channels_max = 0,
3053};
3054
Linus Torvalds1da177e2005-04-16 15:20:36 -07003055static int alc_build_pcms(struct hda_codec *codec)
3056{
3057 struct alc_spec *spec = codec->spec;
3058 struct hda_pcm *info = spec->pcm_rec;
3059 int i;
3060
3061 codec->num_pcms = 1;
3062 codec->pcm_info = info;
3063
3064 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003065 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003066 if (snd_BUG_ON(!spec->multiout.dac_nids))
3067 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003068 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3069 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3070 }
3071 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003072 if (snd_BUG_ON(!spec->adc_nids))
3073 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003074 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3075 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3076 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077
Takashi Iwai4a471b72005-12-07 13:56:29 +01003078 if (spec->channel_mode) {
3079 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3080 for (i = 0; i < spec->num_channel_mode; i++) {
3081 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3082 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3083 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084 }
3085 }
3086
Takashi Iwaie08a0072006-09-07 17:52:14 +02003087 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003088 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003089 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003090 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003091 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01003092 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003093 if (spec->multiout.dig_out_nid &&
3094 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3096 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3097 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003098 if (spec->dig_in_nid &&
3099 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003100 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3101 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3102 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003103 /* FIXME: do we need this for all Realtek codec models? */
3104 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003105 }
3106
Takashi Iwaie08a0072006-09-07 17:52:14 +02003107 /* If the use of more than one ADC is requested for the current
3108 * model, configure a second analog capture-only PCM.
3109 */
3110 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003111 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3112 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003113 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003114 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003115 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003116 if (spec->alt_dac_nid) {
3117 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3118 *spec->stream_analog_alt_playback;
3119 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3120 spec->alt_dac_nid;
3121 } else {
3122 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3123 alc_pcm_null_stream;
3124 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3125 }
3126 if (spec->num_adc_nids > 1) {
3127 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3128 *spec->stream_analog_alt_capture;
3129 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3130 spec->adc_nids[1];
3131 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3132 spec->num_adc_nids - 1;
3133 } else {
3134 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3135 alc_pcm_null_stream;
3136 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003137 }
3138 }
3139
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140 return 0;
3141}
3142
Takashi Iwai603c4012008-07-30 15:01:44 +02003143static void alc_free_kctls(struct hda_codec *codec)
3144{
3145 struct alc_spec *spec = codec->spec;
3146
3147 if (spec->kctls.list) {
3148 struct snd_kcontrol_new *kctl = spec->kctls.list;
3149 int i;
3150 for (i = 0; i < spec->kctls.used; i++)
3151 kfree(kctl[i].name);
3152 }
3153 snd_array_free(&spec->kctls);
3154}
3155
Linus Torvalds1da177e2005-04-16 15:20:36 -07003156static void alc_free(struct hda_codec *codec)
3157{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003160 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161 return;
3162
Takashi Iwai603c4012008-07-30 15:01:44 +02003163 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003164 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02003165 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003166}
3167
Takashi Iwaie044c392008-10-27 16:56:24 +01003168#ifdef SND_HDA_NEEDS_RESUME
3169static void store_pin_configs(struct hda_codec *codec)
3170{
3171 struct alc_spec *spec = codec->spec;
3172 hda_nid_t nid, end_nid;
3173
3174 end_nid = codec->start_nid + codec->num_nodes;
3175 for (nid = codec->start_nid; nid < end_nid; nid++) {
3176 unsigned int wid_caps = get_wcaps(codec, nid);
3177 unsigned int wid_type =
3178 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3179 if (wid_type != AC_WID_PIN)
3180 continue;
3181 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3182 break;
3183 spec->pin_nids[spec->num_pins] = nid;
3184 spec->pin_cfgs[spec->num_pins] =
3185 snd_hda_codec_read(codec, nid, 0,
3186 AC_VERB_GET_CONFIG_DEFAULT, 0);
3187 spec->num_pins++;
3188 }
3189}
3190
3191static void resume_pin_configs(struct hda_codec *codec)
3192{
3193 struct alc_spec *spec = codec->spec;
3194 int i;
3195
3196 for (i = 0; i < spec->num_pins; i++) {
3197 hda_nid_t pin_nid = spec->pin_nids[i];
3198 unsigned int pin_config = spec->pin_cfgs[i];
3199 snd_hda_codec_write(codec, pin_nid, 0,
3200 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3201 pin_config & 0x000000ff);
3202 snd_hda_codec_write(codec, pin_nid, 0,
3203 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3204 (pin_config & 0x0000ff00) >> 8);
3205 snd_hda_codec_write(codec, pin_nid, 0,
3206 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3207 (pin_config & 0x00ff0000) >> 16);
3208 snd_hda_codec_write(codec, pin_nid, 0,
3209 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3210 pin_config >> 24);
3211 }
3212}
3213
3214static int alc_resume(struct hda_codec *codec)
3215{
3216 resume_pin_configs(codec);
3217 codec->patch_ops.init(codec);
3218 snd_hda_codec_resume_amp(codec);
3219 snd_hda_codec_resume_cache(codec);
3220 return 0;
3221}
3222#else
3223#define store_pin_configs(codec)
3224#endif
3225
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226/*
3227 */
3228static struct hda_codec_ops alc_patch_ops = {
3229 .build_controls = alc_build_controls,
3230 .build_pcms = alc_build_pcms,
3231 .init = alc_init,
3232 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003233 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003234#ifdef SND_HDA_NEEDS_RESUME
3235 .resume = alc_resume,
3236#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003237#ifdef CONFIG_SND_HDA_POWER_SAVE
3238 .check_power_status = alc_check_power_status,
3239#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240};
3241
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003242
3243/*
3244 * Test configuration for debugging
3245 *
3246 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3247 * enum controls.
3248 */
3249#ifdef CONFIG_SND_DEBUG
3250static hda_nid_t alc880_test_dac_nids[4] = {
3251 0x02, 0x03, 0x04, 0x05
3252};
3253
3254static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003255 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003256 .items = {
3257 { "In-1", 0x0 },
3258 { "In-2", 0x1 },
3259 { "In-3", 0x2 },
3260 { "In-4", 0x3 },
3261 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003262 { "Front", 0x5 },
3263 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003264 },
3265};
3266
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003267static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003268 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003269 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003270 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003271 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003272};
3273
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003274static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3275 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003276{
3277 static char *texts[] = {
3278 "N/A", "Line Out", "HP Out",
3279 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3280 };
3281 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3282 uinfo->count = 1;
3283 uinfo->value.enumerated.items = 8;
3284 if (uinfo->value.enumerated.item >= 8)
3285 uinfo->value.enumerated.item = 7;
3286 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3287 return 0;
3288}
3289
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003290static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3291 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003292{
3293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3294 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3295 unsigned int pin_ctl, item = 0;
3296
3297 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3298 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3299 if (pin_ctl & AC_PINCTL_OUT_EN) {
3300 if (pin_ctl & AC_PINCTL_HP_EN)
3301 item = 2;
3302 else
3303 item = 1;
3304 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3305 switch (pin_ctl & AC_PINCTL_VREFEN) {
3306 case AC_PINCTL_VREF_HIZ: item = 3; break;
3307 case AC_PINCTL_VREF_50: item = 4; break;
3308 case AC_PINCTL_VREF_GRD: item = 5; break;
3309 case AC_PINCTL_VREF_80: item = 6; break;
3310 case AC_PINCTL_VREF_100: item = 7; break;
3311 }
3312 }
3313 ucontrol->value.enumerated.item[0] = item;
3314 return 0;
3315}
3316
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003317static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3318 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003319{
3320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3321 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3322 static unsigned int ctls[] = {
3323 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3324 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3325 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3329 };
3330 unsigned int old_ctl, new_ctl;
3331
3332 old_ctl = snd_hda_codec_read(codec, nid, 0,
3333 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3334 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3335 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003336 int val;
3337 snd_hda_codec_write_cache(codec, nid, 0,
3338 AC_VERB_SET_PIN_WIDGET_CONTROL,
3339 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003340 val = ucontrol->value.enumerated.item[0] >= 3 ?
3341 HDA_AMP_MUTE : 0;
3342 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3343 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003344 return 1;
3345 }
3346 return 0;
3347}
3348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003349static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3350 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003351{
3352 static char *texts[] = {
3353 "Front", "Surround", "CLFE", "Side"
3354 };
3355 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3356 uinfo->count = 1;
3357 uinfo->value.enumerated.items = 4;
3358 if (uinfo->value.enumerated.item >= 4)
3359 uinfo->value.enumerated.item = 3;
3360 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3361 return 0;
3362}
3363
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003364static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3365 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003366{
3367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3368 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3369 unsigned int sel;
3370
3371 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3372 ucontrol->value.enumerated.item[0] = sel & 3;
3373 return 0;
3374}
3375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003376static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3377 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003378{
3379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3380 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3381 unsigned int sel;
3382
3383 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3384 if (ucontrol->value.enumerated.item[0] != sel) {
3385 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003386 snd_hda_codec_write_cache(codec, nid, 0,
3387 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003388 return 1;
3389 }
3390 return 0;
3391}
3392
3393#define PIN_CTL_TEST(xname,nid) { \
3394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3395 .name = xname, \
3396 .info = alc_test_pin_ctl_info, \
3397 .get = alc_test_pin_ctl_get, \
3398 .put = alc_test_pin_ctl_put, \
3399 .private_value = nid \
3400 }
3401
3402#define PIN_SRC_TEST(xname,nid) { \
3403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3404 .name = xname, \
3405 .info = alc_test_pin_src_info, \
3406 .get = alc_test_pin_src_get, \
3407 .put = alc_test_pin_src_put, \
3408 .private_value = nid \
3409 }
3410
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003411static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3413 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3414 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3415 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3417 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3418 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3419 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003420 PIN_CTL_TEST("Front Pin Mode", 0x14),
3421 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3422 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3423 PIN_CTL_TEST("Side Pin Mode", 0x17),
3424 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3425 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3426 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3427 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3428 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3429 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3430 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3431 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3432 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3433 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3434 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3435 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3436 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3437 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3438 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3439 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003442 {
3443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3444 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003445 .info = alc_ch_mode_info,
3446 .get = alc_ch_mode_get,
3447 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003448 },
3449 { } /* end */
3450};
3451
3452static struct hda_verb alc880_test_init_verbs[] = {
3453 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3457 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3460 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3461 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003462 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003467 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003472 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003477 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3479 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003483 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003484 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003488 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003490 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003492 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003494 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003495 /* Analog input/passthru */
3496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003501 { }
3502};
3503#endif
3504
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505/*
3506 */
3507
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003508static const char *alc880_models[ALC880_MODEL_LAST] = {
3509 [ALC880_3ST] = "3stack",
3510 [ALC880_TCL_S700] = "tcl",
3511 [ALC880_3ST_DIG] = "3stack-digout",
3512 [ALC880_CLEVO] = "clevo",
3513 [ALC880_5ST] = "5stack",
3514 [ALC880_5ST_DIG] = "5stack-digout",
3515 [ALC880_W810] = "w810",
3516 [ALC880_Z71V] = "z71v",
3517 [ALC880_6ST] = "6stack",
3518 [ALC880_6ST_DIG] = "6stack-digout",
3519 [ALC880_ASUS] = "asus",
3520 [ALC880_ASUS_W1V] = "asus-w1v",
3521 [ALC880_ASUS_DIG] = "asus-dig",
3522 [ALC880_ASUS_DIG2] = "asus-dig2",
3523 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003524 [ALC880_UNIWILL_P53] = "uniwill-p53",
3525 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003526 [ALC880_F1734] = "F1734",
3527 [ALC880_LG] = "lg",
3528 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003529 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003530#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003531 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003532#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003533 [ALC880_AUTO] = "auto",
3534};
3535
3536static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003537 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003538 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3539 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3540 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3541 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3542 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3543 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3544 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3545 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003546 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3547 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003548 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3549 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3550 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3551 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3552 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3553 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3554 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3555 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3556 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3557 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003558 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003559 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3560 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3561 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003562 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003563 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003564 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3565 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003566 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3567 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003568 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3569 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3570 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3571 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003572 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3573 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003574 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003575 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003576 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003577 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003578 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3579 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003580 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003581 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003582 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003583 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003584 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003585 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003586 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003587 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003588 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003589 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3590 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003591 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003592 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3593 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3594 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3595 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003596 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3597 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003598 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003599 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003600 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3601 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003602 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3603 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3604 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003605 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3606 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3607 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003608 {}
3609};
3610
Takashi Iwai16ded522005-06-10 19:58:24 +02003611/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003612 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003613 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003614static struct alc_config_preset alc880_presets[] = {
3615 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003616 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003617 .init_verbs = { alc880_volume_init_verbs,
3618 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003619 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003620 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003621 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3622 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003623 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003624 .input_mux = &alc880_capture_source,
3625 },
3626 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003627 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003628 .init_verbs = { alc880_volume_init_verbs,
3629 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003630 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003631 .dac_nids = alc880_dac_nids,
3632 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003633 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3634 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003635 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003636 .input_mux = &alc880_capture_source,
3637 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003638 [ALC880_TCL_S700] = {
3639 .mixers = { alc880_tcl_s700_mixer },
3640 .init_verbs = { alc880_volume_init_verbs,
3641 alc880_pin_tcl_S700_init_verbs,
3642 alc880_gpio2_init_verbs },
3643 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3644 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003645 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3646 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003647 .hp_nid = 0x03,
3648 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3649 .channel_mode = alc880_2_jack_modes,
3650 .input_mux = &alc880_capture_source,
3651 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003652 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003653 .mixers = { alc880_three_stack_mixer,
3654 alc880_five_stack_mixer},
3655 .init_verbs = { alc880_volume_init_verbs,
3656 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003657 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3658 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003659 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3660 .channel_mode = alc880_fivestack_modes,
3661 .input_mux = &alc880_capture_source,
3662 },
3663 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 .mixers = { alc880_three_stack_mixer,
3665 alc880_five_stack_mixer },
3666 .init_verbs = { alc880_volume_init_verbs,
3667 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003668 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3669 .dac_nids = alc880_dac_nids,
3670 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3672 .channel_mode = alc880_fivestack_modes,
3673 .input_mux = &alc880_capture_source,
3674 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003675 [ALC880_6ST] = {
3676 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003677 .init_verbs = { alc880_volume_init_verbs,
3678 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003679 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3680 .dac_nids = alc880_6st_dac_nids,
3681 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3682 .channel_mode = alc880_sixstack_modes,
3683 .input_mux = &alc880_6stack_capture_source,
3684 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003685 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003686 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003687 .init_verbs = { alc880_volume_init_verbs,
3688 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003689 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3690 .dac_nids = alc880_6st_dac_nids,
3691 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003692 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3693 .channel_mode = alc880_sixstack_modes,
3694 .input_mux = &alc880_6stack_capture_source,
3695 },
3696 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003697 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003698 .init_verbs = { alc880_volume_init_verbs,
3699 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003700 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003701 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3702 .dac_nids = alc880_w810_dac_nids,
3703 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003704 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3705 .channel_mode = alc880_w810_modes,
3706 .input_mux = &alc880_capture_source,
3707 },
3708 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003710 .init_verbs = { alc880_volume_init_verbs,
3711 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003712 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3713 .dac_nids = alc880_z71v_dac_nids,
3714 .dig_out_nid = ALC880_DIGOUT_NID,
3715 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3717 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003718 .input_mux = &alc880_capture_source,
3719 },
3720 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003722 .init_verbs = { alc880_volume_init_verbs,
3723 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003724 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3725 .dac_nids = alc880_f1734_dac_nids,
3726 .hp_nid = 0x02,
3727 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3728 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003729 .input_mux = &alc880_f1734_capture_source,
3730 .unsol_event = alc880_uniwill_p53_unsol_event,
3731 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003732 },
3733 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003734 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003735 .init_verbs = { alc880_volume_init_verbs,
3736 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003737 alc880_gpio1_init_verbs },
3738 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3739 .dac_nids = alc880_asus_dac_nids,
3740 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3741 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003742 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .input_mux = &alc880_capture_source,
3744 },
3745 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003746 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003747 .init_verbs = { alc880_volume_init_verbs,
3748 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003749 alc880_gpio1_init_verbs },
3750 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3751 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003752 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3754 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003755 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003756 .input_mux = &alc880_capture_source,
3757 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003758 [ALC880_ASUS_DIG2] = {
3759 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 .init_verbs = { alc880_volume_init_verbs,
3761 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003762 alc880_gpio2_init_verbs }, /* use GPIO2 */
3763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3764 .dac_nids = alc880_asus_dac_nids,
3765 .dig_out_nid = ALC880_DIGOUT_NID,
3766 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3767 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003768 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003769 .input_mux = &alc880_capture_source,
3770 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003771 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003773 .init_verbs = { alc880_volume_init_verbs,
3774 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003775 alc880_gpio1_init_verbs },
3776 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3777 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003778 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3780 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003781 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003782 .input_mux = &alc880_capture_source,
3783 },
3784 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003785 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003786 .init_verbs = { alc880_volume_init_verbs,
3787 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3789 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003790 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3792 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003793 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003794 .input_mux = &alc880_capture_source,
3795 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003796 [ALC880_UNIWILL] = {
3797 .mixers = { alc880_uniwill_mixer },
3798 .init_verbs = { alc880_volume_init_verbs,
3799 alc880_uniwill_init_verbs },
3800 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3801 .dac_nids = alc880_asus_dac_nids,
3802 .dig_out_nid = ALC880_DIGOUT_NID,
3803 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3804 .channel_mode = alc880_threestack_modes,
3805 .need_dac_fix = 1,
3806 .input_mux = &alc880_capture_source,
3807 .unsol_event = alc880_uniwill_unsol_event,
3808 .init_hook = alc880_uniwill_automute,
3809 },
3810 [ALC880_UNIWILL_P53] = {
3811 .mixers = { alc880_uniwill_p53_mixer },
3812 .init_verbs = { alc880_volume_init_verbs,
3813 alc880_uniwill_p53_init_verbs },
3814 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3815 .dac_nids = alc880_asus_dac_nids,
3816 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003817 .channel_mode = alc880_threestack_modes,
3818 .input_mux = &alc880_capture_source,
3819 .unsol_event = alc880_uniwill_p53_unsol_event,
3820 .init_hook = alc880_uniwill_p53_hp_automute,
3821 },
3822 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003823 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003824 alc880_pcbeep_mixer, },
3825 .init_verbs = { alc880_volume_init_verbs,
3826 alc880_uniwill_p53_init_verbs,
3827 alc880_beep_init_verbs },
3828 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3829 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003830 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003831 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3832 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003833 .input_mux = &alc880_capture_source,
3834 .unsol_event = alc880_uniwill_p53_unsol_event,
3835 .init_hook = alc880_uniwill_p53_hp_automute,
3836 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 [ALC880_CLEVO] = {
3838 .mixers = { alc880_three_stack_mixer },
3839 .init_verbs = { alc880_volume_init_verbs,
3840 alc880_pin_clevo_init_verbs },
3841 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3842 .dac_nids = alc880_dac_nids,
3843 .hp_nid = 0x03,
3844 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3845 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003846 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003847 .input_mux = &alc880_capture_source,
3848 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003849 [ALC880_LG] = {
3850 .mixers = { alc880_lg_mixer },
3851 .init_verbs = { alc880_volume_init_verbs,
3852 alc880_lg_init_verbs },
3853 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3854 .dac_nids = alc880_lg_dac_nids,
3855 .dig_out_nid = ALC880_DIGOUT_NID,
3856 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3857 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003858 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003859 .input_mux = &alc880_lg_capture_source,
3860 .unsol_event = alc880_lg_unsol_event,
3861 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003862#ifdef CONFIG_SND_HDA_POWER_SAVE
3863 .loopbacks = alc880_lg_loopbacks,
3864#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003865 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003866 [ALC880_LG_LW] = {
3867 .mixers = { alc880_lg_lw_mixer },
3868 .init_verbs = { alc880_volume_init_verbs,
3869 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003870 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003871 .dac_nids = alc880_dac_nids,
3872 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003873 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3874 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003875 .input_mux = &alc880_lg_lw_capture_source,
3876 .unsol_event = alc880_lg_lw_unsol_event,
3877 .init_hook = alc880_lg_lw_automute,
3878 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003879 [ALC880_MEDION_RIM] = {
3880 .mixers = { alc880_medion_rim_mixer },
3881 .init_verbs = { alc880_volume_init_verbs,
3882 alc880_medion_rim_init_verbs,
3883 alc_gpio2_init_verbs },
3884 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3885 .dac_nids = alc880_dac_nids,
3886 .dig_out_nid = ALC880_DIGOUT_NID,
3887 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3888 .channel_mode = alc880_2_jack_modes,
3889 .input_mux = &alc880_medion_rim_capture_source,
3890 .unsol_event = alc880_medion_rim_unsol_event,
3891 .init_hook = alc880_medion_rim_automute,
3892 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003893#ifdef CONFIG_SND_DEBUG
3894 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003895 .mixers = { alc880_test_mixer },
3896 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003897 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3898 .dac_nids = alc880_test_dac_nids,
3899 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003900 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3901 .channel_mode = alc880_test_modes,
3902 .input_mux = &alc880_test_capture_source,
3903 },
3904#endif
3905};
3906
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003907/*
3908 * Automatic parse of I/O pins from the BIOS configuration
3909 */
3910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911enum {
3912 ALC_CTL_WIDGET_VOL,
3913 ALC_CTL_WIDGET_MUTE,
3914 ALC_CTL_BIND_MUTE,
3915};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003916static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003917 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3918 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003919 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003920};
3921
3922/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003923static int add_control(struct alc_spec *spec, int type, const char *name,
3924 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003926 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003927
Takashi Iwai603c4012008-07-30 15:01:44 +02003928 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3929 knew = snd_array_new(&spec->kctls);
3930 if (!knew)
3931 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003932 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003933 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003934 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 return -ENOMEM;
3936 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003937 return 0;
3938}
3939
3940#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3941#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3942#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3943#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3944#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3945#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3946#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3947#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3948#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3949#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3950#define ALC880_PIN_CD_NID 0x1c
3951
3952/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003953static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3954 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003955{
3956 hda_nid_t nid;
3957 int assigned[4];
3958 int i, j;
3959
3960 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003961 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003962
3963 /* check the pins hardwired to audio widget */
3964 for (i = 0; i < cfg->line_outs; i++) {
3965 nid = cfg->line_out_pins[i];
3966 if (alc880_is_fixed_pin(nid)) {
3967 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003968 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969 assigned[idx] = 1;
3970 }
3971 }
3972 /* left pins can be connect to any audio widget */
3973 for (i = 0; i < cfg->line_outs; i++) {
3974 nid = cfg->line_out_pins[i];
3975 if (alc880_is_fixed_pin(nid))
3976 continue;
3977 /* search for an empty channel */
3978 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003979 if (!assigned[j]) {
3980 spec->multiout.dac_nids[i] =
3981 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 assigned[j] = 1;
3983 break;
3984 }
3985 }
3986 }
3987 spec->multiout.num_dacs = cfg->line_outs;
3988 return 0;
3989}
3990
3991/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003992static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3993 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994{
3995 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 static const char *chname[4] = {
3997 "Front", "Surround", NULL /*CLFE*/, "Side"
3998 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999 hda_nid_t nid;
4000 int i, err;
4001
4002 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004003 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004 continue;
4005 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4006 if (i == 2) {
4007 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004008 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4009 "Center Playback Volume",
4010 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4011 HDA_OUTPUT));
4012 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004013 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004014 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4015 "LFE Playback Volume",
4016 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4017 HDA_OUTPUT));
4018 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004020 err = add_control(spec, ALC_CTL_BIND_MUTE,
4021 "Center Playback Switch",
4022 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4023 HDA_INPUT));
4024 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004025 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004026 err = add_control(spec, ALC_CTL_BIND_MUTE,
4027 "LFE Playback Switch",
4028 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4029 HDA_INPUT));
4030 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004031 return err;
4032 } else {
4033 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4035 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4036 HDA_OUTPUT));
4037 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004038 return err;
4039 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004040 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4041 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4042 HDA_INPUT));
4043 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004044 return err;
4045 }
4046 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004047 return 0;
4048}
4049
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004050/* add playback controls for speaker and HP outputs */
4051static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4052 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004053{
4054 hda_nid_t nid;
4055 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004056 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004058 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004059 return 0;
4060
4061 if (alc880_is_fixed_pin(pin)) {
4062 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004063 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004065 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004066 else
4067 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068 /* control HP volume/switch on the output mixer amp */
4069 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004070 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004071 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4072 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4073 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004075 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4077 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004079 return err;
4080 } else if (alc880_is_multi_pin(pin)) {
4081 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004082 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004083 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4085 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4086 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 return err;
4088 }
4089 return 0;
4090}
4091
4092/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4094 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004095 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096{
4097 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004098 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099
4100 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004101 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4102 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4103 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 return err;
4105 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004106 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4107 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4108 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004109 return err;
4110 return 0;
4111}
4112
4113/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004114static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4115 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004116{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01004118 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119
4120 for (i = 0; i < AUTO_PIN_LAST; i++) {
4121 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004122 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004123 err = new_analog_input(spec, cfg->input_pins[i],
4124 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004125 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 if (err < 0)
4127 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004128 imux->items[imux->num_items].label =
4129 auto_pin_cfg_labels[i];
4130 imux->items[imux->num_items].index =
4131 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132 imux->num_items++;
4133 }
4134 }
4135 return 0;
4136}
4137
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004138static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4139 unsigned int pin_type)
4140{
4141 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4142 pin_type);
4143 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004144 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4145 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004146}
4147
Kailang Yangdf694da2005-12-05 19:42:22 +01004148static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4149 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004150 int dac_idx)
4151{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004152 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 /* need the manual connection? */
4154 if (alc880_is_multi_pin(nid)) {
4155 struct alc_spec *spec = codec->spec;
4156 int idx = alc880_multi_pin_idx(nid);
4157 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4158 AC_VERB_SET_CONNECT_SEL,
4159 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4160 }
4161}
4162
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004163static int get_pin_type(int line_out_type)
4164{
4165 if (line_out_type == AUTO_PIN_HP_OUT)
4166 return PIN_HP;
4167 else
4168 return PIN_OUT;
4169}
4170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171static void alc880_auto_init_multi_out(struct hda_codec *codec)
4172{
4173 struct alc_spec *spec = codec->spec;
4174 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004175
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004176 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 for (i = 0; i < spec->autocfg.line_outs; i++) {
4178 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004179 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4180 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004181 }
4182}
4183
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004184static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185{
4186 struct alc_spec *spec = codec->spec;
4187 hda_nid_t pin;
4188
Takashi Iwai82bc9552006-03-21 11:24:42 +01004189 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004190 if (pin) /* connect to front */
4191 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004192 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193 if (pin) /* connect to front */
4194 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4195}
4196
4197static void alc880_auto_init_analog_input(struct hda_codec *codec)
4198{
4199 struct alc_spec *spec = codec->spec;
4200 int i;
4201
4202 for (i = 0; i < AUTO_PIN_LAST; i++) {
4203 hda_nid_t nid = spec->autocfg.input_pins[i];
4204 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004205 snd_hda_codec_write(codec, nid, 0,
4206 AC_VERB_SET_PIN_WIDGET_CONTROL,
4207 i <= AUTO_PIN_FRONT_MIC ?
4208 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004210 snd_hda_codec_write(codec, nid, 0,
4211 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004212 AMP_OUT_MUTE);
4213 }
4214 }
4215}
4216
4217/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004218/* return 1 if successful, 0 if the proper config is not found,
4219 * or a negative error code
4220 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004221static int alc880_parse_auto_config(struct hda_codec *codec)
4222{
4223 struct alc_spec *spec = codec->spec;
4224 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004225 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4228 alc880_ignore);
4229 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004231 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004232 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004233
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004234 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4235 if (err < 0)
4236 return err;
4237 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4238 if (err < 0)
4239 return err;
4240 err = alc880_auto_create_extra_out(spec,
4241 spec->autocfg.speaker_pins[0],
4242 "Speaker");
4243 if (err < 0)
4244 return err;
4245 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4246 "Headphone");
4247 if (err < 0)
4248 return err;
4249 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4250 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004251 return err;
4252
4253 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4254
4255 if (spec->autocfg.dig_out_pin)
4256 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4257 if (spec->autocfg.dig_in_pin)
4258 spec->dig_in_nid = ALC880_DIGIN_NID;
4259
Takashi Iwai603c4012008-07-30 15:01:44 +02004260 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004261 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262
Takashi Iwaid88897e2008-10-31 15:01:37 +01004263 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004265 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 spec->input_mux = &spec->private_imux;
4267
Takashi Iwaie044c392008-10-27 16:56:24 +01004268 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 return 1;
4270}
4271
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004272/* additional initialization for auto-configuration model */
4273static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004275 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004277 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004279 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004280 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281}
4282
4283/*
4284 * OK, here we have finally the patch for ALC880
4285 */
4286
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004287static void set_capture_mixer(struct alc_spec *spec)
4288{
4289 static struct snd_kcontrol_new *caps[3] = {
4290 alc_capture_mixer1,
4291 alc_capture_mixer2,
4292 alc_capture_mixer3,
4293 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004294 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004295 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4296}
4297
Linus Torvalds1da177e2005-04-16 15:20:36 -07004298static int patch_alc880(struct hda_codec *codec)
4299{
4300 struct alc_spec *spec;
4301 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004302 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004303
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004304 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004305 if (spec == NULL)
4306 return -ENOMEM;
4307
4308 codec->spec = spec;
4309
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004310 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4311 alc880_models,
4312 alc880_cfg_tbl);
4313 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004314 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4315 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004317 }
4318
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319 if (board_config == ALC880_AUTO) {
4320 /* automatic parse from the BIOS config */
4321 err = alc880_parse_auto_config(codec);
4322 if (err < 0) {
4323 alc_free(codec);
4324 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004325 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004326 printk(KERN_INFO
4327 "hda_codec: Cannot set up configuration "
4328 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 board_config = ALC880_3ST;
4330 }
4331 }
4332
Kailang Yangdf694da2005-12-05 19:42:22 +01004333 if (board_config != ALC880_AUTO)
4334 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004335
4336 spec->stream_name_analog = "ALC880 Analog";
4337 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4338 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004339 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004340
4341 spec->stream_name_digital = "ALC880 Digital";
4342 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4343 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4344
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004345 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004346 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004347 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004348 /* get type */
4349 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 if (wcap != AC_WID_AUD_IN) {
4351 spec->adc_nids = alc880_adc_nids_alt;
4352 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353 } else {
4354 spec->adc_nids = alc880_adc_nids;
4355 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 }
4357 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004358 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359
Takashi Iwai2134ea42008-01-10 16:53:55 +01004360 spec->vmaster_nid = 0x0c;
4361
Linus Torvalds1da177e2005-04-16 15:20:36 -07004362 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004364 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004365#ifdef CONFIG_SND_HDA_POWER_SAVE
4366 if (!spec->loopback.amplist)
4367 spec->loopback.amplist = alc880_loopbacks;
4368#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004369 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004370
4371 return 0;
4372}
4373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374
Linus Torvalds1da177e2005-04-16 15:20:36 -07004375/*
4376 * ALC260 support
4377 */
4378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004379static hda_nid_t alc260_dac_nids[1] = {
4380 /* front */
4381 0x02,
4382};
4383
4384static hda_nid_t alc260_adc_nids[1] = {
4385 /* ADC0 */
4386 0x04,
4387};
4388
Kailang Yangdf694da2005-12-05 19:42:22 +01004389static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004390 /* ADC1 */
4391 0x05,
4392};
4393
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004394/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4395 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4396 */
4397static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004398 /* ADC0, ADC1 */
4399 0x04, 0x05
4400};
4401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004402#define ALC260_DIGOUT_NID 0x03
4403#define ALC260_DIGIN_NID 0x06
4404
4405static struct hda_input_mux alc260_capture_source = {
4406 .num_items = 4,
4407 .items = {
4408 { "Mic", 0x0 },
4409 { "Front Mic", 0x1 },
4410 { "Line", 0x2 },
4411 { "CD", 0x4 },
4412 },
4413};
4414
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004415/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004416 * headphone jack and the internal CD lines since these are the only pins at
4417 * which audio can appear. For flexibility, also allow the option of
4418 * recording the mixer output on the second ADC (ADC0 doesn't have a
4419 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004420 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004421static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4422 {
4423 .num_items = 3,
4424 .items = {
4425 { "Mic/Line", 0x0 },
4426 { "CD", 0x4 },
4427 { "Headphone", 0x2 },
4428 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004429 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004430 {
4431 .num_items = 4,
4432 .items = {
4433 { "Mic/Line", 0x0 },
4434 { "CD", 0x4 },
4435 { "Headphone", 0x2 },
4436 { "Mixer", 0x5 },
4437 },
4438 },
4439
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004440};
4441
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004442/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4443 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004444 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004445static struct hda_input_mux alc260_acer_capture_sources[2] = {
4446 {
4447 .num_items = 4,
4448 .items = {
4449 { "Mic", 0x0 },
4450 { "Line", 0x2 },
4451 { "CD", 0x4 },
4452 { "Headphone", 0x5 },
4453 },
4454 },
4455 {
4456 .num_items = 5,
4457 .items = {
4458 { "Mic", 0x0 },
4459 { "Line", 0x2 },
4460 { "CD", 0x4 },
4461 { "Headphone", 0x6 },
4462 { "Mixer", 0x5 },
4463 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004464 },
4465};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004466/*
4467 * This is just place-holder, so there's something for alc_build_pcms to look
4468 * at when it calculates the maximum number of channels. ALC260 has no mixer
4469 * element which allows changing the channel mode, so the verb list is
4470 * never used.
4471 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004472static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004473 { 2, NULL },
4474};
4475
Kailang Yangdf694da2005-12-05 19:42:22 +01004476
4477/* Mixer combinations
4478 *
4479 * basic: base_output + input + pc_beep + capture
4480 * HP: base_output + input + capture_alt
4481 * HP_3013: hp_3013 + input + capture
4482 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004483 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004484 */
4485
4486static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004487 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004488 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4490 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4491 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4492 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4493 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004494};
Kailang Yangdf694da2005-12-05 19:42:22 +01004495
4496static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004497 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4498 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4499 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4500 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4502 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004505 { } /* end */
4506};
4507
Kailang Yangdf694da2005-12-05 19:42:22 +01004508static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4511 { } /* end */
4512};
4513
Takashi Iwaibec15c32008-01-28 18:16:30 +01004514/* update HP, line and mono out pins according to the master switch */
4515static void alc260_hp_master_update(struct hda_codec *codec,
4516 hda_nid_t hp, hda_nid_t line,
4517 hda_nid_t mono)
4518{
4519 struct alc_spec *spec = codec->spec;
4520 unsigned int val = spec->master_sw ? PIN_HP : 0;
4521 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004522 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004523 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004524 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004525 val);
4526 /* mono (speaker) depending on the HP jack sense */
4527 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004528 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004529 val);
4530}
4531
4532static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4533 struct snd_ctl_elem_value *ucontrol)
4534{
4535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4536 struct alc_spec *spec = codec->spec;
4537 *ucontrol->value.integer.value = spec->master_sw;
4538 return 0;
4539}
4540
4541static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4542 struct snd_ctl_elem_value *ucontrol)
4543{
4544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4545 struct alc_spec *spec = codec->spec;
4546 int val = !!*ucontrol->value.integer.value;
4547 hda_nid_t hp, line, mono;
4548
4549 if (val == spec->master_sw)
4550 return 0;
4551 spec->master_sw = val;
4552 hp = (kcontrol->private_value >> 16) & 0xff;
4553 line = (kcontrol->private_value >> 8) & 0xff;
4554 mono = kcontrol->private_value & 0xff;
4555 alc260_hp_master_update(codec, hp, line, mono);
4556 return 1;
4557}
4558
4559static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4560 {
4561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4562 .name = "Master Playback Switch",
4563 .info = snd_ctl_boolean_mono_info,
4564 .get = alc260_hp_master_sw_get,
4565 .put = alc260_hp_master_sw_put,
4566 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4567 },
4568 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4569 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4571 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4572 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4573 HDA_OUTPUT),
4574 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4575 { } /* end */
4576};
4577
4578static struct hda_verb alc260_hp_unsol_verbs[] = {
4579 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4580 {},
4581};
4582
4583static void alc260_hp_automute(struct hda_codec *codec)
4584{
4585 struct alc_spec *spec = codec->spec;
4586 unsigned int present;
4587
4588 present = snd_hda_codec_read(codec, 0x10, 0,
4589 AC_VERB_GET_PIN_SENSE, 0);
4590 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4591 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4592}
4593
4594static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4595{
4596 if ((res >> 26) == ALC880_HP_EVENT)
4597 alc260_hp_automute(codec);
4598}
4599
Kailang Yangdf694da2005-12-05 19:42:22 +01004600static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004601 {
4602 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4603 .name = "Master Playback Switch",
4604 .info = snd_ctl_boolean_mono_info,
4605 .get = alc260_hp_master_sw_get,
4606 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004607 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004608 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004609 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4610 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4611 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4612 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4613 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4614 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004615 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4616 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004617 { } /* end */
4618};
4619
Kailang Yang3f878302008-08-26 13:02:23 +02004620static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4621 .ops = &snd_hda_bind_vol,
4622 .values = {
4623 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4624 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4625 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4626 0
4627 },
4628};
4629
4630static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4631 .ops = &snd_hda_bind_sw,
4632 .values = {
4633 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4634 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4635 0
4636 },
4637};
4638
4639static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4640 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4641 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4642 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4644 { } /* end */
4645};
4646
Takashi Iwaibec15c32008-01-28 18:16:30 +01004647static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4648 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4649 {},
4650};
4651
4652static void alc260_hp_3013_automute(struct hda_codec *codec)
4653{
4654 struct alc_spec *spec = codec->spec;
4655 unsigned int present;
4656
4657 present = snd_hda_codec_read(codec, 0x15, 0,
4658 AC_VERB_GET_PIN_SENSE, 0);
4659 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004660 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004661}
4662
4663static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4664 unsigned int res)
4665{
4666 if ((res >> 26) == ALC880_HP_EVENT)
4667 alc260_hp_3013_automute(codec);
4668}
4669
Kailang Yang3f878302008-08-26 13:02:23 +02004670static void alc260_hp_3012_automute(struct hda_codec *codec)
4671{
4672 unsigned int present, bits;
4673
4674 present = snd_hda_codec_read(codec, 0x10, 0,
4675 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4676
4677 bits = present ? 0 : PIN_OUT;
4678 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4679 bits);
4680 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4681 bits);
4682 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4683 bits);
4684}
4685
4686static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4687 unsigned int res)
4688{
4689 if ((res >> 26) == ALC880_HP_EVENT)
4690 alc260_hp_3012_automute(codec);
4691}
4692
4693/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004694 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4695 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004696static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004697 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004698 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004699 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004700 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4701 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4702 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4703 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004704 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004705 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4706 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004707 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4708 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004709 { } /* end */
4710};
4711
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004712/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4713 * versions of the ALC260 don't act on requests to enable mic bias from NID
4714 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4715 * datasheet doesn't mention this restriction. At this stage it's not clear
4716 * whether this behaviour is intentional or is a hardware bug in chip
4717 * revisions available in early 2006. Therefore for now allow the
4718 * "Headphone Jack Mode" control to span all choices, but if it turns out
4719 * that the lack of mic bias for this NID is intentional we could change the
4720 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4721 *
4722 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4723 * don't appear to make the mic bias available from the "line" jack, even
4724 * though the NID used for this jack (0x14) can supply it. The theory is
4725 * that perhaps Acer have included blocking capacitors between the ALC260
4726 * and the output jack. If this turns out to be the case for all such
4727 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4728 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004729 *
4730 * The C20x Tablet series have a mono internal speaker which is controlled
4731 * via the chip's Mono sum widget and pin complex, so include the necessary
4732 * controls for such models. On models without a "mono speaker" the control
4733 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004734 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004735static struct snd_kcontrol_new alc260_acer_mixer[] = {
4736 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4737 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004738 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004739 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004740 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004741 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004742 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004743 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4744 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4746 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4747 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4748 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4749 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4750 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4751 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4752 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4753 { } /* end */
4754};
4755
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004756/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4757 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4758 */
4759static struct snd_kcontrol_new alc260_will_mixer[] = {
4760 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4761 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4763 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4764 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4765 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4766 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4767 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4768 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4769 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4771 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4772 { } /* end */
4773};
4774
4775/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4776 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4777 */
4778static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4779 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4780 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4782 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4783 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4784 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4785 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4786 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4787 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4788 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4789 { } /* end */
4790};
4791
Kailang Yangdf694da2005-12-05 19:42:22 +01004792/*
4793 * initialization verbs
4794 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004795static struct hda_verb alc260_init_verbs[] = {
4796 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004798 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004799 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004801 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004803 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004804 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004806 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004807 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004809 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004811 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004813 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4814 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004815 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816 /* set connection select to line in (default select for this ADC) */
4817 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004818 /* mute capture amp left and right */
4819 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4820 /* set connection select to line in (default select for this ADC) */
4821 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004822 /* set vol=0 Line-Out mixer amp left and right */
4823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4824 /* unmute pin widget amp left and right (no gain on this amp) */
4825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4826 /* set vol=0 HP mixer amp left and right */
4827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4828 /* unmute pin widget amp left and right (no gain on this amp) */
4829 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4830 /* set vol=0 Mono mixer amp left and right */
4831 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4832 /* unmute pin widget amp left and right (no gain on this amp) */
4833 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4834 /* unmute LINE-2 out pin */
4835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004836 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4837 * Line In 2 = 0x03
4838 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004839 /* mute analog inputs */
4840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004846 /* mute Front out path */
4847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4848 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4849 /* mute Headphone out path */
4850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4851 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4852 /* mute Mono out path */
4853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4854 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004855 { }
4856};
4857
Takashi Iwai474167d2006-05-17 17:17:43 +02004858#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004859static struct hda_verb alc260_hp_init_verbs[] = {
4860 /* Headphone and output */
4861 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4862 /* mono output */
4863 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4864 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4865 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4866 /* Mic2 (front panel) pin widget for input and vref at 80% */
4867 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4868 /* Line In pin widget for input */
4869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4870 /* Line-2 pin widget for output */
4871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4872 /* CD pin widget for input */
4873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4874 /* unmute amp left and right */
4875 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4876 /* set connection select to line in (default select for this ADC) */
4877 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4878 /* unmute Line-Out mixer amp left and right (volume = 0) */
4879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4880 /* mute pin widget amp left and right (no gain on this amp) */
4881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4882 /* unmute HP mixer amp left and right (volume = 0) */
4883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4884 /* mute pin widget amp left and right (no gain on this amp) */
4885 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004886 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4887 * Line In 2 = 0x03
4888 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004889 /* mute analog inputs */
4890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004895 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4896 /* Unmute Front out path */
4897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4899 /* Unmute Headphone out path */
4900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4902 /* Unmute Mono out path */
4903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4905 { }
4906};
Takashi Iwai474167d2006-05-17 17:17:43 +02004907#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004908
4909static struct hda_verb alc260_hp_3013_init_verbs[] = {
4910 /* Line out and output */
4911 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4912 /* mono output */
4913 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4914 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4915 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4916 /* Mic2 (front panel) pin widget for input and vref at 80% */
4917 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4918 /* Line In pin widget for input */
4919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4920 /* Headphone pin widget for output */
4921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4922 /* CD pin widget for input */
4923 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4924 /* unmute amp left and right */
4925 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4926 /* set connection select to line in (default select for this ADC) */
4927 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4928 /* unmute Line-Out mixer amp left and right (volume = 0) */
4929 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4930 /* mute pin widget amp left and right (no gain on this amp) */
4931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4932 /* unmute HP mixer amp left and right (volume = 0) */
4933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4934 /* mute pin widget amp left and right (no gain on this amp) */
4935 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004936 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4937 * Line In 2 = 0x03
4938 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004939 /* mute analog inputs */
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004945 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4946 /* Unmute Front out path */
4947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4949 /* Unmute Headphone out path */
4950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4952 /* Unmute Mono out path */
4953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4954 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4955 { }
4956};
4957
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004958/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004959 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4960 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004961 */
4962static struct hda_verb alc260_fujitsu_init_verbs[] = {
4963 /* Disable all GPIOs */
4964 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4965 /* Internal speaker is connected to headphone pin */
4966 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4967 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004969 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4970 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4971 /* Ensure all other unused pins are disabled and muted. */
4972 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4973 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004974 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004975 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004976 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004977 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004980
Jonathan Woithef7ace402006-02-28 11:46:14 +01004981 /* Disable digital (SPDIF) pins */
4982 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4983 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004984
Kailang Yangea1fb292008-08-26 12:58:38 +02004985 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004986 * when acting as an output.
4987 */
4988 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4989
4990 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4992 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4998 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4999 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005000
Jonathan Woithef7ace402006-02-28 11:46:14 +01005001 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5002 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5003 /* Unmute Line1 pin widget output buffer since it starts as an output.
5004 * If the pin mode is changed by the user the pin mode control will
5005 * take care of enabling the pin's input/output buffers as needed.
5006 * Therefore there's no need to enable the input buffer at this
5007 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005008 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005010 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005011 * mixer ctrl)
5012 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005013 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005014
Jonathan Woithef7ace402006-02-28 11:46:14 +01005015 /* Mute capture amp left and right */
5016 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005017 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005018 * in (on mic1 pin)
5019 */
5020 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005021
Jonathan Woithef7ace402006-02-28 11:46:14 +01005022 /* Do the same for the second ADC: mute capture input amp and
5023 * set ADC connection to line in (on mic1 pin)
5024 */
5025 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5026 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005027
Jonathan Woithef7ace402006-02-28 11:46:14 +01005028 /* Mute all inputs to mixer widget (even unconnected ones) */
5029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005037
5038 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005039};
5040
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005041/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5042 * similar laptops (adapted from Fujitsu init verbs).
5043 */
5044static struct hda_verb alc260_acer_init_verbs[] = {
5045 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5046 * the headphone jack. Turn this on and rely on the standard mute
5047 * methods whenever the user wants to turn these outputs off.
5048 */
5049 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5050 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5051 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5052 /* Internal speaker/Headphone jack is connected to Line-out pin */
5053 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5054 /* Internal microphone/Mic jack is connected to Mic1 pin */
5055 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5056 /* Line In jack is connected to Line1 pin */
5057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005058 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5059 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005060 /* Ensure all other unused pins are disabled and muted. */
5061 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5062 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005063 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5064 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5067 /* Disable digital (SPDIF) pins */
5068 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5069 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5070
Kailang Yangea1fb292008-08-26 12:58:38 +02005071 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005072 * bus when acting as outputs.
5073 */
5074 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5075 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5076
5077 /* Start with output sum widgets muted and their output gains at min */
5078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5084 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5085 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5086 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5087
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005088 /* Unmute Line-out pin widget amp left and right
5089 * (no equiv mixer ctrl)
5090 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005092 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5093 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005094 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5095 * inputs. If the pin mode is changed by the user the pin mode control
5096 * will take care of enabling the pin's input/output buffers as needed.
5097 * Therefore there's no need to enable the input buffer at this
5098 * stage.
5099 */
5100 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5102
5103 /* Mute capture amp left and right */
5104 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5105 /* Set ADC connection select to match default mixer setting - mic
5106 * (on mic1 pin)
5107 */
5108 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5109
5110 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005111 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005112 */
5113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005114 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005115
5116 /* Mute all inputs to mixer widget (even unconnected ones) */
5117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5123 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5125
5126 { }
5127};
5128
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005129static struct hda_verb alc260_will_verbs[] = {
5130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5131 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5132 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5133 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5134 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5135 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5136 {}
5137};
5138
5139static struct hda_verb alc260_replacer_672v_verbs[] = {
5140 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5141 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5142 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5143
5144 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5145 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5146 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5147
5148 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5149 {}
5150};
5151
5152/* toggle speaker-output according to the hp-jack state */
5153static void alc260_replacer_672v_automute(struct hda_codec *codec)
5154{
5155 unsigned int present;
5156
5157 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5158 present = snd_hda_codec_read(codec, 0x0f, 0,
5159 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5160 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005161 snd_hda_codec_write_cache(codec, 0x01, 0,
5162 AC_VERB_SET_GPIO_DATA, 1);
5163 snd_hda_codec_write_cache(codec, 0x0f, 0,
5164 AC_VERB_SET_PIN_WIDGET_CONTROL,
5165 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005166 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005167 snd_hda_codec_write_cache(codec, 0x01, 0,
5168 AC_VERB_SET_GPIO_DATA, 0);
5169 snd_hda_codec_write_cache(codec, 0x0f, 0,
5170 AC_VERB_SET_PIN_WIDGET_CONTROL,
5171 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005172 }
5173}
5174
5175static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5176 unsigned int res)
5177{
5178 if ((res >> 26) == ALC880_HP_EVENT)
5179 alc260_replacer_672v_automute(codec);
5180}
5181
Kailang Yang3f878302008-08-26 13:02:23 +02005182static struct hda_verb alc260_hp_dc7600_verbs[] = {
5183 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5184 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5185 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5186 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5187 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5189 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5190 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5191 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5193 {}
5194};
5195
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005196/* Test configuration for debugging, modelled after the ALC880 test
5197 * configuration.
5198 */
5199#ifdef CONFIG_SND_DEBUG
5200static hda_nid_t alc260_test_dac_nids[1] = {
5201 0x02,
5202};
5203static hda_nid_t alc260_test_adc_nids[2] = {
5204 0x04, 0x05,
5205};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005206/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005207 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005208 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005209 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005210static struct hda_input_mux alc260_test_capture_sources[2] = {
5211 {
5212 .num_items = 7,
5213 .items = {
5214 { "MIC1 pin", 0x0 },
5215 { "MIC2 pin", 0x1 },
5216 { "LINE1 pin", 0x2 },
5217 { "LINE2 pin", 0x3 },
5218 { "CD pin", 0x4 },
5219 { "LINE-OUT pin", 0x5 },
5220 { "HP-OUT pin", 0x6 },
5221 },
5222 },
5223 {
5224 .num_items = 8,
5225 .items = {
5226 { "MIC1 pin", 0x0 },
5227 { "MIC2 pin", 0x1 },
5228 { "LINE1 pin", 0x2 },
5229 { "LINE2 pin", 0x3 },
5230 { "CD pin", 0x4 },
5231 { "Mixer", 0x5 },
5232 { "LINE-OUT pin", 0x6 },
5233 { "HP-OUT pin", 0x7 },
5234 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005235 },
5236};
5237static struct snd_kcontrol_new alc260_test_mixer[] = {
5238 /* Output driver widgets */
5239 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5240 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5241 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5242 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5243 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5244 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5245
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005246 /* Modes for retasking pin widgets
5247 * Note: the ALC260 doesn't seem to act on requests to enable mic
5248 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5249 * mention this restriction. At this stage it's not clear whether
5250 * this behaviour is intentional or is a hardware bug in chip
5251 * revisions available at least up until early 2006. Therefore for
5252 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5253 * choices, but if it turns out that the lack of mic bias for these
5254 * NIDs is intentional we could change their modes from
5255 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5256 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005257 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5258 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5259 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5260 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5261 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5262 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5263
5264 /* Loopback mixer controls */
5265 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5266 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5267 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5268 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5269 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5270 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5271 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5272 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5273 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5274 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5275 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5276 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5277 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5278 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5279 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5280 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005281
5282 /* Controls for GPIO pins, assuming they are configured as outputs */
5283 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5284 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5285 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5286 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5287
Jonathan Woithe92621f12006-02-28 11:47:47 +01005288 /* Switches to allow the digital IO pins to be enabled. The datasheet
5289 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005290 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005291 */
5292 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5293 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5294
Jonathan Woithef8225f62008-01-08 12:16:54 +01005295 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5296 * this output to turn on an external amplifier.
5297 */
5298 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5299 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5300
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005301 { } /* end */
5302};
5303static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005304 /* Enable all GPIOs as outputs with an initial value of 0 */
5305 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5306 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5307 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5308
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005309 /* Enable retasking pins as output, initially without power amp */
5310 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5311 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5314 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5316
Jonathan Woithe92621f12006-02-28 11:47:47 +01005317 /* Disable digital (SPDIF) pins initially, but users can enable
5318 * them via a mixer switch. In the case of SPDIF-out, this initverb
5319 * payload also sets the generation to 0, output to be in "consumer"
5320 * PCM format, copyright asserted, no pre-emphasis and no validity
5321 * control.
5322 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005323 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5324 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5325
Kailang Yangea1fb292008-08-26 12:58:38 +02005326 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005327 * OUT1 sum bus when acting as an output.
5328 */
5329 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5330 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5331 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5332 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5333
5334 /* Start with output sum widgets muted and their output gains at min */
5335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5344
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005345 /* Unmute retasking pin widget output buffers since the default
5346 * state appears to be output. As the pin mode is changed by the
5347 * user the pin mode control will take care of enabling the pin's
5348 * input/output buffers as needed.
5349 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005350 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5354 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5355 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5356 /* Also unmute the mono-out pin widget */
5357 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5358
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005359 /* Mute capture amp left and right */
5360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005361 /* Set ADC connection select to match default mixer setting (mic1
5362 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005363 */
5364 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5365
5366 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005367 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005368 */
5369 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5370 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5371
5372 /* Mute all inputs to mixer widget (even unconnected ones) */
5373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5381
5382 { }
5383};
5384#endif
5385
Takashi Iwai63300792008-01-24 15:31:36 +01005386#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5387#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005389#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5390#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5391
Kailang Yangdf694da2005-12-05 19:42:22 +01005392/*
5393 * for BIOS auto-configuration
5394 */
5395
5396static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005397 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005398{
5399 hda_nid_t nid_vol;
5400 unsigned long vol_val, sw_val;
5401 char name[32];
5402 int err;
5403
5404 if (nid >= 0x0f && nid < 0x11) {
5405 nid_vol = nid - 0x7;
5406 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5407 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5408 } else if (nid == 0x11) {
5409 nid_vol = nid - 0x7;
5410 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5411 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5412 } else if (nid >= 0x12 && nid <= 0x15) {
5413 nid_vol = 0x08;
5414 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5415 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5416 } else
5417 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005418
Takashi Iwai863b4512008-10-21 17:01:47 +02005419 if (!(*vol_bits & (1 << nid_vol))) {
5420 /* first control for the volume widget */
5421 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5422 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5423 if (err < 0)
5424 return err;
5425 *vol_bits |= (1 << nid_vol);
5426 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005427 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005428 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5429 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005430 return err;
5431 return 1;
5432}
5433
5434/* add playback controls from the parsed DAC table */
5435static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5436 const struct auto_pin_cfg *cfg)
5437{
5438 hda_nid_t nid;
5439 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005440 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005441
5442 spec->multiout.num_dacs = 1;
5443 spec->multiout.dac_nids = spec->private_dac_nids;
5444 spec->multiout.dac_nids[0] = 0x02;
5445
5446 nid = cfg->line_out_pins[0];
5447 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005448 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005449 if (err < 0)
5450 return err;
5451 }
5452
Takashi Iwai82bc9552006-03-21 11:24:42 +01005453 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005454 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005455 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005456 if (err < 0)
5457 return err;
5458 }
5459
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005460 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005461 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005462 err = alc260_add_playback_controls(spec, nid, "Headphone",
5463 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005464 if (err < 0)
5465 return err;
5466 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005467 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005468}
5469
5470/* create playback/capture controls for input pins */
5471static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5472 const struct auto_pin_cfg *cfg)
5473{
Kailang Yangdf694da2005-12-05 19:42:22 +01005474 struct hda_input_mux *imux = &spec->private_imux;
5475 int i, err, idx;
5476
5477 for (i = 0; i < AUTO_PIN_LAST; i++) {
5478 if (cfg->input_pins[i] >= 0x12) {
5479 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005480 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005481 auto_pin_cfg_labels[i], idx,
5482 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005483 if (err < 0)
5484 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005485 imux->items[imux->num_items].label =
5486 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005487 imux->items[imux->num_items].index = idx;
5488 imux->num_items++;
5489 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005490 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005491 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005492 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005493 auto_pin_cfg_labels[i], idx,
5494 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005495 if (err < 0)
5496 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005497 imux->items[imux->num_items].label =
5498 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005499 imux->items[imux->num_items].index = idx;
5500 imux->num_items++;
5501 }
5502 }
5503 return 0;
5504}
5505
5506static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5507 hda_nid_t nid, int pin_type,
5508 int sel_idx)
5509{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005510 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005511 /* need the manual connection? */
5512 if (nid >= 0x12) {
5513 int idx = nid - 0x12;
5514 snd_hda_codec_write(codec, idx + 0x0b, 0,
5515 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005516 }
5517}
5518
5519static void alc260_auto_init_multi_out(struct hda_codec *codec)
5520{
5521 struct alc_spec *spec = codec->spec;
5522 hda_nid_t nid;
5523
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005524 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005525 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005526 if (nid) {
5527 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5528 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5529 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005530
Takashi Iwai82bc9552006-03-21 11:24:42 +01005531 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 if (nid)
5533 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5534
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005535 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005536 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005537 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005538}
Kailang Yangdf694da2005-12-05 19:42:22 +01005539
5540#define ALC260_PIN_CD_NID 0x16
5541static void alc260_auto_init_analog_input(struct hda_codec *codec)
5542{
5543 struct alc_spec *spec = codec->spec;
5544 int i;
5545
5546 for (i = 0; i < AUTO_PIN_LAST; i++) {
5547 hda_nid_t nid = spec->autocfg.input_pins[i];
5548 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005549 snd_hda_codec_write(codec, nid, 0,
5550 AC_VERB_SET_PIN_WIDGET_CONTROL,
5551 i <= AUTO_PIN_FRONT_MIC ?
5552 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005553 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554 snd_hda_codec_write(codec, nid, 0,
5555 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005556 AMP_OUT_MUTE);
5557 }
5558 }
5559}
5560
5561/*
5562 * generic initialization of ADC, input mixers and output mixers
5563 */
5564static struct hda_verb alc260_volume_init_verbs[] = {
5565 /*
5566 * Unmute ADC0-1 and set the default input to mic-in
5567 */
5568 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5569 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5571 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005572
Kailang Yangdf694da2005-12-05 19:42:22 +01005573 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5574 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005575 * Note: PASD motherboards uses the Line In 2 as the input for
5576 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005577 */
5578 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005579 /* mute analog inputs */
5580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5583 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005585
5586 /*
5587 * Set up output mixers (0x08 - 0x0a)
5588 */
5589 /* set vol=0 to output mixers */
5590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5592 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5593 /* set up input amps for analog loopback */
5594 /* Amp Indices: DAC = 0, mixer = 1 */
5595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5600 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005601
Kailang Yangdf694da2005-12-05 19:42:22 +01005602 { }
5603};
5604
5605static int alc260_parse_auto_config(struct hda_codec *codec)
5606{
5607 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005608 int err;
5609 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5610
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005611 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5612 alc260_ignore);
5613 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005614 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005615 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5616 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005617 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005618 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005619 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005620 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5621 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005622 return err;
5623
5624 spec->multiout.max_channels = 2;
5625
5626 if (spec->autocfg.dig_out_pin)
5627 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005628 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005629 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005630
Takashi Iwaid88897e2008-10-31 15:01:37 +01005631 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005632
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005633 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005634 spec->input_mux = &spec->private_imux;
5635
Takashi Iwaie044c392008-10-27 16:56:24 +01005636 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 return 1;
5638}
5639
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005640/* additional initialization for auto-configuration model */
5641static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005642{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005643 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005644 alc260_auto_init_multi_out(codec);
5645 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005646 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005647 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005648}
5649
Takashi Iwaicb53c622007-08-10 17:21:45 +02005650#ifdef CONFIG_SND_HDA_POWER_SAVE
5651static struct hda_amp_list alc260_loopbacks[] = {
5652 { 0x07, HDA_INPUT, 0 },
5653 { 0x07, HDA_INPUT, 1 },
5654 { 0x07, HDA_INPUT, 2 },
5655 { 0x07, HDA_INPUT, 3 },
5656 { 0x07, HDA_INPUT, 4 },
5657 { } /* end */
5658};
5659#endif
5660
Kailang Yangdf694da2005-12-05 19:42:22 +01005661/*
5662 * ALC260 configurations
5663 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005664static const char *alc260_models[ALC260_MODEL_LAST] = {
5665 [ALC260_BASIC] = "basic",
5666 [ALC260_HP] = "hp",
5667 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005668 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005669 [ALC260_FUJITSU_S702X] = "fujitsu",
5670 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005671 [ALC260_WILL] = "will",
5672 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005673#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005674 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005675#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005676 [ALC260_AUTO] = "auto",
5677};
5678
5679static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005680 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005681 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005682 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005683 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005684 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005685 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005686 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005687 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5688 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5689 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5690 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5691 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5692 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5693 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5694 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5695 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005696 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005697 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005698 {}
5699};
5700
Kailang Yangdf694da2005-12-05 19:42:22 +01005701static struct alc_config_preset alc260_presets[] = {
5702 [ALC260_BASIC] = {
5703 .mixers = { alc260_base_output_mixer,
5704 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005705 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005706 .init_verbs = { alc260_init_verbs },
5707 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5708 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005709 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005710 .adc_nids = alc260_adc_nids,
5711 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5712 .channel_mode = alc260_modes,
5713 .input_mux = &alc260_capture_source,
5714 },
5715 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005716 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005717 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005718 .init_verbs = { alc260_init_verbs,
5719 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005720 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5721 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005722 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5723 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005724 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5725 .channel_mode = alc260_modes,
5726 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005727 .unsol_event = alc260_hp_unsol_event,
5728 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005729 },
Kailang Yang3f878302008-08-26 13:02:23 +02005730 [ALC260_HP_DC7600] = {
5731 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005732 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005733 .init_verbs = { alc260_init_verbs,
5734 alc260_hp_dc7600_verbs },
5735 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5736 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005737 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5738 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005739 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5740 .channel_mode = alc260_modes,
5741 .input_mux = &alc260_capture_source,
5742 .unsol_event = alc260_hp_3012_unsol_event,
5743 .init_hook = alc260_hp_3012_automute,
5744 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005745 [ALC260_HP_3013] = {
5746 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005747 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005748 .init_verbs = { alc260_hp_3013_init_verbs,
5749 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005750 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5751 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005752 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5753 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005754 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5755 .channel_mode = alc260_modes,
5756 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005757 .unsol_event = alc260_hp_3013_unsol_event,
5758 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005759 },
5760 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005761 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005762 .init_verbs = { alc260_fujitsu_init_verbs },
5763 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5764 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005765 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5766 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005767 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5768 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005769 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5770 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005771 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005772 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005773 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005774 .init_verbs = { alc260_acer_init_verbs },
5775 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5776 .dac_nids = alc260_dac_nids,
5777 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5778 .adc_nids = alc260_dual_adc_nids,
5779 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5780 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005781 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5782 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005783 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005784 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005785 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005786 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5787 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5788 .dac_nids = alc260_dac_nids,
5789 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5790 .adc_nids = alc260_adc_nids,
5791 .dig_out_nid = ALC260_DIGOUT_NID,
5792 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5793 .channel_mode = alc260_modes,
5794 .input_mux = &alc260_capture_source,
5795 },
5796 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005797 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005798 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5799 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5800 .dac_nids = alc260_dac_nids,
5801 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5802 .adc_nids = alc260_adc_nids,
5803 .dig_out_nid = ALC260_DIGOUT_NID,
5804 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5805 .channel_mode = alc260_modes,
5806 .input_mux = &alc260_capture_source,
5807 .unsol_event = alc260_replacer_672v_unsol_event,
5808 .init_hook = alc260_replacer_672v_automute,
5809 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005810#ifdef CONFIG_SND_DEBUG
5811 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005812 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005813 .init_verbs = { alc260_test_init_verbs },
5814 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5815 .dac_nids = alc260_test_dac_nids,
5816 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5817 .adc_nids = alc260_test_adc_nids,
5818 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5819 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005820 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5821 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005822 },
5823#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005824};
5825
Linus Torvalds1da177e2005-04-16 15:20:36 -07005826static int patch_alc260(struct hda_codec *codec)
5827{
5828 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005829 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005830
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005831 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005832 if (spec == NULL)
5833 return -ENOMEM;
5834
5835 codec->spec = spec;
5836
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005837 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5838 alc260_models,
5839 alc260_cfg_tbl);
5840 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005841 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5842 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005844 }
5845
Kailang Yangdf694da2005-12-05 19:42:22 +01005846 if (board_config == ALC260_AUTO) {
5847 /* automatic parse from the BIOS config */
5848 err = alc260_parse_auto_config(codec);
5849 if (err < 0) {
5850 alc_free(codec);
5851 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005852 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005853 printk(KERN_INFO
5854 "hda_codec: Cannot set up configuration "
5855 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005856 board_config = ALC260_BASIC;
5857 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005858 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005859
Kailang Yangdf694da2005-12-05 19:42:22 +01005860 if (board_config != ALC260_AUTO)
5861 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005862
5863 spec->stream_name_analog = "ALC260 Analog";
5864 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5865 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5866
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005867 spec->stream_name_digital = "ALC260 Digital";
5868 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5869 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5870
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005871 if (!spec->adc_nids && spec->input_mux) {
5872 /* check whether NID 0x04 is valid */
5873 unsigned int wcap = get_wcaps(codec, 0x04);
5874 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5875 /* get type */
5876 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5877 spec->adc_nids = alc260_adc_nids_alt;
5878 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5879 } else {
5880 spec->adc_nids = alc260_adc_nids;
5881 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5882 }
5883 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005884 set_capture_mixer(spec);
5885
Takashi Iwai2134ea42008-01-10 16:53:55 +01005886 spec->vmaster_nid = 0x08;
5887
Linus Torvalds1da177e2005-04-16 15:20:36 -07005888 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005889 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005890 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005891#ifdef CONFIG_SND_HDA_POWER_SAVE
5892 if (!spec->loopback.amplist)
5893 spec->loopback.amplist = alc260_loopbacks;
5894#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005895 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005896
5897 return 0;
5898}
5899
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005900
Linus Torvalds1da177e2005-04-16 15:20:36 -07005901/*
5902 * ALC882 support
5903 *
5904 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5905 * configuration. Each pin widget can choose any input DACs and a mixer.
5906 * Each ADC is connected from a mixer of all inputs. This makes possible
5907 * 6-channel independent captures.
5908 *
5909 * In addition, an independent DAC for the multi-playback (not used in this
5910 * driver yet).
5911 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005912#define ALC882_DIGOUT_NID 0x06
5913#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005914
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005915static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005916 { 8, NULL }
5917};
5918
5919static hda_nid_t alc882_dac_nids[4] = {
5920 /* front, rear, clfe, rear_surr */
5921 0x02, 0x03, 0x04, 0x05
5922};
5923
Kailang Yangdf694da2005-12-05 19:42:22 +01005924/* identical with ALC880 */
5925#define alc882_adc_nids alc880_adc_nids
5926#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005927
Takashi Iwaie1406342008-02-11 18:32:32 +01005928static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5929static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5930
Linus Torvalds1da177e2005-04-16 15:20:36 -07005931/* input MUX */
5932/* FIXME: should be a matrix-type input source selection */
5933
5934static struct hda_input_mux alc882_capture_source = {
5935 .num_items = 4,
5936 .items = {
5937 { "Mic", 0x0 },
5938 { "Front Mic", 0x1 },
5939 { "Line", 0x2 },
5940 { "CD", 0x4 },
5941 },
5942};
Kailang Yangdf694da2005-12-05 19:42:22 +01005943/*
Kailang Yang272a5272007-05-14 11:00:38 +02005944 * 2ch mode
5945 */
5946static struct hda_verb alc882_3ST_ch2_init[] = {
5947 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5948 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5949 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5950 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5951 { } /* end */
5952};
5953
5954/*
5955 * 6ch mode
5956 */
5957static struct hda_verb alc882_3ST_ch6_init[] = {
5958 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5959 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5960 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5961 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5962 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5963 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5964 { } /* end */
5965};
5966
5967static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5968 { 2, alc882_3ST_ch2_init },
5969 { 6, alc882_3ST_ch6_init },
5970};
5971
5972/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 * 6ch mode
5974 */
5975static struct hda_verb alc882_sixstack_ch6_init[] = {
5976 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5977 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5978 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5979 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5980 { } /* end */
5981};
5982
5983/*
5984 * 8ch mode
5985 */
5986static struct hda_verb alc882_sixstack_ch8_init[] = {
5987 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5988 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5989 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5990 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5991 { } /* end */
5992};
5993
5994static struct hda_channel_mode alc882_sixstack_modes[2] = {
5995 { 6, alc882_sixstack_ch6_init },
5996 { 8, alc882_sixstack_ch8_init },
5997};
5998
Takashi Iwai87350ad2007-08-16 18:19:38 +02005999/*
6000 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6001 */
6002
6003/*
6004 * 2ch mode
6005 */
6006static struct hda_verb alc885_mbp_ch2_init[] = {
6007 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6008 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6009 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6010 { } /* end */
6011};
6012
6013/*
6014 * 6ch mode
6015 */
6016static struct hda_verb alc885_mbp_ch6_init[] = {
6017 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6018 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6019 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6020 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6021 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6022 { } /* end */
6023};
6024
6025static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6026 { 2, alc885_mbp_ch2_init },
6027 { 6, alc885_mbp_ch6_init },
6028};
6029
6030
Linus Torvalds1da177e2005-04-16 15:20:36 -07006031/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6032 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6033 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006034static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006035 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006036 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006037 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006038 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006039 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6040 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006041 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6042 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006043 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006044 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006054 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006055 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6056 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6057 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006058 { } /* end */
6059};
6060
Takashi Iwai87350ad2007-08-16 18:19:38 +02006061static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6063 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6064 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6065 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6066 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6067 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6069 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006070 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6072 { } /* end */
6073};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006074static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6075 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6076 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6079 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6080 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6084 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6085 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6086 { } /* end */
6087};
6088
Kailang Yang272a5272007-05-14 11:00:38 +02006089static struct snd_kcontrol_new alc882_targa_mixer[] = {
6090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6091 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6093 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6094 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6095 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6096 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006099 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6101 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006102 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006103 { } /* end */
6104};
6105
6106/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6107 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6108 */
6109static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6111 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6113 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6116 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6117 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6119 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006123 { } /* end */
6124};
6125
Takashi Iwai914759b2007-09-06 14:52:04 +02006126static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6128 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6137 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6138 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6139 { } /* end */
6140};
6141
Kailang Yangdf694da2005-12-05 19:42:22 +01006142static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6143 {
6144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6145 .name = "Channel Mode",
6146 .info = alc_ch_mode_info,
6147 .get = alc_ch_mode_get,
6148 .put = alc_ch_mode_put,
6149 },
6150 { } /* end */
6151};
6152
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153static struct hda_verb alc882_init_verbs[] = {
6154 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006158 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006159 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006162 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006163 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006166 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006167 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006171 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006174 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006175 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006179 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006183 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006185 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006186 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006187 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006188 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006189 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6190 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6193 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006194 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006195 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6196 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6197 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6198 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6199 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006200 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006201 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006202
6203 /* FIXME: use matrix-type input source selection */
6204 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6205 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006210 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006215 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6220 /* ADC1: mute amp left and right */
6221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006222 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006223 /* ADC2: mute amp left and right */
6224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006225 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006226 /* ADC3: mute amp left and right */
6227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006228 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006229
6230 { }
6231};
6232
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006233static struct hda_verb alc882_eapd_verbs[] = {
6234 /* change to EAPD mode */
6235 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006236 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006237 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006238};
6239
Tobin Davis9102cd12006-12-15 10:02:12 +01006240/* Mac Pro test */
6241static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6247 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6248 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6249 { } /* end */
6250};
6251
6252static struct hda_verb alc882_macpro_init_verbs[] = {
6253 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6257 /* Front Pin: output 0 (0x0c) */
6258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6261 /* Front Mic pin: input vref at 80% */
6262 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6264 /* Speaker: output */
6265 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6267 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6268 /* Headphone output (output 0 - 0x0c) */
6269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6271 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6272
6273 /* FIXME: use matrix-type input source selection */
6274 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6275 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6280 /* Input mixer2 */
6281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6285 /* Input mixer3 */
6286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6290 /* ADC1: mute amp left and right */
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6292 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6293 /* ADC2: mute amp left and right */
6294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6295 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6296 /* ADC3: mute amp left and right */
6297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6298 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6299
6300 { }
6301};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006302
Takashi Iwai87350ad2007-08-16 18:19:38 +02006303/* Macbook Pro rev3 */
6304static struct hda_verb alc885_mbp3_init_verbs[] = {
6305 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6309 /* Rear mixer */
6310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6313 /* Front Pin: output 0 (0x0c) */
6314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6316 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6317 /* HP Pin: output 0 (0x0d) */
6318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6320 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6322 /* Mic (rear) pin: input vref at 80% */
6323 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6325 /* Front Mic pin: input vref at 80% */
6326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6328 /* Line In pin: use output 1 when in LineOut mode */
6329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6331 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6332
6333 /* FIXME: use matrix-type input source selection */
6334 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6335 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6340 /* Input mixer2 */
6341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6345 /* Input mixer3 */
6346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6350 /* ADC1: mute amp left and right */
6351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6352 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6353 /* ADC2: mute amp left and right */
6354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6356 /* ADC3: mute amp left and right */
6357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6358 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6359
6360 { }
6361};
6362
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006363/* iMac 24 mixer. */
6364static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6365 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6366 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6367 { } /* end */
6368};
6369
6370/* iMac 24 init verbs. */
6371static struct hda_verb alc885_imac24_init_verbs[] = {
6372 /* Internal speakers: output 0 (0x0c) */
6373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6375 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6376 /* Internal speakers: output 0 (0x0c) */
6377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6379 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6380 /* Headphone: output 0 (0x0c) */
6381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6384 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6385 /* Front Mic: input vref at 80% */
6386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6388 { }
6389};
6390
6391/* Toggle speaker-output according to the hp-jack state */
6392static void alc885_imac24_automute(struct hda_codec *codec)
6393{
6394 unsigned int present;
6395
6396 present = snd_hda_codec_read(codec, 0x14, 0,
6397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006398 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6399 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6400 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6401 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006402}
6403
6404/* Processes unsolicited events. */
6405static void alc885_imac24_unsol_event(struct hda_codec *codec,
6406 unsigned int res)
6407{
6408 /* Headphone insertion or removal. */
6409 if ((res >> 26) == ALC880_HP_EVENT)
6410 alc885_imac24_automute(codec);
6411}
6412
Takashi Iwai87350ad2007-08-16 18:19:38 +02006413static void alc885_mbp3_automute(struct hda_codec *codec)
6414{
6415 unsigned int present;
6416
6417 present = snd_hda_codec_read(codec, 0x15, 0,
6418 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6419 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6420 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6421 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6422 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6423
6424}
6425static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6426 unsigned int res)
6427{
6428 /* Headphone insertion or removal. */
6429 if ((res >> 26) == ALC880_HP_EVENT)
6430 alc885_mbp3_automute(codec);
6431}
6432
6433
Kailang Yang272a5272007-05-14 11:00:38 +02006434static struct hda_verb alc882_targa_verbs[] = {
6435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6437
6438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006440
Kailang Yang272a5272007-05-14 11:00:38 +02006441 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6442 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6444
6445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6446 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6447 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6448 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6449 { } /* end */
6450};
6451
6452/* toggle speaker-output according to the hp-jack state */
6453static void alc882_targa_automute(struct hda_codec *codec)
6454{
6455 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006456
Kailang Yang272a5272007-05-14 11:00:38 +02006457 present = snd_hda_codec_read(codec, 0x14, 0,
6458 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006459 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6460 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006461 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6462 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006463}
6464
6465static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6466{
6467 /* Looks like the unsol event is incompatible with the standard
6468 * definition. 4bit tag is placed at 26 bit!
6469 */
6470 if (((res >> 26) == ALC880_HP_EVENT)) {
6471 alc882_targa_automute(codec);
6472 }
6473}
6474
6475static struct hda_verb alc882_asus_a7j_verbs[] = {
6476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6478
6479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6481 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006482
Kailang Yang272a5272007-05-14 11:00:38 +02006483 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6485 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6486
6487 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6488 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6490 { } /* end */
6491};
6492
Takashi Iwai914759b2007-09-06 14:52:04 +02006493static struct hda_verb alc882_asus_a7m_verbs[] = {
6494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6496
6497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006500
Takashi Iwai914759b2007-09-06 14:52:04 +02006501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6503 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6504
6505 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6506 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6507 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6508 { } /* end */
6509};
6510
Tobin Davis9102cd12006-12-15 10:02:12 +01006511static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6512{
6513 unsigned int gpiostate, gpiomask, gpiodir;
6514
6515 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6516 AC_VERB_GET_GPIO_DATA, 0);
6517
6518 if (!muted)
6519 gpiostate |= (1 << pin);
6520 else
6521 gpiostate &= ~(1 << pin);
6522
6523 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6524 AC_VERB_GET_GPIO_MASK, 0);
6525 gpiomask |= (1 << pin);
6526
6527 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6528 AC_VERB_GET_GPIO_DIRECTION, 0);
6529 gpiodir |= (1 << pin);
6530
6531
6532 snd_hda_codec_write(codec, codec->afg, 0,
6533 AC_VERB_SET_GPIO_MASK, gpiomask);
6534 snd_hda_codec_write(codec, codec->afg, 0,
6535 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6536
6537 msleep(1);
6538
6539 snd_hda_codec_write(codec, codec->afg, 0,
6540 AC_VERB_SET_GPIO_DATA, gpiostate);
6541}
6542
Takashi Iwai7debbe52007-08-16 15:01:03 +02006543/* set up GPIO at initialization */
6544static void alc885_macpro_init_hook(struct hda_codec *codec)
6545{
6546 alc882_gpio_mute(codec, 0, 0);
6547 alc882_gpio_mute(codec, 1, 0);
6548}
6549
6550/* set up GPIO and update auto-muting at initialization */
6551static void alc885_imac24_init_hook(struct hda_codec *codec)
6552{
6553 alc885_macpro_init_hook(codec);
6554 alc885_imac24_automute(codec);
6555}
6556
Kailang Yangdf694da2005-12-05 19:42:22 +01006557/*
6558 * generic initialization of ADC, input mixers and output mixers
6559 */
6560static struct hda_verb alc882_auto_init_verbs[] = {
6561 /*
6562 * Unmute ADC0-2 and set the default input to mic-in
6563 */
6564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6567 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6569 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6570
Takashi Iwaicb53c622007-08-10 17:21:45 +02006571 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006572 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006573 * Note: PASD motherboards uses the Line In 2 as the input for
6574 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006575 */
6576 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006582
6583 /*
6584 * Set up output mixers (0x0c - 0x0f)
6585 */
6586 /* set vol=0 to output mixers */
6587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6591 /* set up input amps for analog loopback */
6592 /* Amp Indices: DAC = 0, mixer = 1 */
6593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6600 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6601 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6603
6604 /* FIXME: use matrix-type input source selection */
6605 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6606 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6611 /* Input mixer2 */
6612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6615 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6616 /* Input mixer3 */
6617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6621
6622 { }
6623};
6624
Takashi Iwaicb53c622007-08-10 17:21:45 +02006625#ifdef CONFIG_SND_HDA_POWER_SAVE
6626#define alc882_loopbacks alc880_loopbacks
6627#endif
6628
Kailang Yangdf694da2005-12-05 19:42:22 +01006629/* pcm configuration: identiacal with ALC880 */
6630#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6631#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6632#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6633#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6634
6635/*
6636 * configuration and preset
6637 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006638static const char *alc882_models[ALC882_MODEL_LAST] = {
6639 [ALC882_3ST_DIG] = "3stack-dig",
6640 [ALC882_6ST_DIG] = "6stack-dig",
6641 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006642 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006643 [ALC882_TARGA] = "targa",
6644 [ALC882_ASUS_A7J] = "asus-a7j",
6645 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006646 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006647 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006648 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006649 [ALC882_AUTO] = "auto",
6650};
6651
6652static struct snd_pci_quirk alc882_cfg_tbl[] = {
6653 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006654 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006655 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006656 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006657 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006658 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006659 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006660 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006661 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006662 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6663 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6664 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006665 {}
6666};
6667
6668static struct alc_config_preset alc882_presets[] = {
6669 [ALC882_3ST_DIG] = {
6670 .mixers = { alc882_base_mixer },
6671 .init_verbs = { alc882_init_verbs },
6672 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6673 .dac_nids = alc882_dac_nids,
6674 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006675 .dig_in_nid = ALC882_DIGIN_NID,
6676 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6677 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006678 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006679 .input_mux = &alc882_capture_source,
6680 },
6681 [ALC882_6ST_DIG] = {
6682 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6683 .init_verbs = { alc882_init_verbs },
6684 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6685 .dac_nids = alc882_dac_nids,
6686 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006687 .dig_in_nid = ALC882_DIGIN_NID,
6688 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6689 .channel_mode = alc882_sixstack_modes,
6690 .input_mux = &alc882_capture_source,
6691 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006692 [ALC882_ARIMA] = {
6693 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6694 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6695 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6696 .dac_nids = alc882_dac_nids,
6697 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6698 .channel_mode = alc882_sixstack_modes,
6699 .input_mux = &alc882_capture_source,
6700 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006701 [ALC882_W2JC] = {
6702 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6703 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6704 alc880_gpio1_init_verbs },
6705 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6706 .dac_nids = alc882_dac_nids,
6707 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6708 .channel_mode = alc880_threestack_modes,
6709 .need_dac_fix = 1,
6710 .input_mux = &alc882_capture_source,
6711 .dig_out_nid = ALC882_DIGOUT_NID,
6712 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006713 [ALC885_MBP3] = {
6714 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6715 .init_verbs = { alc885_mbp3_init_verbs,
6716 alc880_gpio1_init_verbs },
6717 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6718 .dac_nids = alc882_dac_nids,
6719 .channel_mode = alc885_mbp_6ch_modes,
6720 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6721 .input_mux = &alc882_capture_source,
6722 .dig_out_nid = ALC882_DIGOUT_NID,
6723 .dig_in_nid = ALC882_DIGIN_NID,
6724 .unsol_event = alc885_mbp3_unsol_event,
6725 .init_hook = alc885_mbp3_automute,
6726 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006727 [ALC885_MACPRO] = {
6728 .mixers = { alc882_macpro_mixer },
6729 .init_verbs = { alc882_macpro_init_verbs },
6730 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6731 .dac_nids = alc882_dac_nids,
6732 .dig_out_nid = ALC882_DIGOUT_NID,
6733 .dig_in_nid = ALC882_DIGIN_NID,
6734 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6735 .channel_mode = alc882_ch_modes,
6736 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006737 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006738 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006739 [ALC885_IMAC24] = {
6740 .mixers = { alc885_imac24_mixer },
6741 .init_verbs = { alc885_imac24_init_verbs },
6742 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6743 .dac_nids = alc882_dac_nids,
6744 .dig_out_nid = ALC882_DIGOUT_NID,
6745 .dig_in_nid = ALC882_DIGIN_NID,
6746 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6747 .channel_mode = alc882_ch_modes,
6748 .input_mux = &alc882_capture_source,
6749 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006750 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006751 },
Kailang Yang272a5272007-05-14 11:00:38 +02006752 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006753 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006754 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6755 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6756 .dac_nids = alc882_dac_nids,
6757 .dig_out_nid = ALC882_DIGOUT_NID,
6758 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6759 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006760 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006761 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6762 .channel_mode = alc882_3ST_6ch_modes,
6763 .need_dac_fix = 1,
6764 .input_mux = &alc882_capture_source,
6765 .unsol_event = alc882_targa_unsol_event,
6766 .init_hook = alc882_targa_automute,
6767 },
6768 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006769 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006770 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6771 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6772 .dac_nids = alc882_dac_nids,
6773 .dig_out_nid = ALC882_DIGOUT_NID,
6774 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6775 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006776 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006777 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6778 .channel_mode = alc882_3ST_6ch_modes,
6779 .need_dac_fix = 1,
6780 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006781 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006782 [ALC882_ASUS_A7M] = {
6783 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6784 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6785 alc880_gpio1_init_verbs,
6786 alc882_asus_a7m_verbs },
6787 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6788 .dac_nids = alc882_dac_nids,
6789 .dig_out_nid = ALC882_DIGOUT_NID,
6790 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6791 .channel_mode = alc880_threestack_modes,
6792 .need_dac_fix = 1,
6793 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006794 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006795};
6796
6797
6798/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006799 * Pin config fixes
6800 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006801enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006802 PINFIX_ABIT_AW9D_MAX
6803};
6804
6805static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6806 { 0x15, 0x01080104 }, /* side */
6807 { 0x16, 0x01011012 }, /* rear */
6808 { 0x17, 0x01016011 }, /* clfe */
6809 { }
6810};
6811
6812static const struct alc_pincfg *alc882_pin_fixes[] = {
6813 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6814};
6815
6816static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6817 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6818 {}
6819};
6820
6821/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006822 * BIOS auto configuration
6823 */
6824static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6825 hda_nid_t nid, int pin_type,
6826 int dac_idx)
6827{
6828 /* set as output */
6829 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006830 int idx;
6831
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006832 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006833 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6834 idx = 4;
6835 else
6836 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006837 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6838
6839}
6840
6841static void alc882_auto_init_multi_out(struct hda_codec *codec)
6842{
6843 struct alc_spec *spec = codec->spec;
6844 int i;
6845
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006846 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006847 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006848 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006849 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006850 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006851 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006852 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006853 }
6854}
6855
6856static void alc882_auto_init_hp_out(struct hda_codec *codec)
6857{
6858 struct alc_spec *spec = codec->spec;
6859 hda_nid_t pin;
6860
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006861 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006862 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006863 /* use dac 0 */
6864 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006865 pin = spec->autocfg.speaker_pins[0];
6866 if (pin)
6867 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006868}
6869
6870#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6871#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6872
6873static void alc882_auto_init_analog_input(struct hda_codec *codec)
6874{
6875 struct alc_spec *spec = codec->spec;
6876 int i;
6877
6878 for (i = 0; i < AUTO_PIN_LAST; i++) {
6879 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006880 unsigned int vref;
6881 if (!nid)
6882 continue;
6883 vref = PIN_IN;
6884 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006885 unsigned int pincap;
6886 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6887 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006888 AC_PINCAP_VREF_80)
6889 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006890 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006891 snd_hda_codec_write(codec, nid, 0,
6892 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6893 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6894 snd_hda_codec_write(codec, nid, 0,
6895 AC_VERB_SET_AMP_GAIN_MUTE,
6896 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006897 }
6898}
6899
Takashi Iwaif511b012008-08-15 16:46:42 +02006900static void alc882_auto_init_input_src(struct hda_codec *codec)
6901{
6902 struct alc_spec *spec = codec->spec;
6903 const struct hda_input_mux *imux = spec->input_mux;
6904 int c;
6905
6906 for (c = 0; c < spec->num_adc_nids; c++) {
6907 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6908 hda_nid_t nid = spec->capsrc_nids[c];
6909 int conns, mute, idx, item;
6910
6911 conns = snd_hda_get_connections(codec, nid, conn_list,
6912 ARRAY_SIZE(conn_list));
6913 if (conns < 0)
6914 continue;
6915 for (idx = 0; idx < conns; idx++) {
6916 /* if the current connection is the selected one,
6917 * unmute it as default - otherwise mute it
6918 */
6919 mute = AMP_IN_MUTE(idx);
6920 for (item = 0; item < imux->num_items; item++) {
6921 if (imux->items[item].index == idx) {
6922 if (spec->cur_mux[c] == item)
6923 mute = AMP_IN_UNMUTE(idx);
6924 break;
6925 }
6926 }
6927 snd_hda_codec_write(codec, nid, 0,
6928 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6929 }
6930 }
6931}
6932
Takashi Iwai776e1842007-08-29 15:07:11 +02006933/* add mic boosts if needed */
6934static int alc_auto_add_mic_boost(struct hda_codec *codec)
6935{
6936 struct alc_spec *spec = codec->spec;
6937 int err;
6938 hda_nid_t nid;
6939
6940 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006941 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006942 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6943 "Mic Boost",
6944 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6945 if (err < 0)
6946 return err;
6947 }
6948 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006949 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006950 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6951 "Front Mic Boost",
6952 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6953 if (err < 0)
6954 return err;
6955 }
6956 return 0;
6957}
6958
Kailang Yangdf694da2005-12-05 19:42:22 +01006959/* almost identical with ALC880 parser... */
6960static int alc882_parse_auto_config(struct hda_codec *codec)
6961{
6962 struct alc_spec *spec = codec->spec;
6963 int err = alc880_parse_auto_config(codec);
6964
6965 if (err < 0)
6966 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006967 else if (!err)
6968 return 0; /* no config found */
6969
6970 err = alc_auto_add_mic_boost(codec);
6971 if (err < 0)
6972 return err;
6973
6974 /* hack - override the init verbs */
6975 spec->init_verbs[0] = alc882_auto_init_verbs;
6976
6977 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006978}
6979
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006980/* additional initialization for auto-configuration model */
6981static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006982{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006983 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006984 alc882_auto_init_multi_out(codec);
6985 alc882_auto_init_hp_out(codec);
6986 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006987 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006988 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006989 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006990}
6991
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006992static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6993
Linus Torvalds1da177e2005-04-16 15:20:36 -07006994static int patch_alc882(struct hda_codec *codec)
6995{
6996 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006998
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006999 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007000 if (spec == NULL)
7001 return -ENOMEM;
7002
Linus Torvalds1da177e2005-04-16 15:20:36 -07007003 codec->spec = spec;
7004
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007005 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7006 alc882_models,
7007 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007008
Kailang Yangdf694da2005-12-05 19:42:22 +01007009 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007010 /* Pick up systems that don't supply PCI SSID */
7011 switch (codec->subsystem_id) {
7012 case 0x106b0c00: /* Mac Pro */
7013 board_config = ALC885_MACPRO;
7014 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007015 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007016 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007017 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007018 board_config = ALC885_IMAC24;
7019 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007020 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007021 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007022 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007023 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007024 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007025 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007026 board_config = ALC885_MBP3;
7027 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007028 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007029 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007030 if (codec->revision_id == 0x100101 ||
7031 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007032 alc_free(codec);
7033 return patch_alc883(codec);
7034 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007035 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7036 "trying auto-probe from BIOS...\n");
7037 board_config = ALC882_AUTO;
7038 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007039 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007040
Takashi Iwaif95474e2007-07-10 00:47:43 +02007041 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7042
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 if (board_config == ALC882_AUTO) {
7044 /* automatic parse from the BIOS config */
7045 err = alc882_parse_auto_config(codec);
7046 if (err < 0) {
7047 alc_free(codec);
7048 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007049 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007050 printk(KERN_INFO
7051 "hda_codec: Cannot set up configuration "
7052 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007053 board_config = ALC882_3ST_DIG;
7054 }
7055 }
7056
7057 if (board_config != ALC882_AUTO)
7058 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007059
Kailang Yang2f893282008-05-27 12:14:47 +02007060 if (codec->vendor_id == 0x10ec0885) {
7061 spec->stream_name_analog = "ALC885 Analog";
7062 spec->stream_name_digital = "ALC885 Digital";
7063 } else {
7064 spec->stream_name_analog = "ALC882 Analog";
7065 spec->stream_name_digital = "ALC882 Digital";
7066 }
7067
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7069 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007070 /* FIXME: setup DAC5 */
7071 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7072 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007073
Kailang Yangdf694da2005-12-05 19:42:22 +01007074 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7075 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007076
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007077 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007078 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007079 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007080 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007081 /* get type */
7082 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007083 if (wcap != AC_WID_AUD_IN) {
7084 spec->adc_nids = alc882_adc_nids_alt;
7085 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007086 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 } else {
7088 spec->adc_nids = alc882_adc_nids;
7089 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007090 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007091 }
7092 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007093 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007094
Takashi Iwai2134ea42008-01-10 16:53:55 +01007095 spec->vmaster_nid = 0x0c;
7096
Linus Torvalds1da177e2005-04-16 15:20:36 -07007097 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007098 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007099 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007100#ifdef CONFIG_SND_HDA_POWER_SAVE
7101 if (!spec->loopback.amplist)
7102 spec->loopback.amplist = alc882_loopbacks;
7103#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007104 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007105
7106 return 0;
7107}
7108
7109/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007110 * ALC883 support
7111 *
7112 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7113 * configuration. Each pin widget can choose any input DACs and a mixer.
7114 * Each ADC is connected from a mixer of all inputs. This makes possible
7115 * 6-channel independent captures.
7116 *
7117 * In addition, an independent DAC for the multi-playback (not used in this
7118 * driver yet).
7119 */
7120#define ALC883_DIGOUT_NID 0x06
7121#define ALC883_DIGIN_NID 0x0a
7122
Wu Fengguang3ab90932008-11-17 09:51:09 +01007123#define ALC1200_DIGOUT_NID 0x10
7124
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007125static hda_nid_t alc883_dac_nids[4] = {
7126 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007127 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007128};
7129
7130static hda_nid_t alc883_adc_nids[2] = {
7131 /* ADC1-2 */
7132 0x08, 0x09,
7133};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007134
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007135static hda_nid_t alc883_adc_nids_alt[1] = {
7136 /* ADC1 */
7137 0x08,
7138};
7139
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007140static hda_nid_t alc883_adc_nids_rev[2] = {
7141 /* ADC2-1 */
7142 0x09, 0x08
7143};
7144
Takashi Iwaie1406342008-02-11 18:32:32 +01007145static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7146
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007147static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7148
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007149/* input MUX */
7150/* FIXME: should be a matrix-type input source selection */
7151
7152static struct hda_input_mux alc883_capture_source = {
7153 .num_items = 4,
7154 .items = {
7155 { "Mic", 0x0 },
7156 { "Front Mic", 0x1 },
7157 { "Line", 0x2 },
7158 { "CD", 0x4 },
7159 },
7160};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007161
Jiang zhe17bba1b2008-06-04 12:11:07 +02007162static struct hda_input_mux alc883_3stack_6ch_intel = {
7163 .num_items = 4,
7164 .items = {
7165 { "Mic", 0x1 },
7166 { "Front Mic", 0x0 },
7167 { "Line", 0x2 },
7168 { "CD", 0x4 },
7169 },
7170};
7171
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007172static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7173 .num_items = 2,
7174 .items = {
7175 { "Mic", 0x1 },
7176 { "Line", 0x2 },
7177 },
7178};
7179
Kailang Yang272a5272007-05-14 11:00:38 +02007180static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7181 .num_items = 4,
7182 .items = {
7183 { "Mic", 0x0 },
7184 { "iMic", 0x1 },
7185 { "Line", 0x2 },
7186 { "CD", 0x4 },
7187 },
7188};
7189
Jiang zhefb97dc62008-03-06 11:07:11 +01007190static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7191 .num_items = 2,
7192 .items = {
7193 { "Mic", 0x0 },
7194 { "Int Mic", 0x1 },
7195 },
7196};
7197
Kailang Yange2757d52008-08-26 13:17:46 +02007198static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7199 .num_items = 3,
7200 .items = {
7201 { "Mic", 0x0 },
7202 { "Front Mic", 0x1 },
7203 { "Line", 0x4 },
7204 },
7205};
7206
7207static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7208 .num_items = 2,
7209 .items = {
7210 { "Mic", 0x0 },
7211 { "Line", 0x2 },
7212 },
7213};
7214
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007215/*
7216 * 2ch mode
7217 */
7218static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7219 { 2, NULL }
7220};
7221
7222/*
7223 * 2ch mode
7224 */
7225static struct hda_verb alc883_3ST_ch2_init[] = {
7226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7228 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7229 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7230 { } /* end */
7231};
7232
7233/*
Tobin Davisb2011312007-09-17 12:45:11 +02007234 * 4ch mode
7235 */
7236static struct hda_verb alc883_3ST_ch4_init[] = {
7237 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7238 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7239 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7240 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7241 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7242 { } /* end */
7243};
7244
7245/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007246 * 6ch mode
7247 */
7248static struct hda_verb alc883_3ST_ch6_init[] = {
7249 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7250 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7251 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7252 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7253 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7254 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7255 { } /* end */
7256};
7257
Tobin Davisb2011312007-09-17 12:45:11 +02007258static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007259 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007260 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007261 { 6, alc883_3ST_ch6_init },
7262};
7263
7264/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007265 * 2ch mode
7266 */
7267static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7268 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7269 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7270 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7271 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7272 { } /* end */
7273};
7274
7275/*
7276 * 4ch mode
7277 */
7278static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7279 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7280 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7281 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7282 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7283 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7284 { } /* end */
7285};
7286
7287/*
7288 * 6ch mode
7289 */
7290static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7291 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7292 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7293 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7296 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7297 { } /* end */
7298};
7299
7300static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7301 { 2, alc883_3ST_ch2_intel_init },
7302 { 4, alc883_3ST_ch4_intel_init },
7303 { 6, alc883_3ST_ch6_intel_init },
7304};
7305
7306/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007307 * 6ch mode
7308 */
7309static struct hda_verb alc883_sixstack_ch6_init[] = {
7310 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7311 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7312 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7313 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7314 { } /* end */
7315};
7316
7317/*
7318 * 8ch mode
7319 */
7320static struct hda_verb alc883_sixstack_ch8_init[] = {
7321 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7322 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7323 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7324 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7325 { } /* end */
7326};
7327
7328static struct hda_channel_mode alc883_sixstack_modes[2] = {
7329 { 6, alc883_sixstack_ch6_init },
7330 { 8, alc883_sixstack_ch8_init },
7331};
7332
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007333static struct hda_verb alc883_medion_eapd_verbs[] = {
7334 /* eanable EAPD on medion laptop */
7335 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7336 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7337 { }
7338};
7339
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007340/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7341 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7342 */
7343
7344static struct snd_kcontrol_new alc883_base_mixer[] = {
7345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7348 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7349 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7350 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7351 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7352 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7354 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7363 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007365 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7366 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7367 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007368 { } /* end */
7369};
7370
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007371static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7373 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7380 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7383 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007385 { } /* end */
7386};
7387
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007388static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007389 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7390 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7391 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7392 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7396 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7397 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7398 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007399 { } /* end */
7400};
7401
Jiang zhefb97dc62008-03-06 11:07:11 +01007402static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7403 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7404 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7405 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7406 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7410 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7411 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7412 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007413 { } /* end */
7414};
7415
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007416static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7419 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007428 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007432 { } /* end */
7433};
7434
7435static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7437 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7438 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7439 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7440 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7441 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7442 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7443 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007450 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007453 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7455 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7456 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007457 { } /* end */
7458};
7459
Jiang zhe17bba1b2008-06-04 12:11:07 +02007460static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7461 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7462 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7463 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7464 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7465 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7466 HDA_OUTPUT),
7467 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7468 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7469 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7471 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7472 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7473 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7474 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7478 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7480 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7481 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7482 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007483 { } /* end */
7484};
7485
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007486static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007487 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007488 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007489 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007490 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007491 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7492 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007493 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7494 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7499 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007501 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007504 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7506 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7507 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007508 { } /* end */
7509};
7510
Kailang Yangccc656c2006-10-17 12:32:26 +02007511static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7512 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7514 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7515 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7516 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7517 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7518 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7519 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7520 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7523 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7524 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007526 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007528 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007529};
Kailang Yangccc656c2006-10-17 12:32:26 +02007530
7531static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7533 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7534 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7535 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7536 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007540 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7541 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7542 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007543 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007544};
Kailang Yangccc656c2006-10-17 12:32:26 +02007545
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007546static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7547 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007549 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7550 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7553 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7554 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007555 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007556};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007557
Kailang Yang272a5272007-05-14 11:00:38 +02007558static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7559 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7560 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7566 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7567 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007568 { } /* end */
7569};
7570
7571static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7574 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007581 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007582};
Kailang Yang272a5272007-05-14 11:00:38 +02007583
Tobin Davis2880a862007-08-07 11:50:26 +02007584static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007585 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7586 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007593 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007594};
Tobin Davis2880a862007-08-07 11:50:26 +02007595
Kailang Yange2757d52008-08-26 13:17:46 +02007596static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7598 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7599 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7600 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7601 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7602 0x0d, 1, 0x0, HDA_OUTPUT),
7603 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7604 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7605 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7606 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7607 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7608 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7609 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7615 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7617 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7618 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007620 { } /* end */
7621};
7622
7623static struct hda_bind_ctls alc883_bind_cap_vol = {
7624 .ops = &snd_hda_bind_vol,
7625 .values = {
7626 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7627 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7628 0
7629 },
7630};
7631
7632static struct hda_bind_ctls alc883_bind_cap_switch = {
7633 .ops = &snd_hda_bind_sw,
7634 .values = {
7635 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7636 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7637 0
7638 },
7639};
7640
7641static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7648 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007650 { } /* end */
7651};
7652
7653static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007654 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7655 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7656 {
7657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7658 /* .name = "Capture Source", */
7659 .name = "Input Source",
7660 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007661 .info = alc_mux_enum_info,
7662 .get = alc_mux_enum_get,
7663 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007664 },
7665 { } /* end */
7666};
7667
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007668static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7669 {
7670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7671 .name = "Channel Mode",
7672 .info = alc_ch_mode_info,
7673 .get = alc_ch_mode_get,
7674 .put = alc_ch_mode_put,
7675 },
7676 { } /* end */
7677};
7678
7679static struct hda_verb alc883_init_verbs[] = {
7680 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 /* ADC2: mute amp left and right */
7684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7686 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7690 /* Rear mixer */
7691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7692 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7693 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7694 /* CLFE mixer */
7695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7698 /* Side mixer */
7699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7700 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7701 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7702
Takashi Iwaicb53c622007-08-10 17:21:45 +02007703 /* mute analog input loopbacks */
7704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007709
7710 /* Front Pin: output 0 (0x0c) */
7711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7713 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 /* Rear Pin: output 1 (0x0d) */
7715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7717 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7718 /* CLFE Pin: output 2 (0x0e) */
7719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7720 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7721 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7722 /* Side Pin: output 3 (0x0f) */
7723 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7725 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7726 /* Mic (rear) pin: input vref at 80% */
7727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7729 /* Front Mic pin: input vref at 80% */
7730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7732 /* Line In pin: input */
7733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7735 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7739 /* CD pin widget for input */
7740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7741
7742 /* FIXME: use matrix-type input source selection */
7743 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7744 /* Input mixer2 */
7745 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007746 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007749 /* Input mixer3 */
7750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007754 { }
7755};
7756
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007757/* toggle speaker-output according to the hp-jack state */
7758static void alc883_mitac_hp_automute(struct hda_codec *codec)
7759{
7760 unsigned int present;
7761
7762 present = snd_hda_codec_read(codec, 0x15, 0,
7763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7764 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7766 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7767 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7768}
7769
7770/* auto-toggle front mic */
7771/*
7772static void alc883_mitac_mic_automute(struct hda_codec *codec)
7773{
7774 unsigned int present;
7775 unsigned char bits;
7776
7777 present = snd_hda_codec_read(codec, 0x18, 0,
7778 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7779 bits = present ? HDA_AMP_MUTE : 0;
7780 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7781}
7782*/
7783
7784static void alc883_mitac_automute(struct hda_codec *codec)
7785{
7786 alc883_mitac_hp_automute(codec);
7787 /* alc883_mitac_mic_automute(codec); */
7788}
7789
7790static void alc883_mitac_unsol_event(struct hda_codec *codec,
7791 unsigned int res)
7792{
7793 switch (res >> 26) {
7794 case ALC880_HP_EVENT:
7795 alc883_mitac_hp_automute(codec);
7796 break;
7797 case ALC880_MIC_EVENT:
7798 /* alc883_mitac_mic_automute(codec); */
7799 break;
7800 }
7801}
7802
7803static struct hda_verb alc883_mitac_verbs[] = {
7804 /* HP */
7805 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7807 /* Subwoofer */
7808 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7809 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7810
7811 /* enable unsolicited event */
7812 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7813 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7814
7815 { } /* end */
7816};
7817
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007818static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007819 /* HP */
7820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7822 /* Int speaker */
7823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7825
7826 /* enable unsolicited event */
7827 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007828 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007829
7830 { } /* end */
7831};
7832
Jiang zhefb97dc62008-03-06 11:07:11 +01007833static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7834 /* HP */
7835 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7837 /* Subwoofer */
7838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7840
7841 /* enable unsolicited event */
7842 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7843
7844 { } /* end */
7845};
7846
Kailang Yangccc656c2006-10-17 12:32:26 +02007847static struct hda_verb alc883_tagra_verbs[] = {
7848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7850
7851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007853
Kailang Yangccc656c2006-10-17 12:32:26 +02007854 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7855 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7856 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7857
7858 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007859 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7860 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7861 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007862
7863 { } /* end */
7864};
7865
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007866static struct hda_verb alc883_lenovo_101e_verbs[] = {
7867 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7868 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7869 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7870 { } /* end */
7871};
7872
Kailang Yang272a5272007-05-14 11:00:38 +02007873static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7874 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7878 { } /* end */
7879};
7880
7881static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7884 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7885 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7887 { } /* end */
7888};
7889
Kailang Yang189609a2007-08-20 11:31:23 +02007890static struct hda_verb alc883_haier_w66_verbs[] = {
7891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7893
7894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7895
7896 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7897 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7898 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7899 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7900 { } /* end */
7901};
7902
Kailang Yange2757d52008-08-26 13:17:46 +02007903static struct hda_verb alc888_lenovo_sky_verbs[] = {
7904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7909 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7910 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7911 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7912 { } /* end */
7913};
7914
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007915static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007916 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007917 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7918 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007919 { }
7920};
7921
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007922static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007923 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7924 { }
7925};
7926
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007927static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007928 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7929 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7930 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7931 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7932 { }
7933};
7934
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007935static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007936 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7937 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7939 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7940 { }
7941};
7942
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007943static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7944 { 2, alc888_3st_hp_2ch_init },
7945 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007946};
7947
Kailang Yang272a5272007-05-14 11:00:38 +02007948/* toggle front-jack and RCA according to the hp-jack state */
7949static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7950{
7951 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007952
Kailang Yang272a5272007-05-14 11:00:38 +02007953 present = snd_hda_codec_read(codec, 0x1b, 0,
7954 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007955 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7956 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7957 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7958 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007959}
7960
7961/* toggle RCA according to the front-jack state */
7962static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7963{
7964 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007965
Kailang Yang272a5272007-05-14 11:00:38 +02007966 present = snd_hda_codec_read(codec, 0x14, 0,
7967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007968 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007970}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007971
Kailang Yang272a5272007-05-14 11:00:38 +02007972static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7973 unsigned int res)
7974{
7975 if ((res >> 26) == ALC880_HP_EVENT)
7976 alc888_lenovo_ms7195_front_automute(codec);
7977 if ((res >> 26) == ALC880_FRONT_EVENT)
7978 alc888_lenovo_ms7195_rca_automute(codec);
7979}
7980
7981static struct hda_verb alc883_medion_md2_verbs[] = {
7982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7984
7985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7986
7987 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7988 { } /* end */
7989};
7990
7991/* toggle speaker-output according to the hp-jack state */
7992static void alc883_medion_md2_automute(struct hda_codec *codec)
7993{
7994 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007995
Kailang Yang272a5272007-05-14 11:00:38 +02007996 present = snd_hda_codec_read(codec, 0x14, 0,
7997 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007998 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7999 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008000}
8001
8002static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8003 unsigned int res)
8004{
8005 if ((res >> 26) == ALC880_HP_EVENT)
8006 alc883_medion_md2_automute(codec);
8007}
8008
Kailang Yangccc656c2006-10-17 12:32:26 +02008009/* toggle speaker-output according to the hp-jack state */
8010static void alc883_tagra_automute(struct hda_codec *codec)
8011{
8012 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008013 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008014
8015 present = snd_hda_codec_read(codec, 0x14, 0,
8016 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008017 bits = present ? HDA_AMP_MUTE : 0;
8018 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8019 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008020 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8021 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008022}
8023
8024static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8025{
8026 if ((res >> 26) == ALC880_HP_EVENT)
8027 alc883_tagra_automute(codec);
8028}
8029
Jiang zhe368c7a92008-03-04 11:20:33 +01008030/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008031static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008032{
8033 unsigned int present;
8034 unsigned char bits;
8035
8036 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8037 & AC_PINSENSE_PRESENCE;
8038 bits = present ? HDA_AMP_MUTE : 0;
8039 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8040 HDA_AMP_MUTE, bits);
8041}
8042
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008043static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8044{
8045 unsigned int present;
8046
8047 present = snd_hda_codec_read(codec, 0x18, 0,
8048 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8049 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8050 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8051}
8052
8053static void alc883_clevo_m720_automute(struct hda_codec *codec)
8054{
8055 alc883_clevo_m720_hp_automute(codec);
8056 alc883_clevo_m720_mic_automute(codec);
8057}
8058
8059static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008060 unsigned int res)
8061{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008062 switch (res >> 26) {
8063 case ALC880_HP_EVENT:
8064 alc883_clevo_m720_hp_automute(codec);
8065 break;
8066 case ALC880_MIC_EVENT:
8067 alc883_clevo_m720_mic_automute(codec);
8068 break;
8069 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008070}
8071
Jiang zhefb97dc62008-03-06 11:07:11 +01008072/* toggle speaker-output according to the hp-jack state */
8073static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8074{
8075 unsigned int present;
8076 unsigned char bits;
8077
8078 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8079 & AC_PINSENSE_PRESENCE;
8080 bits = present ? HDA_AMP_MUTE : 0;
8081 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8082 HDA_AMP_MUTE, bits);
8083}
8084
8085static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8086 unsigned int res)
8087{
8088 if ((res >> 26) == ALC880_HP_EVENT)
8089 alc883_2ch_fujitsu_pi2515_automute(codec);
8090}
8091
Kailang Yang189609a2007-08-20 11:31:23 +02008092static void alc883_haier_w66_automute(struct hda_codec *codec)
8093{
8094 unsigned int present;
8095 unsigned char bits;
8096
8097 present = snd_hda_codec_read(codec, 0x1b, 0,
8098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8099 bits = present ? 0x80 : 0;
8100 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8101 0x80, bits);
8102}
8103
8104static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8105 unsigned int res)
8106{
8107 if ((res >> 26) == ALC880_HP_EVENT)
8108 alc883_haier_w66_automute(codec);
8109}
8110
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008111static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8112{
8113 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008114 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008115
8116 present = snd_hda_codec_read(codec, 0x14, 0,
8117 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008118 bits = present ? HDA_AMP_MUTE : 0;
8119 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8120 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008121}
8122
8123static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8124{
8125 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008126 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008127
8128 present = snd_hda_codec_read(codec, 0x1b, 0,
8129 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008130 bits = present ? HDA_AMP_MUTE : 0;
8131 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8132 HDA_AMP_MUTE, bits);
8133 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8134 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008135}
8136
8137static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8138 unsigned int res)
8139{
8140 if ((res >> 26) == ALC880_HP_EVENT)
8141 alc883_lenovo_101e_all_automute(codec);
8142 if ((res >> 26) == ALC880_FRONT_EVENT)
8143 alc883_lenovo_101e_ispeaker_automute(codec);
8144}
8145
Takashi Iwai676a9b52007-08-16 15:23:35 +02008146/* toggle speaker-output according to the hp-jack state */
8147static void alc883_acer_aspire_automute(struct hda_codec *codec)
8148{
8149 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008150
Takashi Iwai676a9b52007-08-16 15:23:35 +02008151 present = snd_hda_codec_read(codec, 0x14, 0,
8152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8153 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8154 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8155 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8156 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8157}
8158
8159static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8160 unsigned int res)
8161{
8162 if ((res >> 26) == ALC880_HP_EVENT)
8163 alc883_acer_aspire_automute(codec);
8164}
8165
Kailang Yangd1a991a2007-08-15 16:21:59 +02008166static struct hda_verb alc883_acer_eapd_verbs[] = {
8167 /* HP Pin: output 0 (0x0c) */
8168 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8170 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8171 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8173 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008174 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008175 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8176 /* eanable EAPD on medion laptop */
8177 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8178 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008179 /* enable unsolicited event */
8180 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008181 { }
8182};
8183
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008184static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8185{
8186 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008187
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008188 present = snd_hda_codec_read(codec, 0x1b, 0,
8189 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8190 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8191 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8192 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8193 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8194 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8195 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8196 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8197 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8198}
8199
8200static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8201 unsigned int res)
8202{
8203 switch (res >> 26) {
8204 case ALC880_HP_EVENT:
8205 printk("hp_event\n");
8206 alc888_6st_dell_front_automute(codec);
8207 break;
8208 }
8209}
8210
Kailang Yange2757d52008-08-26 13:17:46 +02008211static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8212{
8213 unsigned int mute;
8214 unsigned int present;
8215
8216 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8217 present = snd_hda_codec_read(codec, 0x1b, 0,
8218 AC_VERB_GET_PIN_SENSE, 0);
8219 present = (present & 0x80000000) != 0;
8220 if (present) {
8221 /* mute internal speaker */
8222 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8223 HDA_AMP_MUTE, HDA_AMP_MUTE);
8224 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8225 HDA_AMP_MUTE, HDA_AMP_MUTE);
8226 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8227 HDA_AMP_MUTE, HDA_AMP_MUTE);
8228 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8229 HDA_AMP_MUTE, HDA_AMP_MUTE);
8230 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8231 HDA_AMP_MUTE, HDA_AMP_MUTE);
8232 } else {
8233 /* unmute internal speaker if necessary */
8234 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8235 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8236 HDA_AMP_MUTE, mute);
8237 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8238 HDA_AMP_MUTE, mute);
8239 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8240 HDA_AMP_MUTE, mute);
8241 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8242 HDA_AMP_MUTE, mute);
8243 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8244 HDA_AMP_MUTE, mute);
8245 }
8246}
8247
8248static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8249 unsigned int res)
8250{
8251 if ((res >> 26) == ALC880_HP_EVENT)
8252 alc888_lenovo_sky_front_automute(codec);
8253}
8254
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008255/*
8256 * generic initialization of ADC, input mixers and output mixers
8257 */
8258static struct hda_verb alc883_auto_init_verbs[] = {
8259 /*
8260 * Unmute ADC0-2 and set the default input to mic-in
8261 */
8262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8264 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8266
Takashi Iwaicb53c622007-08-10 17:21:45 +02008267 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008268 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008269 * Note: PASD motherboards uses the Line In 2 as the input for
8270 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008271 */
8272 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008278
8279 /*
8280 * Set up output mixers (0x0c - 0x0f)
8281 */
8282 /* set vol=0 to output mixers */
8283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8287 /* set up input amps for analog loopback */
8288 /* Amp Indices: DAC = 0, mixer = 1 */
8289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8297 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8298 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8299
8300 /* FIXME: use matrix-type input source selection */
8301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8302 /* Input mixer1 */
8303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008306 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8308 /* Input mixer2 */
8309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008312 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008314
8315 { }
8316};
8317
Kailang Yange2757d52008-08-26 13:17:46 +02008318static struct hda_verb alc888_asus_m90v_verbs[] = {
8319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8322 /* enable unsolicited event */
8323 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8324 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8325 { } /* end */
8326};
8327
8328static void alc883_nb_mic_automute(struct hda_codec *codec)
8329{
8330 unsigned int present;
8331
8332 present = snd_hda_codec_read(codec, 0x18, 0,
8333 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8334 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8335 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8336 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8337 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8338}
8339
8340static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8341{
8342 unsigned int present;
8343 unsigned char bits;
8344
8345 present = snd_hda_codec_read(codec, 0x1b, 0,
8346 AC_VERB_GET_PIN_SENSE, 0)
8347 & AC_PINSENSE_PRESENCE;
8348 bits = present ? 0 : PIN_OUT;
8349 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8350 bits);
8351 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8352 bits);
8353 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8354 bits);
8355}
8356
8357static void alc883_mode2_unsol_event(struct hda_codec *codec,
8358 unsigned int res)
8359{
8360 switch (res >> 26) {
8361 case ALC880_HP_EVENT:
8362 alc883_M90V_speaker_automute(codec);
8363 break;
8364 case ALC880_MIC_EVENT:
8365 alc883_nb_mic_automute(codec);
8366 break;
8367 }
8368}
8369
8370static void alc883_mode2_inithook(struct hda_codec *codec)
8371{
8372 alc883_M90V_speaker_automute(codec);
8373 alc883_nb_mic_automute(codec);
8374}
8375
8376static struct hda_verb alc888_asus_eee1601_verbs[] = {
8377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8381 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8382 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8383 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8384 /* enable unsolicited event */
8385 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8386 { } /* end */
8387};
8388
8389static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8390{
8391 unsigned int present;
8392 unsigned char bits;
8393
8394 present = snd_hda_codec_read(codec, 0x14, 0,
8395 AC_VERB_GET_PIN_SENSE, 0)
8396 & AC_PINSENSE_PRESENCE;
8397 bits = present ? 0 : PIN_OUT;
8398 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8399 bits);
8400}
8401
8402static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8403 unsigned int res)
8404{
8405 switch (res >> 26) {
8406 case ALC880_HP_EVENT:
8407 alc883_eee1601_speaker_automute(codec);
8408 break;
8409 }
8410}
8411
8412static void alc883_eee1601_inithook(struct hda_codec *codec)
8413{
8414 alc883_eee1601_speaker_automute(codec);
8415}
8416
Takashi Iwaicb53c622007-08-10 17:21:45 +02008417#ifdef CONFIG_SND_HDA_POWER_SAVE
8418#define alc883_loopbacks alc880_loopbacks
8419#endif
8420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008421/* pcm configuration: identiacal with ALC880 */
8422#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8423#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008424#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008425#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8426#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8427
8428/*
8429 * configuration and preset
8430 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008431static const char *alc883_models[ALC883_MODEL_LAST] = {
8432 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8433 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8434 [ALC883_3ST_6ch] = "3stack-6ch",
8435 [ALC883_6ST_DIG] = "6stack-dig",
8436 [ALC883_TARGA_DIG] = "targa-dig",
8437 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008438 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008439 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008440 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008441 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008442 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008443 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008444 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008445 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8446 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008447 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008448 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008449 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008450 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008451 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008452 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008453 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008454 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008455 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008456 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008457 [ALC883_AUTO] = "auto",
8458};
8459
8460static struct snd_pci_quirk alc883_cfg_tbl[] = {
8461 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008462 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008463 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008464 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8465 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008466 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008467 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8468 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008469 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8470 ALC888_ACER_ASPIRE_4930G),
8471 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8472 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008473 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8474 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008475 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008476 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008477 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008478 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8479 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008480 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008481 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008482 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008483 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008484 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008485 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008486 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008487 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008488 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008489 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008490 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8491 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008492 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008493 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008494 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008495 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8496 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8497 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008498 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008499 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008500 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008501 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8502 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8503 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8504 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8505 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8506 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8507 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8508 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8509 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008510 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8511 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008512 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008513 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008514 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008515 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008516 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008517 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008518 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008519 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8520 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008521 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008522 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008523 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008524 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8525 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008526 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008527 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8528 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008529 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008530 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008531 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8532 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008533 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008534 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008535 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008536 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008537 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008538 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8539 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008540 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008541 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008542 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008543 {}
8544};
8545
8546static struct alc_config_preset alc883_presets[] = {
8547 [ALC883_3ST_2ch_DIG] = {
8548 .mixers = { alc883_3ST_2ch_mixer },
8549 .init_verbs = { alc883_init_verbs },
8550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8551 .dac_nids = alc883_dac_nids,
8552 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008553 .dig_in_nid = ALC883_DIGIN_NID,
8554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8555 .channel_mode = alc883_3ST_2ch_modes,
8556 .input_mux = &alc883_capture_source,
8557 },
8558 [ALC883_3ST_6ch_DIG] = {
8559 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8560 .init_verbs = { alc883_init_verbs },
8561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8562 .dac_nids = alc883_dac_nids,
8563 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008564 .dig_in_nid = ALC883_DIGIN_NID,
8565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8566 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008567 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008568 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008569 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008570 [ALC883_3ST_6ch] = {
8571 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8572 .init_verbs = { alc883_init_verbs },
8573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8574 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8576 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008577 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008578 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008579 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008580 [ALC883_3ST_6ch_INTEL] = {
8581 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8582 .init_verbs = { alc883_init_verbs },
8583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8584 .dac_nids = alc883_dac_nids,
8585 .dig_out_nid = ALC883_DIGOUT_NID,
8586 .dig_in_nid = ALC883_DIGIN_NID,
8587 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8588 .channel_mode = alc883_3ST_6ch_intel_modes,
8589 .need_dac_fix = 1,
8590 .input_mux = &alc883_3stack_6ch_intel,
8591 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008592 [ALC883_6ST_DIG] = {
8593 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8594 .init_verbs = { alc883_init_verbs },
8595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8596 .dac_nids = alc883_dac_nids,
8597 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008598 .dig_in_nid = ALC883_DIGIN_NID,
8599 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8600 .channel_mode = alc883_sixstack_modes,
8601 .input_mux = &alc883_capture_source,
8602 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008603 [ALC883_TARGA_DIG] = {
8604 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8605 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8607 .dac_nids = alc883_dac_nids,
8608 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8610 .channel_mode = alc883_3ST_6ch_modes,
8611 .need_dac_fix = 1,
8612 .input_mux = &alc883_capture_source,
8613 .unsol_event = alc883_tagra_unsol_event,
8614 .init_hook = alc883_tagra_automute,
8615 },
8616 [ALC883_TARGA_2ch_DIG] = {
8617 .mixers = { alc883_tagra_2ch_mixer},
8618 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8620 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008621 .adc_nids = alc883_adc_nids_alt,
8622 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008623 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008624 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8625 .channel_mode = alc883_3ST_2ch_modes,
8626 .input_mux = &alc883_capture_source,
8627 .unsol_event = alc883_tagra_unsol_event,
8628 .init_hook = alc883_tagra_automute,
8629 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008630 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008631 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008632 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8633 * and the headphone jack. Turn this on and rely on the
8634 * standard mute methods whenever the user wants to turn
8635 * these outputs off.
8636 */
8637 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8638 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8639 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008640 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8641 .channel_mode = alc883_3ST_2ch_modes,
8642 .input_mux = &alc883_capture_source,
8643 },
Tobin Davis2880a862007-08-07 11:50:26 +02008644 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008645 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008646 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8648 .dac_nids = alc883_dac_nids,
8649 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008650 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8651 .channel_mode = alc883_3ST_2ch_modes,
8652 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008653 .unsol_event = alc883_acer_aspire_unsol_event,
8654 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008655 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008656 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008657 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008658 alc883_chmode_mixer },
8659 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8660 alc888_acer_aspire_4930g_verbs },
8661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8662 .dac_nids = alc883_dac_nids,
8663 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8664 .adc_nids = alc883_adc_nids_rev,
8665 .capsrc_nids = alc883_capsrc_nids_rev,
8666 .dig_out_nid = ALC883_DIGOUT_NID,
8667 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8668 .channel_mode = alc883_3ST_6ch_modes,
8669 .need_dac_fix = 1,
8670 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008671 ARRAY_SIZE(alc888_2_capture_sources),
8672 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008673 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8674 .init_hook = alc888_acer_aspire_4930g_automute,
8675 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008676 [ALC883_MEDION] = {
8677 .mixers = { alc883_fivestack_mixer,
8678 alc883_chmode_mixer },
8679 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008680 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8682 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008683 .adc_nids = alc883_adc_nids_alt,
8684 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008685 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8686 .channel_mode = alc883_sixstack_modes,
8687 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008688 },
Kailang Yang272a5272007-05-14 11:00:38 +02008689 [ALC883_MEDION_MD2] = {
8690 .mixers = { alc883_medion_md2_mixer},
8691 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8693 .dac_nids = alc883_dac_nids,
8694 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008695 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8696 .channel_mode = alc883_3ST_2ch_modes,
8697 .input_mux = &alc883_capture_source,
8698 .unsol_event = alc883_medion_md2_unsol_event,
8699 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008700 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008701 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008702 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008703 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8704 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8705 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008706 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8707 .channel_mode = alc883_3ST_2ch_modes,
8708 .input_mux = &alc883_capture_source,
8709 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008710 [ALC883_CLEVO_M720] = {
8711 .mixers = { alc883_clevo_m720_mixer },
8712 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8714 .dac_nids = alc883_dac_nids,
8715 .dig_out_nid = ALC883_DIGOUT_NID,
8716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8717 .channel_mode = alc883_3ST_2ch_modes,
8718 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008719 .unsol_event = alc883_clevo_m720_unsol_event,
8720 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008721 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008722 [ALC883_LENOVO_101E_2ch] = {
8723 .mixers = { alc883_lenovo_101e_2ch_mixer},
8724 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8725 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8726 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008727 .adc_nids = alc883_adc_nids_alt,
8728 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008729 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8730 .channel_mode = alc883_3ST_2ch_modes,
8731 .input_mux = &alc883_lenovo_101e_capture_source,
8732 .unsol_event = alc883_lenovo_101e_unsol_event,
8733 .init_hook = alc883_lenovo_101e_all_automute,
8734 },
Kailang Yang272a5272007-05-14 11:00:38 +02008735 [ALC883_LENOVO_NB0763] = {
8736 .mixers = { alc883_lenovo_nb0763_mixer },
8737 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8738 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8739 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8741 .channel_mode = alc883_3ST_2ch_modes,
8742 .need_dac_fix = 1,
8743 .input_mux = &alc883_lenovo_nb0763_capture_source,
8744 .unsol_event = alc883_medion_md2_unsol_event,
8745 .init_hook = alc883_medion_md2_automute,
8746 },
8747 [ALC888_LENOVO_MS7195_DIG] = {
8748 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8749 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8750 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8751 .dac_nids = alc883_dac_nids,
8752 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008753 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8754 .channel_mode = alc883_3ST_6ch_modes,
8755 .need_dac_fix = 1,
8756 .input_mux = &alc883_capture_source,
8757 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8758 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008759 },
8760 [ALC883_HAIER_W66] = {
8761 .mixers = { alc883_tagra_2ch_mixer},
8762 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8763 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8764 .dac_nids = alc883_dac_nids,
8765 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008766 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8767 .channel_mode = alc883_3ST_2ch_modes,
8768 .input_mux = &alc883_capture_source,
8769 .unsol_event = alc883_haier_w66_unsol_event,
8770 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008771 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008772 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008773 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008774 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008775 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8776 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008777 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8778 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008779 .need_dac_fix = 1,
8780 .input_mux = &alc883_capture_source,
8781 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008782 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008783 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008784 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8786 .dac_nids = alc883_dac_nids,
8787 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008788 .dig_in_nid = ALC883_DIGIN_NID,
8789 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8790 .channel_mode = alc883_sixstack_modes,
8791 .input_mux = &alc883_capture_source,
8792 .unsol_event = alc888_6st_dell_unsol_event,
8793 .init_hook = alc888_6st_dell_front_automute,
8794 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008795 [ALC883_MITAC] = {
8796 .mixers = { alc883_mitac_mixer },
8797 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8798 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8799 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8801 .channel_mode = alc883_3ST_2ch_modes,
8802 .input_mux = &alc883_capture_source,
8803 .unsol_event = alc883_mitac_unsol_event,
8804 .init_hook = alc883_mitac_automute,
8805 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008806 [ALC883_FUJITSU_PI2515] = {
8807 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8808 .init_verbs = { alc883_init_verbs,
8809 alc883_2ch_fujitsu_pi2515_verbs},
8810 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8811 .dac_nids = alc883_dac_nids,
8812 .dig_out_nid = ALC883_DIGOUT_NID,
8813 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8814 .channel_mode = alc883_3ST_2ch_modes,
8815 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8816 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8817 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8818 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008819 [ALC888_FUJITSU_XA3530] = {
8820 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8821 .init_verbs = { alc883_init_verbs,
8822 alc888_fujitsu_xa3530_verbs },
8823 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8824 .dac_nids = alc883_dac_nids,
8825 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8826 .adc_nids = alc883_adc_nids_rev,
8827 .capsrc_nids = alc883_capsrc_nids_rev,
8828 .dig_out_nid = ALC883_DIGOUT_NID,
8829 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8830 .channel_mode = alc888_4ST_8ch_intel_modes,
8831 .num_mux_defs =
8832 ARRAY_SIZE(alc888_2_capture_sources),
8833 .input_mux = alc888_2_capture_sources,
8834 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8835 .init_hook = alc888_fujitsu_xa3530_automute,
8836 },
Kailang Yange2757d52008-08-26 13:17:46 +02008837 [ALC888_LENOVO_SKY] = {
8838 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8839 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8840 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8841 .dac_nids = alc883_dac_nids,
8842 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008843 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8844 .channel_mode = alc883_sixstack_modes,
8845 .need_dac_fix = 1,
8846 .input_mux = &alc883_lenovo_sky_capture_source,
8847 .unsol_event = alc883_lenovo_sky_unsol_event,
8848 .init_hook = alc888_lenovo_sky_front_automute,
8849 },
8850 [ALC888_ASUS_M90V] = {
8851 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8852 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8853 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8854 .dac_nids = alc883_dac_nids,
8855 .dig_out_nid = ALC883_DIGOUT_NID,
8856 .dig_in_nid = ALC883_DIGIN_NID,
8857 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8858 .channel_mode = alc883_3ST_6ch_modes,
8859 .need_dac_fix = 1,
8860 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8861 .unsol_event = alc883_mode2_unsol_event,
8862 .init_hook = alc883_mode2_inithook,
8863 },
8864 [ALC888_ASUS_EEE1601] = {
8865 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008866 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008867 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8868 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8869 .dac_nids = alc883_dac_nids,
8870 .dig_out_nid = ALC883_DIGOUT_NID,
8871 .dig_in_nid = ALC883_DIGIN_NID,
8872 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8873 .channel_mode = alc883_3ST_2ch_modes,
8874 .need_dac_fix = 1,
8875 .input_mux = &alc883_asus_eee1601_capture_source,
8876 .unsol_event = alc883_eee1601_unsol_event,
8877 .init_hook = alc883_eee1601_inithook,
8878 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008879 [ALC1200_ASUS_P5Q] = {
8880 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8881 .init_verbs = { alc883_init_verbs },
8882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8883 .dac_nids = alc883_dac_nids,
8884 .dig_out_nid = ALC1200_DIGOUT_NID,
8885 .dig_in_nid = ALC883_DIGIN_NID,
8886 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8887 .channel_mode = alc883_sixstack_modes,
8888 .input_mux = &alc883_capture_source,
8889 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008890};
8891
8892
8893/*
8894 * BIOS auto configuration
8895 */
8896static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8897 hda_nid_t nid, int pin_type,
8898 int dac_idx)
8899{
8900 /* set as output */
8901 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008902 int idx;
8903
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008904 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8906 idx = 4;
8907 else
8908 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008909 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8910
8911}
8912
8913static void alc883_auto_init_multi_out(struct hda_codec *codec)
8914{
8915 struct alc_spec *spec = codec->spec;
8916 int i;
8917
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008918 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008919 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008920 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008921 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008922 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008923 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008924 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008925 }
8926}
8927
8928static void alc883_auto_init_hp_out(struct hda_codec *codec)
8929{
8930 struct alc_spec *spec = codec->spec;
8931 hda_nid_t pin;
8932
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008933 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008934 if (pin) /* connect to front */
8935 /* use dac 0 */
8936 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008937 pin = spec->autocfg.speaker_pins[0];
8938 if (pin)
8939 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008940}
8941
8942#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8943#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8944
8945static void alc883_auto_init_analog_input(struct hda_codec *codec)
8946{
8947 struct alc_spec *spec = codec->spec;
8948 int i;
8949
8950 for (i = 0; i < AUTO_PIN_LAST; i++) {
8951 hda_nid_t nid = spec->autocfg.input_pins[i];
8952 if (alc883_is_input_pin(nid)) {
8953 snd_hda_codec_write(codec, nid, 0,
8954 AC_VERB_SET_PIN_WIDGET_CONTROL,
8955 (i <= AUTO_PIN_FRONT_MIC ?
8956 PIN_VREF80 : PIN_IN));
8957 if (nid != ALC883_PIN_CD_NID)
8958 snd_hda_codec_write(codec, nid, 0,
8959 AC_VERB_SET_AMP_GAIN_MUTE,
8960 AMP_OUT_MUTE);
8961 }
8962 }
8963}
8964
Takashi Iwaif511b012008-08-15 16:46:42 +02008965#define alc883_auto_init_input_src alc882_auto_init_input_src
8966
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008967/* almost identical with ALC880 parser... */
8968static int alc883_parse_auto_config(struct hda_codec *codec)
8969{
8970 struct alc_spec *spec = codec->spec;
8971 int err = alc880_parse_auto_config(codec);
8972
8973 if (err < 0)
8974 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008975 else if (!err)
8976 return 0; /* no config found */
8977
8978 err = alc_auto_add_mic_boost(codec);
8979 if (err < 0)
8980 return err;
8981
8982 /* hack - override the init verbs */
8983 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008984
8985 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008986}
8987
8988/* additional initialization for auto-configuration model */
8989static void alc883_auto_init(struct hda_codec *codec)
8990{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008991 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008992 alc883_auto_init_multi_out(codec);
8993 alc883_auto_init_hp_out(codec);
8994 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008995 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008996 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008997 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008998}
8999
9000static int patch_alc883(struct hda_codec *codec)
9001{
9002 struct alc_spec *spec;
9003 int err, board_config;
9004
9005 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9006 if (spec == NULL)
9007 return -ENOMEM;
9008
9009 codec->spec = spec;
9010
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009011 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9012
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009013 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9014 alc883_models,
9015 alc883_cfg_tbl);
9016 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009017 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9018 "trying auto-probe from BIOS...\n");
9019 board_config = ALC883_AUTO;
9020 }
9021
9022 if (board_config == ALC883_AUTO) {
9023 /* automatic parse from the BIOS config */
9024 err = alc883_parse_auto_config(codec);
9025 if (err < 0) {
9026 alc_free(codec);
9027 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009028 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009029 printk(KERN_INFO
9030 "hda_codec: Cannot set up configuration "
9031 "from BIOS. Using base mode...\n");
9032 board_config = ALC883_3ST_2ch_DIG;
9033 }
9034 }
9035
9036 if (board_config != ALC883_AUTO)
9037 setup_preset(spec, &alc883_presets[board_config]);
9038
Kailang Yang2f893282008-05-27 12:14:47 +02009039 switch (codec->vendor_id) {
9040 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009041 if (codec->revision_id == 0x100101) {
9042 spec->stream_name_analog = "ALC1200 Analog";
9043 spec->stream_name_digital = "ALC1200 Digital";
9044 } else {
9045 spec->stream_name_analog = "ALC888 Analog";
9046 spec->stream_name_digital = "ALC888 Digital";
9047 }
Kailang Yang2f893282008-05-27 12:14:47 +02009048 break;
9049 case 0x10ec0889:
9050 spec->stream_name_analog = "ALC889 Analog";
9051 spec->stream_name_digital = "ALC889 Digital";
9052 break;
9053 default:
9054 spec->stream_name_analog = "ALC883 Analog";
9055 spec->stream_name_digital = "ALC883 Digital";
9056 break;
9057 }
9058
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009059 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9060 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009061 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009062
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009063 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9064 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9065
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009066 if (!spec->num_adc_nids) {
9067 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9068 spec->adc_nids = alc883_adc_nids;
9069 }
9070 if (!spec->capsrc_nids)
9071 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009072 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009073 if (!spec->cap_mixer)
9074 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075
Takashi Iwai2134ea42008-01-10 16:53:55 +01009076 spec->vmaster_nid = 0x0c;
9077
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009078 codec->patch_ops = alc_patch_ops;
9079 if (board_config == ALC883_AUTO)
9080 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009081
Takashi Iwaicb53c622007-08-10 17:21:45 +02009082#ifdef CONFIG_SND_HDA_POWER_SAVE
9083 if (!spec->loopback.amplist)
9084 spec->loopback.amplist = alc883_loopbacks;
9085#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009086 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009087
9088 return 0;
9089}
9090
9091/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009092 * ALC262 support
9093 */
9094
9095#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9096#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9097
9098#define alc262_dac_nids alc260_dac_nids
9099#define alc262_adc_nids alc882_adc_nids
9100#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009101#define alc262_capsrc_nids alc882_capsrc_nids
9102#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009103
9104#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009105#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009106
Kailang Yang4e555fe2008-08-26 13:05:55 +02009107static hda_nid_t alc262_dmic_adc_nids[1] = {
9108 /* ADC0 */
9109 0x09
9110};
9111
9112static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9113
Kailang Yangdf694da2005-12-05 19:42:22 +01009114static struct snd_kcontrol_new alc262_base_mixer[] = {
9115 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9116 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9117 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9118 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009123 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009126 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009127 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009128 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01009129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9131 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9132 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009133 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009134};
9135
Kailang Yangccc656c2006-10-17 12:32:26 +02009136static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9138 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9139 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9140 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009148 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009149 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009150 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02009151 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9153 { } /* end */
9154};
9155
Takashi Iwaice875f02008-01-28 18:17:43 +01009156/* update HP, line and mono-out pins according to the master switch */
9157static void alc262_hp_master_update(struct hda_codec *codec)
9158{
9159 struct alc_spec *spec = codec->spec;
9160 int val = spec->master_sw;
9161
9162 /* HP & line-out */
9163 snd_hda_codec_write_cache(codec, 0x1b, 0,
9164 AC_VERB_SET_PIN_WIDGET_CONTROL,
9165 val ? PIN_HP : 0);
9166 snd_hda_codec_write_cache(codec, 0x15, 0,
9167 AC_VERB_SET_PIN_WIDGET_CONTROL,
9168 val ? PIN_HP : 0);
9169 /* mono (speaker) depending on the HP jack sense */
9170 val = val && !spec->jack_present;
9171 snd_hda_codec_write_cache(codec, 0x16, 0,
9172 AC_VERB_SET_PIN_WIDGET_CONTROL,
9173 val ? PIN_OUT : 0);
9174}
9175
9176static void alc262_hp_bpc_automute(struct hda_codec *codec)
9177{
9178 struct alc_spec *spec = codec->spec;
9179 unsigned int presence;
9180 presence = snd_hda_codec_read(codec, 0x1b, 0,
9181 AC_VERB_GET_PIN_SENSE, 0);
9182 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9183 alc262_hp_master_update(codec);
9184}
9185
9186static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9187{
9188 if ((res >> 26) != ALC880_HP_EVENT)
9189 return;
9190 alc262_hp_bpc_automute(codec);
9191}
9192
9193static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9194{
9195 struct alc_spec *spec = codec->spec;
9196 unsigned int presence;
9197 presence = snd_hda_codec_read(codec, 0x15, 0,
9198 AC_VERB_GET_PIN_SENSE, 0);
9199 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9200 alc262_hp_master_update(codec);
9201}
9202
9203static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9204 unsigned int res)
9205{
9206 if ((res >> 26) != ALC880_HP_EVENT)
9207 return;
9208 alc262_hp_wildwest_automute(codec);
9209}
9210
9211static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9212 struct snd_ctl_elem_value *ucontrol)
9213{
9214 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9215 struct alc_spec *spec = codec->spec;
9216 *ucontrol->value.integer.value = spec->master_sw;
9217 return 0;
9218}
9219
9220static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9221 struct snd_ctl_elem_value *ucontrol)
9222{
9223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9224 struct alc_spec *spec = codec->spec;
9225 int val = !!*ucontrol->value.integer.value;
9226
9227 if (val == spec->master_sw)
9228 return 0;
9229 spec->master_sw = val;
9230 alc262_hp_master_update(codec);
9231 return 1;
9232}
9233
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009234static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009235 {
9236 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9237 .name = "Master Playback Switch",
9238 .info = snd_ctl_boolean_mono_info,
9239 .get = alc262_hp_master_sw_get,
9240 .put = alc262_hp_master_sw_put,
9241 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9243 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009245 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9246 HDA_OUTPUT),
9247 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9248 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9250 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009251 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009252 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9253 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009254 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9259 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9260 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9261 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9262 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9263 { } /* end */
9264};
9265
Kailang Yangcd7509a2007-01-26 18:33:17 +01009266static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009267 {
9268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9269 .name = "Master Playback Switch",
9270 .info = snd_ctl_boolean_mono_info,
9271 .get = alc262_hp_master_sw_get,
9272 .put = alc262_hp_master_sw_put,
9273 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9275 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009278 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9279 HDA_OUTPUT),
9280 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9281 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009282 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9283 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009284 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9287 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9288 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9289 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9290 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9291 { } /* end */
9292};
9293
9294static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9295 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9296 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009297 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009298 { } /* end */
9299};
9300
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009301/* mute/unmute internal speaker according to the hp jack and mute state */
9302static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9303{
9304 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009305
9306 if (force || !spec->sense_updated) {
9307 unsigned int present;
9308 present = snd_hda_codec_read(codec, 0x15, 0,
9309 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009310 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009311 spec->sense_updated = 1;
9312 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009313 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9314 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009315}
9316
9317static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9318 unsigned int res)
9319{
9320 if ((res >> 26) != ALC880_HP_EVENT)
9321 return;
9322 alc262_hp_t5735_automute(codec, 1);
9323}
9324
9325static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9326{
9327 alc262_hp_t5735_automute(codec, 1);
9328}
9329
9330static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009331 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9332 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9337 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9338 { } /* end */
9339};
9340
9341static struct hda_verb alc262_hp_t5735_verbs[] = {
9342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9344
9345 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9346 { }
9347};
9348
Kailang Yang8c427222008-01-10 13:03:59 +01009349static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9353 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9355 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9356 { } /* end */
9357};
9358
9359static struct hda_verb alc262_hp_rp5700_verbs[] = {
9360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9364 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9365 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9370 {}
9371};
9372
9373static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9374 .num_items = 1,
9375 .items = {
9376 { "Line", 0x1 },
9377 },
9378};
9379
Takashi Iwai0724ea22007-08-23 00:31:43 +02009380/* bind hp and internal speaker mute (with plug check) */
9381static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9382 struct snd_ctl_elem_value *ucontrol)
9383{
9384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9385 long *valp = ucontrol->value.integer.value;
9386 int change;
9387
9388 /* change hp mute */
9389 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9390 HDA_AMP_MUTE,
9391 valp[0] ? 0 : HDA_AMP_MUTE);
9392 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9393 HDA_AMP_MUTE,
9394 valp[1] ? 0 : HDA_AMP_MUTE);
9395 if (change) {
9396 /* change speaker according to HP jack state */
9397 struct alc_spec *spec = codec->spec;
9398 unsigned int mute;
9399 if (spec->jack_present)
9400 mute = HDA_AMP_MUTE;
9401 else
9402 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9403 HDA_OUTPUT, 0);
9404 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9405 HDA_AMP_MUTE, mute);
9406 }
9407 return change;
9408}
Takashi Iwai5b319542007-07-26 11:49:22 +02009409
Kailang Yang272a5272007-05-14 11:00:38 +02009410static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009411 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9412 {
9413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9414 .name = "Master Playback Switch",
9415 .info = snd_hda_mixer_amp_switch_info,
9416 .get = snd_hda_mixer_amp_switch_get,
9417 .put = alc262_sony_master_sw_put,
9418 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9419 },
Kailang Yang272a5272007-05-14 11:00:38 +02009420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9422 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9423 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9424 { } /* end */
9425};
9426
Kailang Yang83c34212007-07-05 11:43:05 +02009427static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9429 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9433 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9434 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9435 { } /* end */
9436};
Kailang Yang272a5272007-05-14 11:00:38 +02009437
Kailang Yangdf694da2005-12-05 19:42:22 +01009438#define alc262_capture_mixer alc882_capture_mixer
9439#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9440
9441/*
9442 * generic initialization of ADC, input mixers and output mixers
9443 */
9444static struct hda_verb alc262_init_verbs[] = {
9445 /*
9446 * Unmute ADC0-2 and set the default input to mic-in
9447 */
9448 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9450 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9452 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9454
Takashi Iwaicb53c622007-08-10 17:21:45 +02009455 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009456 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009457 * Note: PASD motherboards uses the Line In 2 as the input for
9458 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009459 */
9460 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009461 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9462 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009466
9467 /*
9468 * Set up output mixers (0x0c - 0x0e)
9469 */
9470 /* set vol=0 to output mixers */
9471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9474 /* set up input amps for analog loopback */
9475 /* Amp Indices: DAC = 0, mixer = 1 */
9476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9479 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9482
9483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9485 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9488 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9489
9490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9493 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009495
Kailang Yangdf694da2005-12-05 19:42:22 +01009496 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9497 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009498
Kailang Yangdf694da2005-12-05 19:42:22 +01009499 /* FIXME: use matrix-type input source selection */
9500 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9501 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9506 /* Input mixer2 */
9507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9511 /* Input mixer3 */
9512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009516
9517 { }
9518};
9519
Kailang Yang4e555fe2008-08-26 13:05:55 +02009520static struct hda_verb alc262_eapd_verbs[] = {
9521 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9522 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9523 { }
9524};
9525
Kailang Yangccc656c2006-10-17 12:32:26 +02009526static struct hda_verb alc262_hippo_unsol_verbs[] = {
9527 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9529 {}
9530};
9531
9532static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9534 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9536
9537 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9539 {}
9540};
9541
Kailang Yang272a5272007-05-14 11:00:38 +02009542static struct hda_verb alc262_sony_unsol_verbs[] = {
9543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9546
9547 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9548 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009549 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009550};
9551
Kailang Yang4e555fe2008-08-26 13:05:55 +02009552static struct hda_input_mux alc262_dmic_capture_source = {
9553 .num_items = 2,
9554 .items = {
9555 { "Int DMic", 0x9 },
9556 { "Mic", 0x0 },
9557 },
9558};
9559
9560static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9561 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9562 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009566 { } /* end */
9567};
9568
9569static struct hda_verb alc262_toshiba_s06_verbs[] = {
9570 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9574 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9575 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9576 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9577 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9578 {}
9579};
9580
9581static void alc262_dmic_automute(struct hda_codec *codec)
9582{
9583 unsigned int present;
9584
9585 present = snd_hda_codec_read(codec, 0x18, 0,
9586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9587 snd_hda_codec_write(codec, 0x22, 0,
9588 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9589}
9590
9591/* toggle speaker-output according to the hp-jack state */
9592static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9593{
9594 unsigned int present;
9595 unsigned char bits;
9596
9597 present = snd_hda_codec_read(codec, 0x15, 0,
9598 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9599 bits = present ? 0 : PIN_OUT;
9600 snd_hda_codec_write(codec, 0x14, 0,
9601 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9602}
9603
9604
9605
9606/* unsolicited event for HP jack sensing */
9607static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9608 unsigned int res)
9609{
9610 if ((res >> 26) == ALC880_HP_EVENT)
9611 alc262_toshiba_s06_speaker_automute(codec);
9612 if ((res >> 26) == ALC880_MIC_EVENT)
9613 alc262_dmic_automute(codec);
9614
9615}
9616
9617static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9618{
9619 alc262_toshiba_s06_speaker_automute(codec);
9620 alc262_dmic_automute(codec);
9621}
9622
Kailang Yangccc656c2006-10-17 12:32:26 +02009623/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009624static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009625{
9626 struct alc_spec *spec = codec->spec;
9627 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009628 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009629
Takashi Iwai5b319542007-07-26 11:49:22 +02009630 /* need to execute and sync at first */
9631 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9632 present = snd_hda_codec_read(codec, 0x15, 0,
9633 AC_VERB_GET_PIN_SENSE, 0);
9634 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009635 if (spec->jack_present) {
9636 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009637 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9638 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009639 } else {
9640 /* unmute internal speaker if necessary */
9641 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009642 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9643 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009644 }
9645}
9646
9647/* unsolicited event for HP jack sensing */
9648static void alc262_hippo_unsol_event(struct hda_codec *codec,
9649 unsigned int res)
9650{
9651 if ((res >> 26) != ALC880_HP_EVENT)
9652 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009653 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009654}
9655
Takashi Iwai5b319542007-07-26 11:49:22 +02009656static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009657{
Kailang Yangccc656c2006-10-17 12:32:26 +02009658 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009659 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009660
Takashi Iwai5b319542007-07-26 11:49:22 +02009661 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9662 present = snd_hda_codec_read(codec, 0x1b, 0,
9663 AC_VERB_GET_PIN_SENSE, 0);
9664 present = (present & 0x80000000) != 0;
9665 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009666 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009667 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9668 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009669 } else {
9670 /* unmute internal speaker if necessary */
9671 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009672 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9673 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009674 }
9675}
9676
9677/* unsolicited event for HP jack sensing */
9678static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9679 unsigned int res)
9680{
9681 if ((res >> 26) != ALC880_HP_EVENT)
9682 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009683 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009684}
9685
Takashi Iwai834be882006-03-01 14:16:17 +01009686/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009687 * nec model
9688 * 0x15 = headphone
9689 * 0x16 = internal speaker
9690 * 0x18 = external mic
9691 */
9692
9693static struct snd_kcontrol_new alc262_nec_mixer[] = {
9694 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9695 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9696
9697 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9698 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9700
9701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9703 { } /* end */
9704};
9705
9706static struct hda_verb alc262_nec_verbs[] = {
9707 /* Unmute Speaker */
9708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9709
9710 /* Headphone */
9711 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9713
9714 /* External mic to headphone */
9715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9716 /* External mic to speaker */
9717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9718 {}
9719};
9720
9721/*
Takashi Iwai834be882006-03-01 14:16:17 +01009722 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009723 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9724 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009725 */
9726
9727#define ALC_HP_EVENT 0x37
9728
9729static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009732 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009734 {}
9735};
9736
Jiang zhe0e31daf2008-03-20 12:12:39 +01009737static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9738 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9740 {}
9741};
9742
Takashi Iwai834be882006-03-01 14:16:17 +01009743static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009744 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009745 .items = {
9746 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009747 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009748 { "CD", 0x4 },
9749 },
9750};
9751
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009752static struct hda_input_mux alc262_HP_capture_source = {
9753 .num_items = 5,
9754 .items = {
9755 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009756 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009757 { "Line", 0x2 },
9758 { "CD", 0x4 },
9759 { "AUX IN", 0x6 },
9760 },
9761};
9762
zhejiangaccbe492007-08-31 12:36:05 +02009763static struct hda_input_mux alc262_HP_D7000_capture_source = {
9764 .num_items = 4,
9765 .items = {
9766 { "Mic", 0x0 },
9767 { "Front Mic", 0x2 },
9768 { "Line", 0x1 },
9769 { "CD", 0x4 },
9770 },
9771};
9772
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009773/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009774static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9775{
9776 struct alc_spec *spec = codec->spec;
9777 unsigned int mute;
9778
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009779 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009780 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009781 /* need to execute and sync at first */
9782 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009783 /* check laptop HP jack */
9784 present = snd_hda_codec_read(codec, 0x14, 0,
9785 AC_VERB_GET_PIN_SENSE, 0);
9786 /* need to execute and sync at first */
9787 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9788 /* check docking HP jack */
9789 present |= snd_hda_codec_read(codec, 0x1b, 0,
9790 AC_VERB_GET_PIN_SENSE, 0);
9791 if (present & AC_PINSENSE_PRESENCE)
9792 spec->jack_present = 1;
9793 else
9794 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009795 spec->sense_updated = 1;
9796 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009797 /* unmute internal speaker only if both HPs are unplugged and
9798 * master switch is on
9799 */
9800 if (spec->jack_present)
9801 mute = HDA_AMP_MUTE;
9802 else
Takashi Iwai834be882006-03-01 14:16:17 +01009803 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009804 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9805 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009806}
9807
9808/* unsolicited event for HP jack sensing */
9809static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9810 unsigned int res)
9811{
9812 if ((res >> 26) != ALC_HP_EVENT)
9813 return;
9814 alc262_fujitsu_automute(codec, 1);
9815}
9816
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009817static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9818{
9819 alc262_fujitsu_automute(codec, 1);
9820}
9821
Takashi Iwai834be882006-03-01 14:16:17 +01009822/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009823static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9824 .ops = &snd_hda_bind_vol,
9825 .values = {
9826 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9827 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9828 0
9829 },
9830};
Takashi Iwai834be882006-03-01 14:16:17 +01009831
Jiang zhe0e31daf2008-03-20 12:12:39 +01009832/* mute/unmute internal speaker according to the hp jack and mute state */
9833static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9834{
9835 struct alc_spec *spec = codec->spec;
9836 unsigned int mute;
9837
9838 if (force || !spec->sense_updated) {
9839 unsigned int present_int_hp;
9840 /* need to execute and sync at first */
9841 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9842 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9843 AC_VERB_GET_PIN_SENSE, 0);
9844 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9845 spec->sense_updated = 1;
9846 }
9847 if (spec->jack_present) {
9848 /* mute internal speaker */
9849 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9850 HDA_AMP_MUTE, HDA_AMP_MUTE);
9851 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9852 HDA_AMP_MUTE, HDA_AMP_MUTE);
9853 } else {
9854 /* unmute internal speaker if necessary */
9855 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9856 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9857 HDA_AMP_MUTE, mute);
9858 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9859 HDA_AMP_MUTE, mute);
9860 }
9861}
9862
9863/* unsolicited event for HP jack sensing */
9864static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9865 unsigned int res)
9866{
9867 if ((res >> 26) != ALC_HP_EVENT)
9868 return;
9869 alc262_lenovo_3000_automute(codec, 1);
9870}
9871
Takashi Iwai834be882006-03-01 14:16:17 +01009872/* bind hp and internal speaker mute (with plug check) */
9873static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9874 struct snd_ctl_elem_value *ucontrol)
9875{
9876 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9877 long *valp = ucontrol->value.integer.value;
9878 int change;
9879
Tony Vroon5d9fab22008-03-14 17:09:18 +01009880 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9881 HDA_AMP_MUTE,
9882 valp ? 0 : HDA_AMP_MUTE);
9883 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9884 HDA_AMP_MUTE,
9885 valp ? 0 : HDA_AMP_MUTE);
9886
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009887 if (change)
9888 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009889 return change;
9890}
9891
9892static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009893 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009894 {
9895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9896 .name = "Master Playback Switch",
9897 .info = snd_hda_mixer_amp_switch_info,
9898 .get = snd_hda_mixer_amp_switch_get,
9899 .put = alc262_fujitsu_master_sw_put,
9900 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9901 },
9902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009904 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9905 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009906 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009909 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9910 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9911 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009912 { } /* end */
9913};
9914
Jiang zhe0e31daf2008-03-20 12:12:39 +01009915/* bind hp and internal speaker mute (with plug check) */
9916static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9917 struct snd_ctl_elem_value *ucontrol)
9918{
9919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9920 long *valp = ucontrol->value.integer.value;
9921 int change;
9922
9923 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9924 HDA_AMP_MUTE,
9925 valp ? 0 : HDA_AMP_MUTE);
9926
9927 if (change)
9928 alc262_lenovo_3000_automute(codec, 0);
9929 return change;
9930}
9931
9932static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9933 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9934 {
9935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9936 .name = "Master Playback Switch",
9937 .info = snd_hda_mixer_amp_switch_info,
9938 .get = snd_hda_mixer_amp_switch_get,
9939 .put = alc262_lenovo_3000_master_sw_put,
9940 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9941 },
9942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9947 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9948 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9949 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9950 { } /* end */
9951};
9952
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009953static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9954 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9955 {
9956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9957 .name = "Master Playback Switch",
9958 .info = snd_hda_mixer_amp_switch_info,
9959 .get = snd_hda_mixer_amp_switch_get,
9960 .put = alc262_sony_master_sw_put,
9961 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9962 },
9963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9965 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9966 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9967 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9968 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9969 { } /* end */
9970};
9971
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009972/* additional init verbs for Benq laptops */
9973static struct hda_verb alc262_EAPD_verbs[] = {
9974 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9975 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9976 {}
9977};
9978
Kailang Yang83c34212007-07-05 11:43:05 +02009979static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9981 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9982
9983 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9984 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9985 {}
9986};
9987
Tobin Davisf651b502007-10-26 12:40:47 +02009988/* Samsung Q1 Ultra Vista model setup */
9989static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009990 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9991 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9994 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009995 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009996 { } /* end */
9997};
9998
9999static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010000 /* output mixer */
10001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10004 /* speaker */
10005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10008 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10009 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10015 /* internal mic */
10016 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10018 /* ADC, choose mic */
10019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10020 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10021 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10022 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010029 {}
10030};
10031
Tobin Davisf651b502007-10-26 12:40:47 +020010032/* mute/unmute internal speaker according to the hp jack and mute state */
10033static void alc262_ultra_automute(struct hda_codec *codec)
10034{
10035 struct alc_spec *spec = codec->spec;
10036 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010037
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010038 mute = 0;
10039 /* auto-mute only when HP is used as HP */
10040 if (!spec->cur_mux[0]) {
10041 unsigned int present;
10042 /* need to execute and sync at first */
10043 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10044 present = snd_hda_codec_read(codec, 0x15, 0,
10045 AC_VERB_GET_PIN_SENSE, 0);
10046 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10047 if (spec->jack_present)
10048 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010049 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010050 /* mute/unmute internal speaker */
10051 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10052 HDA_AMP_MUTE, mute);
10053 /* mute/unmute HP */
10054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10055 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010056}
10057
10058/* unsolicited event for HP jack sensing */
10059static void alc262_ultra_unsol_event(struct hda_codec *codec,
10060 unsigned int res)
10061{
10062 if ((res >> 26) != ALC880_HP_EVENT)
10063 return;
10064 alc262_ultra_automute(codec);
10065}
10066
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010067static struct hda_input_mux alc262_ultra_capture_source = {
10068 .num_items = 2,
10069 .items = {
10070 { "Mic", 0x1 },
10071 { "Headphone", 0x7 },
10072 },
10073};
10074
10075static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10076 struct snd_ctl_elem_value *ucontrol)
10077{
10078 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10079 struct alc_spec *spec = codec->spec;
10080 int ret;
10081
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010082 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010083 if (!ret)
10084 return 0;
10085 /* reprogram the HP pin as mic or HP according to the input source */
10086 snd_hda_codec_write_cache(codec, 0x15, 0,
10087 AC_VERB_SET_PIN_WIDGET_CONTROL,
10088 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10089 alc262_ultra_automute(codec); /* mute/unmute HP */
10090 return ret;
10091}
10092
10093static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10094 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10095 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10096 {
10097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10098 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010099 .info = alc_mux_enum_info,
10100 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010101 .put = alc262_ultra_mux_enum_put,
10102 },
10103 { } /* end */
10104};
10105
Kailang Yangdf694da2005-12-05 19:42:22 +010010106/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010107static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10108 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010109{
10110 hda_nid_t nid;
10111 int err;
10112
10113 spec->multiout.num_dacs = 1; /* only use one dac */
10114 spec->multiout.dac_nids = spec->private_dac_nids;
10115 spec->multiout.dac_nids[0] = 2;
10116
10117 nid = cfg->line_out_pins[0];
10118 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010119 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10120 "Front Playback Volume",
10121 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10122 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010123 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010124 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10125 "Front Playback Switch",
10126 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10127 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010128 return err;
10129 }
10130
Takashi Iwai82bc9552006-03-21 11:24:42 +010010131 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010132 if (nid) {
10133 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010134 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10135 "Speaker Playback Volume",
10136 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10137 HDA_OUTPUT));
10138 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010139 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010140 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10141 "Speaker Playback Switch",
10142 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10143 HDA_OUTPUT));
10144 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010145 return err;
10146 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010147 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10148 "Speaker Playback Switch",
10149 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10150 HDA_OUTPUT));
10151 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010152 return err;
10153 }
10154 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010155 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010156 if (nid) {
10157 /* spec->multiout.hp_nid = 2; */
10158 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010159 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10160 "Headphone Playback Volume",
10161 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10162 HDA_OUTPUT));
10163 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010164 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010165 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10166 "Headphone Playback Switch",
10167 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10168 HDA_OUTPUT));
10169 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010170 return err;
10171 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010172 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10173 "Headphone Playback Switch",
10174 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10175 HDA_OUTPUT));
10176 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010177 return err;
10178 }
10179 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010180 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010181}
10182
10183/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010184#define alc262_auto_create_analog_input_ctls \
10185 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010186
10187/*
10188 * generic initialization of ADC, input mixers and output mixers
10189 */
10190static struct hda_verb alc262_volume_init_verbs[] = {
10191 /*
10192 * Unmute ADC0-2 and set the default input to mic-in
10193 */
10194 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10196 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10200
Takashi Iwaicb53c622007-08-10 17:21:45 +020010201 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010202 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010203 * Note: PASD motherboards uses the Line In 2 as the input for
10204 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010205 */
10206 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010212
10213 /*
10214 * Set up output mixers (0x0c - 0x0f)
10215 */
10216 /* set vol=0 to output mixers */
10217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010220
Kailang Yangdf694da2005-12-05 19:42:22 +010010221 /* set up input amps for analog loopback */
10222 /* Amp Indices: DAC = 0, mixer = 1 */
10223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10229
10230 /* FIXME: use matrix-type input source selection */
10231 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10232 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10234 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10235 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10237 /* Input mixer2 */
10238 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10239 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10240 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10242 /* Input mixer3 */
10243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10247
10248 { }
10249};
10250
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010251static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10252 /*
10253 * Unmute ADC0-2 and set the default input to mic-in
10254 */
10255 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10257 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10258 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10259 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10261
Takashi Iwaicb53c622007-08-10 17:21:45 +020010262 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010263 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010264 * Note: PASD motherboards uses the Line In 2 as the input for
10265 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010266 */
10267 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010275
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010276 /*
10277 * Set up output mixers (0x0c - 0x0e)
10278 */
10279 /* set vol=0 to output mixers */
10280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10283
10284 /* set up input amps for analog loopback */
10285 /* Amp Indices: DAC = 0, mixer = 1 */
10286 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10292
Takashi Iwaice875f02008-01-28 18:17:43 +010010293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10296
10297 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10299
10300 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10301 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10302
10303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10304 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10305 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10307 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10308
10309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10313 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10314 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10315
10316
10317 /* FIXME: use matrix-type input source selection */
10318 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10319 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10324 /* Input mixer2 */
10325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10329 /* Input mixer3 */
10330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10334
Takashi Iwaice875f02008-01-28 18:17:43 +010010335 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10336
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010337 { }
10338};
10339
Kailang Yangcd7509a2007-01-26 18:33:17 +010010340static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10341 /*
10342 * Unmute ADC0-2 and set the default input to mic-in
10343 */
10344 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10349 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10350
Takashi Iwaicb53c622007-08-10 17:21:45 +020010351 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010352 * mixer widget
10353 * Note: PASD motherboards uses the Line In 2 as the input for front
10354 * panel mic (mic 2)
10355 */
10356 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010365 /*
10366 * Set up output mixers (0x0c - 0x0e)
10367 */
10368 /* set vol=0 to output mixers */
10369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10372
10373 /* set up input amps for analog loopback */
10374 /* Amp Indices: DAC = 0, mixer = 1 */
10375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10381
10382
10383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10384 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10387 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10389 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10390
10391 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10393
10394 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10395 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10396
10397 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10401 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10402 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10403
10404 /* FIXME: use matrix-type input source selection */
10405 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10406 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10412 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10414 /* Input mixer2 */
10415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10420 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10422 /* Input mixer3 */
10423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10428 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10430
Takashi Iwaice875f02008-01-28 18:17:43 +010010431 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10432
Kailang Yangcd7509a2007-01-26 18:33:17 +010010433 { }
10434};
10435
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010436static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10437
10438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10441
10442 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10443 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10444 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10446
10447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10450 {}
10451};
10452
10453
Takashi Iwaicb53c622007-08-10 17:21:45 +020010454#ifdef CONFIG_SND_HDA_POWER_SAVE
10455#define alc262_loopbacks alc880_loopbacks
10456#endif
10457
Kailang Yangdf694da2005-12-05 19:42:22 +010010458/* pcm configuration: identiacal with ALC880 */
10459#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10460#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10461#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10462#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10463
10464/*
10465 * BIOS auto configuration
10466 */
10467static int alc262_parse_auto_config(struct hda_codec *codec)
10468{
10469 struct alc_spec *spec = codec->spec;
10470 int err;
10471 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10472
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010473 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10474 alc262_ignore);
10475 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010476 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010477 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010478 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010479 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10480 if (err < 0)
10481 return err;
10482 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10483 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010484 return err;
10485
10486 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10487
10488 if (spec->autocfg.dig_out_pin)
10489 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10490 if (spec->autocfg.dig_in_pin)
10491 spec->dig_in_nid = ALC262_DIGIN_NID;
10492
Takashi Iwai603c4012008-07-30 15:01:44 +020010493 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010494 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010495
Takashi Iwaid88897e2008-10-31 15:01:37 +010010496 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010497 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010498 spec->input_mux = &spec->private_imux;
10499
Takashi Iwai776e1842007-08-29 15:07:11 +020010500 err = alc_auto_add_mic_boost(codec);
10501 if (err < 0)
10502 return err;
10503
Takashi Iwaie044c392008-10-27 16:56:24 +010010504 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010505 return 1;
10506}
10507
10508#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10509#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10510#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010511#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010512
10513
10514/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010515static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010516{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010517 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010518 alc262_auto_init_multi_out(codec);
10519 alc262_auto_init_hp_out(codec);
10520 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010521 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010522 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010523 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010524}
10525
10526/*
10527 * configuration and preset
10528 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010529static const char *alc262_models[ALC262_MODEL_LAST] = {
10530 [ALC262_BASIC] = "basic",
10531 [ALC262_HIPPO] = "hippo",
10532 [ALC262_HIPPO_1] = "hippo_1",
10533 [ALC262_FUJITSU] = "fujitsu",
10534 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010535 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010536 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010537 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010538 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010539 [ALC262_BENQ_T31] = "benq-t31",
10540 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010541 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010542 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010543 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010544 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010545 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010546 [ALC262_AUTO] = "auto",
10547};
10548
10549static struct snd_pci_quirk alc262_cfg_tbl[] = {
10550 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010551 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010552 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010553 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010554 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10555 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010556 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010557 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010558 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010559 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010560 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010561 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010562 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010563 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010564 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010565 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010566 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010567 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010568 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10569 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10570 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010571 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10572 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010573 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010574 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010575 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010576 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10577 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10578 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010579 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10580 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010581 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010582 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010583 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010584 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010585 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010586 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010587 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010588 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010589 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010590 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010591 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010592 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010593 {}
10594};
10595
10596static struct alc_config_preset alc262_presets[] = {
10597 [ALC262_BASIC] = {
10598 .mixers = { alc262_base_mixer },
10599 .init_verbs = { alc262_init_verbs },
10600 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10601 .dac_nids = alc262_dac_nids,
10602 .hp_nid = 0x03,
10603 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10604 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010605 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010606 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010607 [ALC262_HIPPO] = {
10608 .mixers = { alc262_base_mixer },
10609 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10610 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10611 .dac_nids = alc262_dac_nids,
10612 .hp_nid = 0x03,
10613 .dig_out_nid = ALC262_DIGOUT_NID,
10614 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10615 .channel_mode = alc262_modes,
10616 .input_mux = &alc262_capture_source,
10617 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010618 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010619 },
10620 [ALC262_HIPPO_1] = {
10621 .mixers = { alc262_hippo1_mixer },
10622 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10623 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10624 .dac_nids = alc262_dac_nids,
10625 .hp_nid = 0x02,
10626 .dig_out_nid = ALC262_DIGOUT_NID,
10627 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10628 .channel_mode = alc262_modes,
10629 .input_mux = &alc262_capture_source,
10630 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010631 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010632 },
Takashi Iwai834be882006-03-01 14:16:17 +010010633 [ALC262_FUJITSU] = {
10634 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010635 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10636 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010637 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10638 .dac_nids = alc262_dac_nids,
10639 .hp_nid = 0x03,
10640 .dig_out_nid = ALC262_DIGOUT_NID,
10641 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10642 .channel_mode = alc262_modes,
10643 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010644 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010645 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010646 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010647 [ALC262_HP_BPC] = {
10648 .mixers = { alc262_HP_BPC_mixer },
10649 .init_verbs = { alc262_HP_BPC_init_verbs },
10650 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10651 .dac_nids = alc262_dac_nids,
10652 .hp_nid = 0x03,
10653 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10654 .channel_mode = alc262_modes,
10655 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010656 .unsol_event = alc262_hp_bpc_unsol_event,
10657 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010658 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010659 [ALC262_HP_BPC_D7000_WF] = {
10660 .mixers = { alc262_HP_BPC_WildWest_mixer },
10661 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10662 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10663 .dac_nids = alc262_dac_nids,
10664 .hp_nid = 0x03,
10665 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10666 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010667 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010668 .unsol_event = alc262_hp_wildwest_unsol_event,
10669 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010670 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010671 [ALC262_HP_BPC_D7000_WL] = {
10672 .mixers = { alc262_HP_BPC_WildWest_mixer,
10673 alc262_HP_BPC_WildWest_option_mixer },
10674 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10675 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10676 .dac_nids = alc262_dac_nids,
10677 .hp_nid = 0x03,
10678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10679 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010680 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010681 .unsol_event = alc262_hp_wildwest_unsol_event,
10682 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010683 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010684 [ALC262_HP_TC_T5735] = {
10685 .mixers = { alc262_hp_t5735_mixer },
10686 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10687 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10688 .dac_nids = alc262_dac_nids,
10689 .hp_nid = 0x03,
10690 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10691 .channel_mode = alc262_modes,
10692 .input_mux = &alc262_capture_source,
10693 .unsol_event = alc262_hp_t5735_unsol_event,
10694 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010695 },
10696 [ALC262_HP_RP5700] = {
10697 .mixers = { alc262_hp_rp5700_mixer },
10698 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10699 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10700 .dac_nids = alc262_dac_nids,
10701 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10702 .channel_mode = alc262_modes,
10703 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010704 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010705 [ALC262_BENQ_ED8] = {
10706 .mixers = { alc262_base_mixer },
10707 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10708 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10709 .dac_nids = alc262_dac_nids,
10710 .hp_nid = 0x03,
10711 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10712 .channel_mode = alc262_modes,
10713 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010714 },
Kailang Yang272a5272007-05-14 11:00:38 +020010715 [ALC262_SONY_ASSAMD] = {
10716 .mixers = { alc262_sony_mixer },
10717 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10718 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10719 .dac_nids = alc262_dac_nids,
10720 .hp_nid = 0x02,
10721 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10722 .channel_mode = alc262_modes,
10723 .input_mux = &alc262_capture_source,
10724 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010725 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010726 },
10727 [ALC262_BENQ_T31] = {
10728 .mixers = { alc262_benq_t31_mixer },
10729 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10730 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10731 .dac_nids = alc262_dac_nids,
10732 .hp_nid = 0x03,
10733 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10734 .channel_mode = alc262_modes,
10735 .input_mux = &alc262_capture_source,
10736 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010737 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010738 },
Tobin Davisf651b502007-10-26 12:40:47 +020010739 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010740 .mixers = { alc262_ultra_mixer },
10741 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010742 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10744 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010745 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10746 .channel_mode = alc262_modes,
10747 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010748 .adc_nids = alc262_adc_nids, /* ADC0 */
10749 .capsrc_nids = alc262_capsrc_nids,
10750 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010751 .unsol_event = alc262_ultra_unsol_event,
10752 .init_hook = alc262_ultra_automute,
10753 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010754 [ALC262_LENOVO_3000] = {
10755 .mixers = { alc262_lenovo_3000_mixer },
10756 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10757 alc262_lenovo_3000_unsol_verbs },
10758 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10759 .dac_nids = alc262_dac_nids,
10760 .hp_nid = 0x03,
10761 .dig_out_nid = ALC262_DIGOUT_NID,
10762 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10763 .channel_mode = alc262_modes,
10764 .input_mux = &alc262_fujitsu_capture_source,
10765 .unsol_event = alc262_lenovo_3000_unsol_event,
10766 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010767 [ALC262_NEC] = {
10768 .mixers = { alc262_nec_mixer },
10769 .init_verbs = { alc262_nec_verbs },
10770 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10771 .dac_nids = alc262_dac_nids,
10772 .hp_nid = 0x03,
10773 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10774 .channel_mode = alc262_modes,
10775 .input_mux = &alc262_capture_source,
10776 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010777 [ALC262_TOSHIBA_S06] = {
10778 .mixers = { alc262_toshiba_s06_mixer },
10779 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10780 alc262_eapd_verbs },
10781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10782 .capsrc_nids = alc262_dmic_capsrc_nids,
10783 .dac_nids = alc262_dac_nids,
10784 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10785 .dig_out_nid = ALC262_DIGOUT_NID,
10786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10787 .channel_mode = alc262_modes,
10788 .input_mux = &alc262_dmic_capture_source,
10789 .unsol_event = alc262_toshiba_s06_unsol_event,
10790 .init_hook = alc262_toshiba_s06_init_hook,
10791 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010792 [ALC262_TOSHIBA_RX1] = {
10793 .mixers = { alc262_toshiba_rx1_mixer },
10794 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10795 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10796 .dac_nids = alc262_dac_nids,
10797 .hp_nid = 0x03,
10798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10799 .channel_mode = alc262_modes,
10800 .input_mux = &alc262_capture_source,
10801 .unsol_event = alc262_hippo_unsol_event,
10802 .init_hook = alc262_hippo_automute,
10803 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010804};
10805
10806static int patch_alc262(struct hda_codec *codec)
10807{
10808 struct alc_spec *spec;
10809 int board_config;
10810 int err;
10811
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010812 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010813 if (spec == NULL)
10814 return -ENOMEM;
10815
10816 codec->spec = spec;
10817#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10819 * under-run
10820 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010821 {
10822 int tmp;
10823 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10824 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10825 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10826 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10827 }
10828#endif
10829
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010830 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10831
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010832 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10833 alc262_models,
10834 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010835
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010836 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010837 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10838 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010839 board_config = ALC262_AUTO;
10840 }
10841
10842 if (board_config == ALC262_AUTO) {
10843 /* automatic parse from the BIOS config */
10844 err = alc262_parse_auto_config(codec);
10845 if (err < 0) {
10846 alc_free(codec);
10847 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010848 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010849 printk(KERN_INFO
10850 "hda_codec: Cannot set up configuration "
10851 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010852 board_config = ALC262_BASIC;
10853 }
10854 }
10855
10856 if (board_config != ALC262_AUTO)
10857 setup_preset(spec, &alc262_presets[board_config]);
10858
10859 spec->stream_name_analog = "ALC262 Analog";
10860 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10861 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010862
Kailang Yangdf694da2005-12-05 19:42:22 +010010863 spec->stream_name_digital = "ALC262 Digital";
10864 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10865 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10866
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010867 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010869 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010870 unsigned int wcap = get_wcaps(codec, 0x07);
10871
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010872 /* get type */
10873 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010874 if (wcap != AC_WID_AUD_IN) {
10875 spec->adc_nids = alc262_adc_nids_alt;
10876 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010877 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010878 } else {
10879 spec->adc_nids = alc262_adc_nids;
10880 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010881 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010882 }
10883 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010884 if (!spec->cap_mixer)
10885 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010886
Takashi Iwai2134ea42008-01-10 16:53:55 +010010887 spec->vmaster_nid = 0x0c;
10888
Kailang Yangdf694da2005-12-05 19:42:22 +010010889 codec->patch_ops = alc_patch_ops;
10890 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010891 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010892#ifdef CONFIG_SND_HDA_POWER_SAVE
10893 if (!spec->loopback.amplist)
10894 spec->loopback.amplist = alc262_loopbacks;
10895#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010896 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020010897
Kailang Yangdf694da2005-12-05 19:42:22 +010010898 return 0;
10899}
10900
Kailang Yangdf694da2005-12-05 19:42:22 +010010901/*
Kailang Yanga361d842007-06-05 12:30:55 +020010902 * ALC268 channel source setting (2 channel)
10903 */
10904#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10905#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010906
Kailang Yanga361d842007-06-05 12:30:55 +020010907static hda_nid_t alc268_dac_nids[2] = {
10908 /* front, hp */
10909 0x02, 0x03
10910};
10911
10912static hda_nid_t alc268_adc_nids[2] = {
10913 /* ADC0-1 */
10914 0x08, 0x07
10915};
10916
10917static hda_nid_t alc268_adc_nids_alt[1] = {
10918 /* ADC0 */
10919 0x08
10920};
10921
Takashi Iwaie1406342008-02-11 18:32:32 +010010922static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10923
Kailang Yanga361d842007-06-05 12:30:55 +020010924static struct snd_kcontrol_new alc268_base_mixer[] = {
10925 /* output mixer control */
10926 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10927 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10928 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010930 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10931 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10932 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010933 { }
10934};
10935
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010936/* bind Beep switches of both NID 0x0f and 0x10 */
10937static struct hda_bind_ctls alc268_bind_beep_sw = {
10938 .ops = &snd_hda_bind_sw,
10939 .values = {
10940 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10941 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10942 0
10943 },
10944};
10945
10946static struct snd_kcontrol_new alc268_beep_mixer[] = {
10947 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10948 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10949 { }
10950};
10951
Kailang Yangd1a991a2007-08-15 16:21:59 +020010952static struct hda_verb alc268_eapd_verbs[] = {
10953 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10954 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10955 { }
10956};
10957
Takashi Iwaid2738092007-08-16 14:59:45 +020010958/* Toshiba specific */
10959#define alc268_toshiba_automute alc262_hippo_automute
10960
10961static struct hda_verb alc268_toshiba_verbs[] = {
10962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10963 { } /* end */
10964};
10965
Kailang Yang8ef355d2008-08-26 13:10:22 +020010966static struct hda_input_mux alc268_acer_lc_capture_source = {
10967 .num_items = 2,
10968 .items = {
10969 { "i-Mic", 0x6 },
10970 { "E-Mic", 0x0 },
10971 },
10972};
10973
Takashi Iwaid2738092007-08-16 14:59:45 +020010974/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010975/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010976static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10977 .ops = &snd_hda_bind_vol,
10978 .values = {
10979 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10980 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10981 0
10982 },
10983};
10984
Takashi Iwai889c4392007-08-23 18:56:52 +020010985/* mute/unmute internal speaker according to the hp jack and mute state */
10986static void alc268_acer_automute(struct hda_codec *codec, int force)
10987{
10988 struct alc_spec *spec = codec->spec;
10989 unsigned int mute;
10990
10991 if (force || !spec->sense_updated) {
10992 unsigned int present;
10993 present = snd_hda_codec_read(codec, 0x14, 0,
10994 AC_VERB_GET_PIN_SENSE, 0);
10995 spec->jack_present = (present & 0x80000000) != 0;
10996 spec->sense_updated = 1;
10997 }
10998 if (spec->jack_present)
10999 mute = HDA_AMP_MUTE; /* mute internal speaker */
11000 else /* unmute internal speaker if necessary */
11001 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11002 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11003 HDA_AMP_MUTE, mute);
11004}
11005
11006
11007/* bind hp and internal speaker mute (with plug check) */
11008static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11009 struct snd_ctl_elem_value *ucontrol)
11010{
11011 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11012 long *valp = ucontrol->value.integer.value;
11013 int change;
11014
11015 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11016 HDA_AMP_MUTE,
11017 valp[0] ? 0 : HDA_AMP_MUTE);
11018 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11019 HDA_AMP_MUTE,
11020 valp[1] ? 0 : HDA_AMP_MUTE);
11021 if (change)
11022 alc268_acer_automute(codec, 0);
11023 return change;
11024}
Takashi Iwaid2738092007-08-16 14:59:45 +020011025
Kailang Yang8ef355d2008-08-26 13:10:22 +020011026static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11027 /* output mixer control */
11028 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11029 {
11030 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11031 .name = "Master Playback Switch",
11032 .info = snd_hda_mixer_amp_switch_info,
11033 .get = snd_hda_mixer_amp_switch_get,
11034 .put = alc268_acer_master_sw_put,
11035 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11036 },
11037 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11038 { }
11039};
11040
Takashi Iwaid2738092007-08-16 14:59:45 +020011041static struct snd_kcontrol_new alc268_acer_mixer[] = {
11042 /* output mixer control */
11043 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11044 {
11045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11046 .name = "Master Playback Switch",
11047 .info = snd_hda_mixer_amp_switch_info,
11048 .get = snd_hda_mixer_amp_switch_get,
11049 .put = alc268_acer_master_sw_put,
11050 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11051 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11053 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11054 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011055 { }
11056};
11057
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011058static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11059 /* output mixer control */
11060 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11061 {
11062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11063 .name = "Master Playback Switch",
11064 .info = snd_hda_mixer_amp_switch_info,
11065 .get = snd_hda_mixer_amp_switch_get,
11066 .put = alc268_acer_master_sw_put,
11067 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11068 },
11069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11070 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11071 { }
11072};
11073
Kailang Yang8ef355d2008-08-26 13:10:22 +020011074static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11075 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11078 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11079 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11081 { }
11082};
11083
Takashi Iwaid2738092007-08-16 14:59:45 +020011084static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011085 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11086 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011087 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11090 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011091 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11092 { }
11093};
11094
11095/* unsolicited event for HP jack sensing */
11096static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11097 unsigned int res)
11098{
Takashi Iwai889c4392007-08-23 18:56:52 +020011099 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011100 return;
11101 alc268_toshiba_automute(codec);
11102}
11103
11104static void alc268_acer_unsol_event(struct hda_codec *codec,
11105 unsigned int res)
11106{
Takashi Iwai889c4392007-08-23 18:56:52 +020011107 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011108 return;
11109 alc268_acer_automute(codec, 1);
11110}
11111
Takashi Iwai889c4392007-08-23 18:56:52 +020011112static void alc268_acer_init_hook(struct hda_codec *codec)
11113{
11114 alc268_acer_automute(codec, 1);
11115}
11116
Kailang Yang8ef355d2008-08-26 13:10:22 +020011117/* toggle speaker-output according to the hp-jack state */
11118static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11119{
11120 unsigned int present;
11121 unsigned char bits;
11122
11123 present = snd_hda_codec_read(codec, 0x15, 0,
11124 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11125 bits = present ? AMP_IN_MUTE(0) : 0;
11126 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11127 AMP_IN_MUTE(0), bits);
11128 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11129 AMP_IN_MUTE(0), bits);
11130}
11131
11132
11133static void alc268_acer_mic_automute(struct hda_codec *codec)
11134{
11135 unsigned int present;
11136
11137 present = snd_hda_codec_read(codec, 0x18, 0,
11138 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11139 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11140 present ? 0x0 : 0x6);
11141}
11142
11143static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11144 unsigned int res)
11145{
11146 if ((res >> 26) == ALC880_HP_EVENT)
11147 alc268_aspire_one_speaker_automute(codec);
11148 if ((res >> 26) == ALC880_MIC_EVENT)
11149 alc268_acer_mic_automute(codec);
11150}
11151
11152static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11153{
11154 alc268_aspire_one_speaker_automute(codec);
11155 alc268_acer_mic_automute(codec);
11156}
11157
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011158static struct snd_kcontrol_new alc268_dell_mixer[] = {
11159 /* output mixer control */
11160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11161 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11162 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11165 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11166 { }
11167};
11168
11169static struct hda_verb alc268_dell_verbs[] = {
11170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11172 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11173 { }
11174};
11175
11176/* mute/unmute internal speaker according to the hp jack and mute state */
11177static void alc268_dell_automute(struct hda_codec *codec)
11178{
11179 unsigned int present;
11180 unsigned int mute;
11181
11182 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11183 if (present & 0x80000000)
11184 mute = HDA_AMP_MUTE;
11185 else
11186 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11187 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11188 HDA_AMP_MUTE, mute);
11189}
11190
11191static void alc268_dell_unsol_event(struct hda_codec *codec,
11192 unsigned int res)
11193{
11194 if ((res >> 26) != ALC880_HP_EVENT)
11195 return;
11196 alc268_dell_automute(codec);
11197}
11198
11199#define alc268_dell_init_hook alc268_dell_automute
11200
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011201static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11202 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11203 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11204 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11207 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11208 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11209 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11210 { }
11211};
11212
11213static struct hda_verb alc267_quanta_il1_verbs[] = {
11214 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11215 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11216 { }
11217};
11218
11219static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11220{
11221 unsigned int present;
11222
11223 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11224 & AC_PINSENSE_PRESENCE;
11225 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11226 present ? 0 : PIN_OUT);
11227}
11228
11229static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11230{
11231 unsigned int present;
11232
11233 present = snd_hda_codec_read(codec, 0x18, 0,
11234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11235 snd_hda_codec_write(codec, 0x23, 0,
11236 AC_VERB_SET_CONNECT_SEL,
11237 present ? 0x00 : 0x01);
11238}
11239
11240static void alc267_quanta_il1_automute(struct hda_codec *codec)
11241{
11242 alc267_quanta_il1_hp_automute(codec);
11243 alc267_quanta_il1_mic_automute(codec);
11244}
11245
11246static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11247 unsigned int res)
11248{
11249 switch (res >> 26) {
11250 case ALC880_HP_EVENT:
11251 alc267_quanta_il1_hp_automute(codec);
11252 break;
11253 case ALC880_MIC_EVENT:
11254 alc267_quanta_il1_mic_automute(codec);
11255 break;
11256 }
11257}
11258
Kailang Yanga361d842007-06-05 12:30:55 +020011259/*
11260 * generic initialization of ADC, input mixers and output mixers
11261 */
11262static struct hda_verb alc268_base_init_verbs[] = {
11263 /* Unmute DAC0-1 and set vol = 0 */
11264 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11265 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11266 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11269 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11270
11271 /*
11272 * Set up output mixers (0x0c - 0x0e)
11273 */
11274 /* set vol=0 to output mixers */
11275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11278 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11279
11280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11281 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11282
11283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11285 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11290 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11291
11292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11294 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11295 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11297 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11298 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011299
11300 /* set PCBEEP vol = 0, mute connections */
11301 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11303 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011304
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011305 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011306
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011307 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11309 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011311
Kailang Yanga361d842007-06-05 12:30:55 +020011312 { }
11313};
11314
11315/*
11316 * generic initialization of ADC, input mixers and output mixers
11317 */
11318static struct hda_verb alc268_volume_init_verbs[] = {
11319 /* set output DAC */
11320 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11323 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11324
11325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11328 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11329 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11330
11331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11334 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11335 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11336
11337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11338 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11340 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11341
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011342 /* set PCBEEP vol = 0, mute connections */
11343 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11344 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11345 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011346
11347 { }
11348};
11349
Kailang Yanga361d842007-06-05 12:30:55 +020011350static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11351 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11352 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11353 {
11354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11355 /* The multiple "Capture Source" controls confuse alsamixer
11356 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011357 */
11358 /* .name = "Capture Source", */
11359 .name = "Input Source",
11360 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011361 .info = alc_mux_enum_info,
11362 .get = alc_mux_enum_get,
11363 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011364 },
11365 { } /* end */
11366};
11367
11368static struct snd_kcontrol_new alc268_capture_mixer[] = {
11369 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11370 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11371 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11372 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11373 {
11374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11375 /* The multiple "Capture Source" controls confuse alsamixer
11376 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011377 */
11378 /* .name = "Capture Source", */
11379 .name = "Input Source",
11380 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011381 .info = alc_mux_enum_info,
11382 .get = alc_mux_enum_get,
11383 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011384 },
11385 { } /* end */
11386};
11387
11388static struct hda_input_mux alc268_capture_source = {
11389 .num_items = 4,
11390 .items = {
11391 { "Mic", 0x0 },
11392 { "Front Mic", 0x1 },
11393 { "Line", 0x2 },
11394 { "CD", 0x3 },
11395 },
11396};
11397
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011398static struct hda_input_mux alc268_acer_capture_source = {
11399 .num_items = 3,
11400 .items = {
11401 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011402 { "Internal Mic", 0x1 },
11403 { "Line", 0x2 },
11404 },
11405};
11406
11407static struct hda_input_mux alc268_acer_dmic_capture_source = {
11408 .num_items = 3,
11409 .items = {
11410 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011411 { "Internal Mic", 0x6 },
11412 { "Line", 0x2 },
11413 },
11414};
11415
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011416#ifdef CONFIG_SND_DEBUG
11417static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011418 /* Volume widgets */
11419 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11420 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11421 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11422 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11423 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11424 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11425 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11426 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11427 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11428 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11429 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11430 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11431 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011432 /* The below appears problematic on some hardwares */
11433 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011434 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11435 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11436 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11437 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11438
11439 /* Modes for retasking pin widgets */
11440 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11441 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11442 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11443 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11444
11445 /* Controls for GPIO pins, assuming they are configured as outputs */
11446 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11447 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11448 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11449 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11450
11451 /* Switches to allow the digital SPDIF output pin to be enabled.
11452 * The ALC268 does not have an SPDIF input.
11453 */
11454 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11455
11456 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11457 * this output to turn on an external amplifier.
11458 */
11459 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11460 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11461
11462 { } /* end */
11463};
11464#endif
11465
Kailang Yanga361d842007-06-05 12:30:55 +020011466/* create input playback/capture controls for the given pin */
11467static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11468 const char *ctlname, int idx)
11469{
11470 char name[32];
11471 int err;
11472
11473 sprintf(name, "%s Playback Volume", ctlname);
11474 if (nid == 0x14) {
11475 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11476 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11477 HDA_OUTPUT));
11478 if (err < 0)
11479 return err;
11480 } else if (nid == 0x15) {
11481 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11482 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11483 HDA_OUTPUT));
11484 if (err < 0)
11485 return err;
11486 } else
11487 return -1;
11488 sprintf(name, "%s Playback Switch", ctlname);
11489 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11490 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11491 if (err < 0)
11492 return err;
11493 return 0;
11494}
11495
11496/* add playback controls from the parsed DAC table */
11497static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11498 const struct auto_pin_cfg *cfg)
11499{
11500 hda_nid_t nid;
11501 int err;
11502
11503 spec->multiout.num_dacs = 2; /* only use one dac */
11504 spec->multiout.dac_nids = spec->private_dac_nids;
11505 spec->multiout.dac_nids[0] = 2;
11506 spec->multiout.dac_nids[1] = 3;
11507
11508 nid = cfg->line_out_pins[0];
11509 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011510 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011511
11512 nid = cfg->speaker_pins[0];
11513 if (nid == 0x1d) {
11514 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11515 "Speaker Playback Volume",
11516 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11517 if (err < 0)
11518 return err;
11519 }
11520 nid = cfg->hp_pins[0];
11521 if (nid)
11522 alc268_new_analog_output(spec, nid, "Headphone", 0);
11523
11524 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11525 if (nid == 0x16) {
11526 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11527 "Mono Playback Switch",
11528 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11529 if (err < 0)
11530 return err;
11531 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011532 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011533}
11534
11535/* create playback/capture controls for input pins */
11536static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11537 const struct auto_pin_cfg *cfg)
11538{
11539 struct hda_input_mux *imux = &spec->private_imux;
11540 int i, idx1;
11541
11542 for (i = 0; i < AUTO_PIN_LAST; i++) {
11543 switch(cfg->input_pins[i]) {
11544 case 0x18:
11545 idx1 = 0; /* Mic 1 */
11546 break;
11547 case 0x19:
11548 idx1 = 1; /* Mic 2 */
11549 break;
11550 case 0x1a:
11551 idx1 = 2; /* Line In */
11552 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011553 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011554 idx1 = 3; /* CD */
11555 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011556 case 0x12:
11557 case 0x13:
11558 idx1 = 6; /* digital mics */
11559 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011560 default:
11561 continue;
11562 }
11563 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11564 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011565 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011566 }
11567 return 0;
11568}
11569
11570static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11571{
11572 struct alc_spec *spec = codec->spec;
11573 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11574 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11575 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11576 unsigned int dac_vol1, dac_vol2;
11577
11578 if (speaker_nid) {
11579 snd_hda_codec_write(codec, speaker_nid, 0,
11580 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11581 snd_hda_codec_write(codec, 0x0f, 0,
11582 AC_VERB_SET_AMP_GAIN_MUTE,
11583 AMP_IN_UNMUTE(1));
11584 snd_hda_codec_write(codec, 0x10, 0,
11585 AC_VERB_SET_AMP_GAIN_MUTE,
11586 AMP_IN_UNMUTE(1));
11587 } else {
11588 snd_hda_codec_write(codec, 0x0f, 0,
11589 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11590 snd_hda_codec_write(codec, 0x10, 0,
11591 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11592 }
11593
11594 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011595 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011596 dac_vol2 = AMP_OUT_ZERO;
11597 else if (line_nid == 0x15)
11598 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011599 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011600 dac_vol2 = AMP_OUT_ZERO;
11601 else if (hp_nid == 0x15)
11602 dac_vol1 = AMP_OUT_ZERO;
11603 if (line_nid != 0x16 || hp_nid != 0x16 ||
11604 spec->autocfg.line_out_pins[1] != 0x16 ||
11605 spec->autocfg.line_out_pins[2] != 0x16)
11606 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11607
11608 snd_hda_codec_write(codec, 0x02, 0,
11609 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11610 snd_hda_codec_write(codec, 0x03, 0,
11611 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11612}
11613
11614/* pcm configuration: identiacal with ALC880 */
11615#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11616#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011617#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011618#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11619
11620/*
11621 * BIOS auto configuration
11622 */
11623static int alc268_parse_auto_config(struct hda_codec *codec)
11624{
11625 struct alc_spec *spec = codec->spec;
11626 int err;
11627 static hda_nid_t alc268_ignore[] = { 0 };
11628
11629 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11630 alc268_ignore);
11631 if (err < 0)
11632 return err;
11633 if (!spec->autocfg.line_outs)
11634 return 0; /* can't find valid BIOS pin config */
11635
11636 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11637 if (err < 0)
11638 return err;
11639 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11640 if (err < 0)
11641 return err;
11642
11643 spec->multiout.max_channels = 2;
11644
11645 /* digital only support output */
11646 if (spec->autocfg.dig_out_pin)
11647 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11648
Takashi Iwai603c4012008-07-30 15:01:44 +020011649 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011650 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011651
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011652 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011653 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011654
Takashi Iwaid88897e2008-10-31 15:01:37 +010011655 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011656 spec->num_mux_defs = 1;
11657 spec->input_mux = &spec->private_imux;
11658
Takashi Iwai776e1842007-08-29 15:07:11 +020011659 err = alc_auto_add_mic_boost(codec);
11660 if (err < 0)
11661 return err;
11662
Takashi Iwaie044c392008-10-27 16:56:24 +010011663 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011664 return 1;
11665}
11666
11667#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11668#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11669#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11670
11671/* init callback for auto-configuration model -- overriding the default init */
11672static void alc268_auto_init(struct hda_codec *codec)
11673{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011674 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011675 alc268_auto_init_multi_out(codec);
11676 alc268_auto_init_hp_out(codec);
11677 alc268_auto_init_mono_speaker_out(codec);
11678 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011679 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011680 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011681}
11682
11683/*
11684 * configuration and preset
11685 */
11686static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011687 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011688 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011689 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011690 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011691 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011692 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011693 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011694 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011695#ifdef CONFIG_SND_DEBUG
11696 [ALC268_TEST] = "test",
11697#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011698 [ALC268_AUTO] = "auto",
11699};
11700
11701static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011702 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011703 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011704 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011705 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011706 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011707 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11708 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011709 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011710 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011711 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011712 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011713 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011714 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011715 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011716 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011717 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011718 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011719 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011720 {}
11721};
11722
11723static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011724 [ALC267_QUANTA_IL1] = {
11725 .mixers = { alc267_quanta_il1_mixer },
11726 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11727 alc267_quanta_il1_verbs },
11728 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11729 .dac_nids = alc268_dac_nids,
11730 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11731 .adc_nids = alc268_adc_nids_alt,
11732 .hp_nid = 0x03,
11733 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11734 .channel_mode = alc268_modes,
11735 .input_mux = &alc268_capture_source,
11736 .unsol_event = alc267_quanta_il1_unsol_event,
11737 .init_hook = alc267_quanta_il1_automute,
11738 },
Kailang Yanga361d842007-06-05 12:30:55 +020011739 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011740 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11741 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011742 .init_verbs = { alc268_base_init_verbs },
11743 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11744 .dac_nids = alc268_dac_nids,
11745 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11746 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011747 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011748 .hp_nid = 0x03,
11749 .dig_out_nid = ALC268_DIGOUT_NID,
11750 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11751 .channel_mode = alc268_modes,
11752 .input_mux = &alc268_capture_source,
11753 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011754 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011755 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11756 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011757 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11758 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011759 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11760 .dac_nids = alc268_dac_nids,
11761 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11762 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011763 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011764 .hp_nid = 0x03,
11765 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11766 .channel_mode = alc268_modes,
11767 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011768 .unsol_event = alc268_toshiba_unsol_event,
11769 .init_hook = alc268_toshiba_automute,
11770 },
11771 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011772 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11773 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011774 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11775 alc268_acer_verbs },
11776 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11777 .dac_nids = alc268_dac_nids,
11778 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11779 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011780 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011781 .hp_nid = 0x02,
11782 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11783 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011784 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011785 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011786 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011787 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011788 [ALC268_ACER_DMIC] = {
11789 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11790 alc268_beep_mixer },
11791 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11792 alc268_acer_verbs },
11793 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11794 .dac_nids = alc268_dac_nids,
11795 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11796 .adc_nids = alc268_adc_nids_alt,
11797 .capsrc_nids = alc268_capsrc_nids,
11798 .hp_nid = 0x02,
11799 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11800 .channel_mode = alc268_modes,
11801 .input_mux = &alc268_acer_dmic_capture_source,
11802 .unsol_event = alc268_acer_unsol_event,
11803 .init_hook = alc268_acer_init_hook,
11804 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011805 [ALC268_ACER_ASPIRE_ONE] = {
11806 .mixers = { alc268_acer_aspire_one_mixer,
11807 alc268_capture_alt_mixer },
11808 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11809 alc268_acer_aspire_one_verbs },
11810 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11811 .dac_nids = alc268_dac_nids,
11812 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11813 .adc_nids = alc268_adc_nids_alt,
11814 .capsrc_nids = alc268_capsrc_nids,
11815 .hp_nid = 0x03,
11816 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11817 .channel_mode = alc268_modes,
11818 .input_mux = &alc268_acer_lc_capture_source,
11819 .unsol_event = alc268_acer_lc_unsol_event,
11820 .init_hook = alc268_acer_lc_init_hook,
11821 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011822 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011823 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011824 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11825 alc268_dell_verbs },
11826 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11827 .dac_nids = alc268_dac_nids,
11828 .hp_nid = 0x02,
11829 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11830 .channel_mode = alc268_modes,
11831 .unsol_event = alc268_dell_unsol_event,
11832 .init_hook = alc268_dell_init_hook,
11833 .input_mux = &alc268_capture_source,
11834 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011835 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011836 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11837 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011838 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11839 alc268_toshiba_verbs },
11840 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11841 .dac_nids = alc268_dac_nids,
11842 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11843 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011844 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011845 .hp_nid = 0x03,
11846 .dig_out_nid = ALC268_DIGOUT_NID,
11847 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11848 .channel_mode = alc268_modes,
11849 .input_mux = &alc268_capture_source,
11850 .unsol_event = alc268_toshiba_unsol_event,
11851 .init_hook = alc268_toshiba_automute
11852 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011853#ifdef CONFIG_SND_DEBUG
11854 [ALC268_TEST] = {
11855 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11857 alc268_volume_init_verbs },
11858 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11859 .dac_nids = alc268_dac_nids,
11860 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11861 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011862 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011863 .hp_nid = 0x03,
11864 .dig_out_nid = ALC268_DIGOUT_NID,
11865 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11866 .channel_mode = alc268_modes,
11867 .input_mux = &alc268_capture_source,
11868 },
11869#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011870};
11871
11872static int patch_alc268(struct hda_codec *codec)
11873{
11874 struct alc_spec *spec;
11875 int board_config;
11876 int err;
11877
11878 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11879 if (spec == NULL)
11880 return -ENOMEM;
11881
11882 codec->spec = spec;
11883
11884 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11885 alc268_models,
11886 alc268_cfg_tbl);
11887
11888 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11889 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11890 "trying auto-probe from BIOS...\n");
11891 board_config = ALC268_AUTO;
11892 }
11893
11894 if (board_config == ALC268_AUTO) {
11895 /* automatic parse from the BIOS config */
11896 err = alc268_parse_auto_config(codec);
11897 if (err < 0) {
11898 alc_free(codec);
11899 return err;
11900 } else if (!err) {
11901 printk(KERN_INFO
11902 "hda_codec: Cannot set up configuration "
11903 "from BIOS. Using base mode...\n");
11904 board_config = ALC268_3ST;
11905 }
11906 }
11907
11908 if (board_config != ALC268_AUTO)
11909 setup_preset(spec, &alc268_presets[board_config]);
11910
Kailang Yang2f893282008-05-27 12:14:47 +020011911 if (codec->vendor_id == 0x10ec0267) {
11912 spec->stream_name_analog = "ALC267 Analog";
11913 spec->stream_name_digital = "ALC267 Digital";
11914 } else {
11915 spec->stream_name_analog = "ALC268 Analog";
11916 spec->stream_name_digital = "ALC268 Digital";
11917 }
11918
Kailang Yanga361d842007-06-05 12:30:55 +020011919 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11920 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011921 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011922
Kailang Yanga361d842007-06-05 12:30:55 +020011923 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11924
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011925 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11926 /* override the amp caps for beep generator */
11927 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11928 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11929 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11930 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11931 (0 << AC_AMPCAP_MUTE_SHIFT));
11932
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011933 if (!spec->adc_nids && spec->input_mux) {
11934 /* check whether NID 0x07 is valid */
11935 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011936 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011937
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011938 /* get type */
11939 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011940 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011941 spec->adc_nids = alc268_adc_nids_alt;
11942 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011943 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011944 } else {
11945 spec->adc_nids = alc268_adc_nids;
11946 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011947 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011948 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011949 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011950 /* set default input source */
11951 for (i = 0; i < spec->num_adc_nids; i++)
11952 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11953 0, AC_VERB_SET_CONNECT_SEL,
11954 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011955 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011956
11957 spec->vmaster_nid = 0x02;
11958
Kailang Yanga361d842007-06-05 12:30:55 +020011959 codec->patch_ops = alc_patch_ops;
11960 if (board_config == ALC268_AUTO)
11961 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011962
Takashi Iwaidaead532008-11-28 12:55:36 +010011963 codec->proc_widget_hook = print_realtek_coef;
11964
Kailang Yanga361d842007-06-05 12:30:55 +020011965 return 0;
11966}
11967
11968/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011969 * ALC269 channel source setting (2 channel)
11970 */
11971#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11972
11973#define alc269_dac_nids alc260_dac_nids
11974
11975static hda_nid_t alc269_adc_nids[1] = {
11976 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011977 0x08,
11978};
11979
Takashi Iwaie01bf502008-08-21 16:25:07 +020011980static hda_nid_t alc269_capsrc_nids[1] = {
11981 0x23,
11982};
11983
11984/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11985 * not a mux!
11986 */
11987
Kailang Yangf53281e2008-07-18 12:36:43 +020011988static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11989 .num_items = 2,
11990 .items = {
11991 { "i-Mic", 0x5 },
11992 { "e-Mic", 0x0 },
11993 },
11994};
11995
11996static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11997 .num_items = 2,
11998 .items = {
11999 { "i-Mic", 0x1 },
12000 { "e-Mic", 0x0 },
12001 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012002};
12003
12004#define alc269_modes alc260_modes
12005#define alc269_capture_source alc880_lg_lw_capture_source
12006
12007static struct snd_kcontrol_new alc269_base_mixer[] = {
12008 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12009 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020012014 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12015 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010012016 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12019 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12021 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12022 { } /* end */
12023};
12024
Kailang Yang60db6b52008-08-26 13:13:00 +020012025static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12026 /* output mixer control */
12027 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12028 {
12029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12030 .name = "Master Playback Switch",
12031 .info = snd_hda_mixer_amp_switch_info,
12032 .get = snd_hda_mixer_amp_switch_get,
12033 .put = alc268_acer_master_sw_put,
12034 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12035 },
12036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12039 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12040 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12041 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12042 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12043 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12044 { }
12045};
12046
Tony Vroon64154832008-11-06 15:08:49 +000012047static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12048 /* output mixer control */
12049 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12050 {
12051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12052 .name = "Master Playback Switch",
12053 .info = snd_hda_mixer_amp_switch_info,
12054 .get = snd_hda_mixer_amp_switch_get,
12055 .put = alc268_acer_master_sw_put,
12056 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12057 },
12058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12061 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12062 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12063 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12064 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12065 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12066 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12067 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12068 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12069 { }
12070};
12071
Kailang Yangf53281e2008-07-18 12:36:43 +020012072/* bind volumes of both NID 0x0c and 0x0d */
12073static struct hda_bind_ctls alc269_epc_bind_vol = {
12074 .ops = &snd_hda_bind_vol,
12075 .values = {
12076 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12077 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12078 0
12079 },
12080};
12081
12082static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12083 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12084 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12085 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12086 { } /* end */
12087};
12088
Kailang Yangf6a92242007-12-13 16:52:54 +010012089/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012090static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12091 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12092 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12094 { } /* end */
12095};
12096
12097/* FSC amilo */
12098static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12099 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12101 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012102 { } /* end */
12103};
12104
Takashi Iwai2005af22008-08-20 18:38:26 +020012105/* beep control */
12106static struct snd_kcontrol_new alc269_beep_mixer[] = {
12107 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12108 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12109 { } /* end */
12110};
12111
Kailang Yang60db6b52008-08-26 13:13:00 +020012112static struct hda_verb alc269_quanta_fl1_verbs[] = {
12113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12114 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12116 {0x15, 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
Tony Vroon64154832008-11-06 15:08:49 +000012122static struct hda_verb alc269_lifebook_verbs[] = {
12123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12124 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12125 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12129 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12130 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12131 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12132 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12133 { }
12134};
12135
Kailang Yang60db6b52008-08-26 13:13:00 +020012136/* toggle speaker-output according to the hp-jack state */
12137static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12138{
12139 unsigned int present;
12140 unsigned char bits;
12141
12142 present = snd_hda_codec_read(codec, 0x15, 0,
12143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12144 bits = present ? AMP_IN_MUTE(0) : 0;
12145 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12146 AMP_IN_MUTE(0), bits);
12147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12148 AMP_IN_MUTE(0), bits);
12149
12150 snd_hda_codec_write(codec, 0x20, 0,
12151 AC_VERB_SET_COEF_INDEX, 0x0c);
12152 snd_hda_codec_write(codec, 0x20, 0,
12153 AC_VERB_SET_PROC_COEF, 0x680);
12154
12155 snd_hda_codec_write(codec, 0x20, 0,
12156 AC_VERB_SET_COEF_INDEX, 0x0c);
12157 snd_hda_codec_write(codec, 0x20, 0,
12158 AC_VERB_SET_PROC_COEF, 0x480);
12159}
12160
Tony Vroon64154832008-11-06 15:08:49 +000012161/* toggle speaker-output according to the hp-jacks state */
12162static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12163{
12164 unsigned int present;
12165 unsigned char bits;
12166
12167 /* Check laptop headphone socket */
12168 present = snd_hda_codec_read(codec, 0x15, 0,
12169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12170
12171 /* Check port replicator headphone socket */
12172 present |= snd_hda_codec_read(codec, 0x1a, 0,
12173 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12174
12175 bits = present ? AMP_IN_MUTE(0) : 0;
12176 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12177 AMP_IN_MUTE(0), bits);
12178 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12179 AMP_IN_MUTE(0), bits);
12180
12181 snd_hda_codec_write(codec, 0x20, 0,
12182 AC_VERB_SET_COEF_INDEX, 0x0c);
12183 snd_hda_codec_write(codec, 0x20, 0,
12184 AC_VERB_SET_PROC_COEF, 0x680);
12185
12186 snd_hda_codec_write(codec, 0x20, 0,
12187 AC_VERB_SET_COEF_INDEX, 0x0c);
12188 snd_hda_codec_write(codec, 0x20, 0,
12189 AC_VERB_SET_PROC_COEF, 0x480);
12190}
12191
Kailang Yang60db6b52008-08-26 13:13:00 +020012192static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12193{
12194 unsigned int present;
12195
12196 present = snd_hda_codec_read(codec, 0x18, 0,
12197 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12198 snd_hda_codec_write(codec, 0x23, 0,
12199 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12200}
12201
Tony Vroon64154832008-11-06 15:08:49 +000012202static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12203{
12204 unsigned int present_laptop;
12205 unsigned int present_dock;
12206
12207 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12208 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12209
12210 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12211 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12212
12213 /* Laptop mic port overrides dock mic port, design decision */
12214 if (present_dock)
12215 snd_hda_codec_write(codec, 0x23, 0,
12216 AC_VERB_SET_CONNECT_SEL, 0x3);
12217 if (present_laptop)
12218 snd_hda_codec_write(codec, 0x23, 0,
12219 AC_VERB_SET_CONNECT_SEL, 0x0);
12220 if (!present_dock && !present_laptop)
12221 snd_hda_codec_write(codec, 0x23, 0,
12222 AC_VERB_SET_CONNECT_SEL, 0x1);
12223}
12224
Kailang Yang60db6b52008-08-26 13:13:00 +020012225static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12226 unsigned int res)
12227{
12228 if ((res >> 26) == ALC880_HP_EVENT)
12229 alc269_quanta_fl1_speaker_automute(codec);
12230 if ((res >> 26) == ALC880_MIC_EVENT)
12231 alc269_quanta_fl1_mic_automute(codec);
12232}
12233
Tony Vroon64154832008-11-06 15:08:49 +000012234static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12235 unsigned int res)
12236{
12237 if ((res >> 26) == ALC880_HP_EVENT)
12238 alc269_lifebook_speaker_automute(codec);
12239 if ((res >> 26) == ALC880_MIC_EVENT)
12240 alc269_lifebook_mic_autoswitch(codec);
12241}
12242
Kailang Yang60db6b52008-08-26 13:13:00 +020012243static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12244{
12245 alc269_quanta_fl1_speaker_automute(codec);
12246 alc269_quanta_fl1_mic_automute(codec);
12247}
12248
Tony Vroon64154832008-11-06 15:08:49 +000012249static void alc269_lifebook_init_hook(struct hda_codec *codec)
12250{
12251 alc269_lifebook_speaker_automute(codec);
12252 alc269_lifebook_mic_autoswitch(codec);
12253}
12254
Kailang Yang60db6b52008-08-26 13:13:00 +020012255static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12257 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12258 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12260 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12263 {}
12264};
12265
12266static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12267 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12268 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12269 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12271 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12273 {}
12274};
12275
12276/* toggle speaker-output according to the hp-jack state */
12277static void alc269_speaker_automute(struct hda_codec *codec)
12278{
12279 unsigned int present;
12280 unsigned char bits;
12281
12282 present = snd_hda_codec_read(codec, 0x15, 0,
12283 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12284 bits = present ? AMP_IN_MUTE(0) : 0;
12285 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12286 AMP_IN_MUTE(0), bits);
12287 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12288 AMP_IN_MUTE(0), bits);
12289}
12290
12291static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12292{
12293 unsigned int present;
12294
12295 present = snd_hda_codec_read(codec, 0x18, 0,
12296 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12297 snd_hda_codec_write(codec, 0x23, 0,
12298 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12299}
12300
12301static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12302{
12303 unsigned int present;
12304
12305 present = snd_hda_codec_read(codec, 0x18, 0,
12306 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12307 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12308 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12309 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12310 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12311}
12312
12313/* unsolicited event for HP jack sensing */
12314static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12315 unsigned int res)
12316{
12317 if ((res >> 26) == ALC880_HP_EVENT)
12318 alc269_speaker_automute(codec);
12319
12320 if ((res >> 26) == ALC880_MIC_EVENT)
12321 alc269_eeepc_dmic_automute(codec);
12322}
12323
12324static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12325{
12326 alc269_speaker_automute(codec);
12327 alc269_eeepc_dmic_automute(codec);
12328}
12329
12330/* unsolicited event for HP jack sensing */
12331static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12332 unsigned int res)
12333{
12334 if ((res >> 26) == ALC880_HP_EVENT)
12335 alc269_speaker_automute(codec);
12336
12337 if ((res >> 26) == ALC880_MIC_EVENT)
12338 alc269_eeepc_amic_automute(codec);
12339}
12340
12341static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12342{
12343 alc269_speaker_automute(codec);
12344 alc269_eeepc_amic_automute(codec);
12345}
12346
Kailang Yangf6a92242007-12-13 16:52:54 +010012347/*
12348 * generic initialization of ADC, input mixers and output mixers
12349 */
12350static struct hda_verb alc269_init_verbs[] = {
12351 /*
12352 * Unmute ADC0 and set the default input to mic-in
12353 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012355
12356 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12357 * analog-loopback mixer widget
12358 * Note: PASD motherboards uses the Line In 2 as the input for
12359 * front panel mic (mic 2)
12360 */
12361 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12367
12368 /*
12369 * Set up output mixers (0x0c - 0x0e)
12370 */
12371 /* set vol=0 to output mixers */
12372 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12373 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12374
12375 /* set up input amps for analog loopback */
12376 /* Amp Indices: DAC = 0, mixer = 1 */
12377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12383
12384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12386 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12389 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12390 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12391
12392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12398 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12399
12400 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12401 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12402
12403 /* FIXME: use matrix-type input source selection */
12404 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12405 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12410
12411 /* set EAPD */
12412 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12413 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12414 { }
12415};
12416
12417/* add playback controls from the parsed DAC table */
12418static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12419 const struct auto_pin_cfg *cfg)
12420{
12421 hda_nid_t nid;
12422 int err;
12423
12424 spec->multiout.num_dacs = 1; /* only use one dac */
12425 spec->multiout.dac_nids = spec->private_dac_nids;
12426 spec->multiout.dac_nids[0] = 2;
12427
12428 nid = cfg->line_out_pins[0];
12429 if (nid) {
12430 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12431 "Front Playback Volume",
12432 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12433 if (err < 0)
12434 return err;
12435 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12436 "Front Playback Switch",
12437 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12438 if (err < 0)
12439 return err;
12440 }
12441
12442 nid = cfg->speaker_pins[0];
12443 if (nid) {
12444 if (!cfg->line_out_pins[0]) {
12445 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12446 "Speaker Playback Volume",
12447 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12448 HDA_OUTPUT));
12449 if (err < 0)
12450 return err;
12451 }
12452 if (nid == 0x16) {
12453 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12454 "Speaker Playback Switch",
12455 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12456 HDA_OUTPUT));
12457 if (err < 0)
12458 return err;
12459 } else {
12460 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12461 "Speaker Playback Switch",
12462 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12463 HDA_OUTPUT));
12464 if (err < 0)
12465 return err;
12466 }
12467 }
12468 nid = cfg->hp_pins[0];
12469 if (nid) {
12470 /* spec->multiout.hp_nid = 2; */
12471 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12472 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12473 "Headphone Playback Volume",
12474 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12475 HDA_OUTPUT));
12476 if (err < 0)
12477 return err;
12478 }
12479 if (nid == 0x16) {
12480 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12481 "Headphone Playback Switch",
12482 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12483 HDA_OUTPUT));
12484 if (err < 0)
12485 return err;
12486 } else {
12487 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12488 "Headphone Playback Switch",
12489 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12490 HDA_OUTPUT));
12491 if (err < 0)
12492 return err;
12493 }
12494 }
12495 return 0;
12496}
12497
Takashi Iwaiee956e02008-10-31 17:16:31 +010012498static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12499 const struct auto_pin_cfg *cfg)
12500{
12501 int err;
12502
12503 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12504 if (err < 0)
12505 return err;
12506 /* digital-mic input pin is excluded in alc880_auto_create..()
12507 * because it's under 0x18
12508 */
12509 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12510 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12511 struct hda_input_mux *imux = &spec->private_imux;
12512 imux->items[imux->num_items].label = "Int Mic";
12513 imux->items[imux->num_items].index = 0x05;
12514 imux->num_items++;
12515 }
12516 return 0;
12517}
Kailang Yangf6a92242007-12-13 16:52:54 +010012518
12519#ifdef CONFIG_SND_HDA_POWER_SAVE
12520#define alc269_loopbacks alc880_loopbacks
12521#endif
12522
12523/* pcm configuration: identiacal with ALC880 */
12524#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12525#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12526#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12527#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12528
12529/*
12530 * BIOS auto configuration
12531 */
12532static int alc269_parse_auto_config(struct hda_codec *codec)
12533{
12534 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012535 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012536 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12537
12538 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12539 alc269_ignore);
12540 if (err < 0)
12541 return err;
12542
12543 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12544 if (err < 0)
12545 return err;
12546 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12547 if (err < 0)
12548 return err;
12549
12550 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12551
12552 if (spec->autocfg.dig_out_pin)
12553 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12554
Takashi Iwai603c4012008-07-30 15:01:44 +020012555 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012556 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012557
Takashi Iwai2005af22008-08-20 18:38:26 +020012558 /* create a beep mixer control if the pin 0x1d isn't assigned */
12559 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12560 if (spec->autocfg.input_pins[i] == 0x1d)
12561 break;
12562 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012563 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012564
Takashi Iwaid88897e2008-10-31 15:01:37 +010012565 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012566 spec->num_mux_defs = 1;
12567 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012568 /* set default input source */
12569 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12570 0, AC_VERB_SET_CONNECT_SEL,
12571 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012572
12573 err = alc_auto_add_mic_boost(codec);
12574 if (err < 0)
12575 return err;
12576
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012577 if (!spec->cap_mixer)
12578 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012579
Takashi Iwaie044c392008-10-27 16:56:24 +010012580 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012581 return 1;
12582}
12583
12584#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12585#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12586#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12587
12588
12589/* init callback for auto-configuration model -- overriding the default init */
12590static void alc269_auto_init(struct hda_codec *codec)
12591{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012592 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012593 alc269_auto_init_multi_out(codec);
12594 alc269_auto_init_hp_out(codec);
12595 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012596 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012597 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012598}
12599
12600/*
12601 * configuration and preset
12602 */
12603static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012604 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012605 [ALC269_QUANTA_FL1] = "quanta",
12606 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012607 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012608 [ALC269_FUJITSU] = "fujitsu",
12609 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012610};
12611
12612static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012613 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012614 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12615 ALC269_ASUS_EEEPC_P703),
12616 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12617 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012618 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12619 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012620 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012621 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012622 {}
12623};
12624
12625static struct alc_config_preset alc269_presets[] = {
12626 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012627 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012628 .init_verbs = { alc269_init_verbs },
12629 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12630 .dac_nids = alc269_dac_nids,
12631 .hp_nid = 0x03,
12632 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12633 .channel_mode = alc269_modes,
12634 .input_mux = &alc269_capture_source,
12635 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012636 [ALC269_QUANTA_FL1] = {
12637 .mixers = { alc269_quanta_fl1_mixer },
12638 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_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_capture_source,
12645 .unsol_event = alc269_quanta_fl1_unsol_event,
12646 .init_hook = alc269_quanta_fl1_init_hook,
12647 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012648 [ALC269_ASUS_EEEPC_P703] = {
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_amic_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_amic_capture_source,
12659 .unsol_event = alc269_eeepc_amic_unsol_event,
12660 .init_hook = alc269_eeepc_amic_inithook,
12661 },
12662 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012663 .mixers = { alc269_eeepc_mixer },
12664 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012665 .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 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012676 [ALC269_FUJITSU] = {
12677 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12678 .cap_mixer = alc269_epc_capture_mixer,
12679 .init_verbs = { alc269_init_verbs,
12680 alc269_eeepc_dmic_init_verbs },
12681 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12682 .dac_nids = alc269_dac_nids,
12683 .hp_nid = 0x03,
12684 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12685 .channel_mode = alc269_modes,
12686 .input_mux = &alc269_eeepc_dmic_capture_source,
12687 .unsol_event = alc269_eeepc_dmic_unsol_event,
12688 .init_hook = alc269_eeepc_dmic_inithook,
12689 },
Tony Vroon64154832008-11-06 15:08:49 +000012690 [ALC269_LIFEBOOK] = {
12691 .mixers = { alc269_lifebook_mixer },
12692 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12693 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12694 .dac_nids = alc269_dac_nids,
12695 .hp_nid = 0x03,
12696 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12697 .channel_mode = alc269_modes,
12698 .input_mux = &alc269_capture_source,
12699 .unsol_event = alc269_lifebook_unsol_event,
12700 .init_hook = alc269_lifebook_init_hook,
12701 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012702};
12703
12704static int patch_alc269(struct hda_codec *codec)
12705{
12706 struct alc_spec *spec;
12707 int board_config;
12708 int err;
12709
12710 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12711 if (spec == NULL)
12712 return -ENOMEM;
12713
12714 codec->spec = spec;
12715
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012716 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12717
Kailang Yangf6a92242007-12-13 16:52:54 +010012718 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12719 alc269_models,
12720 alc269_cfg_tbl);
12721
12722 if (board_config < 0) {
12723 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12724 "trying auto-probe from BIOS...\n");
12725 board_config = ALC269_AUTO;
12726 }
12727
12728 if (board_config == ALC269_AUTO) {
12729 /* automatic parse from the BIOS config */
12730 err = alc269_parse_auto_config(codec);
12731 if (err < 0) {
12732 alc_free(codec);
12733 return err;
12734 } else if (!err) {
12735 printk(KERN_INFO
12736 "hda_codec: Cannot set up configuration "
12737 "from BIOS. Using base mode...\n");
12738 board_config = ALC269_BASIC;
12739 }
12740 }
12741
12742 if (board_config != ALC269_AUTO)
12743 setup_preset(spec, &alc269_presets[board_config]);
12744
12745 spec->stream_name_analog = "ALC269 Analog";
12746 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12747 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12748
12749 spec->stream_name_digital = "ALC269 Digital";
12750 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12751 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12752
12753 spec->adc_nids = alc269_adc_nids;
12754 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012755 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012756 if (!spec->cap_mixer)
12757 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012758
12759 codec->patch_ops = alc_patch_ops;
12760 if (board_config == ALC269_AUTO)
12761 spec->init_hook = alc269_auto_init;
12762#ifdef CONFIG_SND_HDA_POWER_SAVE
12763 if (!spec->loopback.amplist)
12764 spec->loopback.amplist = alc269_loopbacks;
12765#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012766 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012767
12768 return 0;
12769}
12770
12771/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012772 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12773 */
12774
12775/*
12776 * set the path ways for 2 channel output
12777 * need to set the codec line out and mic 1 pin widgets to inputs
12778 */
12779static struct hda_verb alc861_threestack_ch2_init[] = {
12780 /* set pin widget 1Ah (line in) for input */
12781 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012782 /* set pin widget 18h (mic1/2) for input, for mic also enable
12783 * the vref
12784 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012785 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12786
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012787 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12788#if 0
12789 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12790 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12791#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012792 { } /* end */
12793};
12794/*
12795 * 6ch mode
12796 * need to set the codec line out and mic 1 pin widgets to outputs
12797 */
12798static struct hda_verb alc861_threestack_ch6_init[] = {
12799 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12800 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12801 /* set pin widget 18h (mic1) for output (CLFE)*/
12802 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12803
12804 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012805 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012806
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012807 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12808#if 0
12809 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12810 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12811#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012812 { } /* end */
12813};
12814
12815static struct hda_channel_mode alc861_threestack_modes[2] = {
12816 { 2, alc861_threestack_ch2_init },
12817 { 6, alc861_threestack_ch6_init },
12818};
Takashi Iwai22309c32006-08-09 16:57:28 +020012819/* Set mic1 as input and unmute the mixer */
12820static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12821 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12822 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12823 { } /* end */
12824};
12825/* Set mic1 as output and mute mixer */
12826static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12827 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12828 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12829 { } /* end */
12830};
12831
12832static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12833 { 2, alc861_uniwill_m31_ch2_init },
12834 { 4, alc861_uniwill_m31_ch4_init },
12835};
Kailang Yangdf694da2005-12-05 19:42:22 +010012836
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012837/* Set mic1 and line-in as input and unmute the mixer */
12838static struct hda_verb alc861_asus_ch2_init[] = {
12839 /* set pin widget 1Ah (line in) for input */
12840 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012841 /* set pin widget 18h (mic1/2) for input, for mic also enable
12842 * the vref
12843 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012844 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12845
12846 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12847#if 0
12848 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12849 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12850#endif
12851 { } /* end */
12852};
12853/* Set mic1 nad line-in as output and mute mixer */
12854static struct hda_verb alc861_asus_ch6_init[] = {
12855 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12856 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12857 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12858 /* set pin widget 18h (mic1) for output (CLFE)*/
12859 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12860 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12861 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12862 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12863
12864 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12865#if 0
12866 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12867 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12868#endif
12869 { } /* end */
12870};
12871
12872static struct hda_channel_mode alc861_asus_modes[2] = {
12873 { 2, alc861_asus_ch2_init },
12874 { 6, alc861_asus_ch6_init },
12875};
12876
Kailang Yangdf694da2005-12-05 19:42:22 +010012877/* patch-ALC861 */
12878
12879static struct snd_kcontrol_new alc861_base_mixer[] = {
12880 /* output mixer control */
12881 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12882 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12883 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12884 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12885 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12886
12887 /*Input mixer control */
12888 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12889 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12890 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12891 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12892 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12893 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12895 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012898
Kailang Yangdf694da2005-12-05 19:42:22 +010012899 { } /* end */
12900};
12901
12902static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12903 /* output mixer control */
12904 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12905 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12907 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12908 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12909
12910 /* Input mixer control */
12911 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12912 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12913 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12914 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12915 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12916 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012921
Kailang Yangdf694da2005-12-05 19:42:22 +010012922 {
12923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12924 .name = "Channel Mode",
12925 .info = alc_ch_mode_info,
12926 .get = alc_ch_mode_get,
12927 .put = alc_ch_mode_put,
12928 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12929 },
12930 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012931};
12932
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012933static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012934 /* output mixer control */
12935 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12937 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012938
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012939 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012940};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012941
Takashi Iwai22309c32006-08-09 16:57:28 +020012942static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12943 /* output mixer control */
12944 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12945 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12947 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12948 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12949
12950 /* Input mixer control */
12951 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12952 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12953 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12954 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12955 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12956 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12958 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012961
Takashi Iwai22309c32006-08-09 16:57:28 +020012962 {
12963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12964 .name = "Channel Mode",
12965 .info = alc_ch_mode_info,
12966 .get = alc_ch_mode_get,
12967 .put = alc_ch_mode_put,
12968 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12969 },
12970 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012971};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012972
12973static struct snd_kcontrol_new alc861_asus_mixer[] = {
12974 /* output mixer control */
12975 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12976 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12977 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12978 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12979 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12980
12981 /* Input mixer control */
12982 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12983 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12984 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12985 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12986 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12987 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12989 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12992
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012993 {
12994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12995 .name = "Channel Mode",
12996 .info = alc_ch_mode_info,
12997 .get = alc_ch_mode_get,
12998 .put = alc_ch_mode_put,
12999 .private_value = ARRAY_SIZE(alc861_asus_modes),
13000 },
13001 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013002};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013003
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013004/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013005static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013006 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13007 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13008 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
13009 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
13010 { }
13011};
13012
Kailang Yangdf694da2005-12-05 19:42:22 +010013013/*
13014 * generic initialization of ADC, input mixers and output mixers
13015 */
13016static struct hda_verb alc861_base_init_verbs[] = {
13017 /*
13018 * Unmute ADC0 and set the default input to mic-in
13019 */
13020 /* port-A for surround (rear panel) */
13021 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13022 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13023 /* port-B for mic-in (rear panel) with vref */
13024 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13025 /* port-C for line-in (rear panel) */
13026 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13027 /* port-D for Front */
13028 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13029 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13030 /* port-E for HP out (front panel) */
13031 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13032 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013033 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013034 /* port-F for mic-in (front panel) with vref */
13035 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13036 /* port-G for CLFE (rear panel) */
13037 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13038 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13039 /* port-H for side (rear panel) */
13040 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13041 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13042 /* CD-in */
13043 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13044 /* route front mic to ADC1*/
13045 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13046 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013047
Kailang Yangdf694da2005-12-05 19:42:22 +010013048 /* Unmute DAC0~3 & spdif out*/
13049 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13050 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13051 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13052 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013054
Kailang Yangdf694da2005-12-05 19:42:22 +010013055 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13056 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13057 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13058 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13059 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013060
Kailang Yangdf694da2005-12-05 19:42:22 +010013061 /* Unmute Stereo Mixer 15 */
13062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013066
13067 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13069 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13071 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13072 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013075 /* hp used DAC 3 (Front) */
13076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13078
13079 { }
13080};
13081
13082static struct hda_verb alc861_threestack_init_verbs[] = {
13083 /*
13084 * Unmute ADC0 and set the default input to mic-in
13085 */
13086 /* port-A for surround (rear panel) */
13087 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13088 /* port-B for mic-in (rear panel) with vref */
13089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13090 /* port-C for line-in (rear panel) */
13091 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13092 /* port-D for Front */
13093 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13094 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13095 /* port-E for HP out (front panel) */
13096 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13097 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013098 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013099 /* port-F for mic-in (front panel) with vref */
13100 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13101 /* port-G for CLFE (rear panel) */
13102 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13103 /* port-H for side (rear panel) */
13104 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13105 /* CD-in */
13106 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13107 /* route front mic to ADC1*/
13108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13110 /* Unmute DAC0~3 & spdif out*/
13111 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13112 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13114 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013116
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13118 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13119 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13120 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13121 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013122
Kailang Yangdf694da2005-12-05 19:42:22 +010013123 /* Unmute Stereo Mixer 15 */
13124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013128
13129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013137 /* hp used DAC 3 (Front) */
13138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13140 { }
13141};
Takashi Iwai22309c32006-08-09 16:57:28 +020013142
13143static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13144 /*
13145 * Unmute ADC0 and set the default input to mic-in
13146 */
13147 /* port-A for surround (rear panel) */
13148 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13149 /* port-B for mic-in (rear panel) with vref */
13150 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13151 /* port-C for line-in (rear panel) */
13152 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13153 /* port-D for Front */
13154 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13155 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13156 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013157 /* this has to be set to VREF80 */
13158 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013159 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013160 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013161 /* port-F for mic-in (front panel) with vref */
13162 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13163 /* port-G for CLFE (rear panel) */
13164 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13165 /* port-H for side (rear panel) */
13166 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13167 /* CD-in */
13168 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13169 /* route front mic to ADC1*/
13170 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13171 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13172 /* Unmute DAC0~3 & spdif out*/
13173 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13174 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13176 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013178
Takashi Iwai22309c32006-08-09 16:57:28 +020013179 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13180 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13181 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13182 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13183 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013184
Takashi Iwai22309c32006-08-09 16:57:28 +020013185 /* Unmute Stereo Mixer 15 */
13186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013190
13191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13192 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13194 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13196 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013199 /* hp used DAC 3 (Front) */
13200 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13202 { }
13203};
13204
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013205static struct hda_verb alc861_asus_init_verbs[] = {
13206 /*
13207 * Unmute ADC0 and set the default input to mic-in
13208 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013209 /* port-A for surround (rear panel)
13210 * according to codec#0 this is the HP jack
13211 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013212 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13213 /* route front PCM to HP */
13214 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13215 /* port-B for mic-in (rear panel) with vref */
13216 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13217 /* port-C for line-in (rear panel) */
13218 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13219 /* port-D for Front */
13220 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13221 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13222 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013223 /* this has to be set to VREF80 */
13224 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013225 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013226 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013227 /* port-F for mic-in (front panel) with vref */
13228 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13229 /* port-G for CLFE (rear panel) */
13230 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13231 /* port-H for side (rear panel) */
13232 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13233 /* CD-in */
13234 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13235 /* route front mic to ADC1*/
13236 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13238 /* Unmute DAC0~3 & spdif out*/
13239 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13240 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13242 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13244 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13245 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13246 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13247 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13248 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013249
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013250 /* Unmute Stereo Mixer 15 */
13251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013255
13256 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13258 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13262 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013264 /* hp used DAC 3 (Front) */
13265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13267 { }
13268};
13269
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013270/* additional init verbs for ASUS laptops */
13271static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13272 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13273 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13274 { }
13275};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013276
Kailang Yangdf694da2005-12-05 19:42:22 +010013277/*
13278 * generic initialization of ADC, input mixers and output mixers
13279 */
13280static struct hda_verb alc861_auto_init_verbs[] = {
13281 /*
13282 * Unmute ADC0 and set the default input to mic-in
13283 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013284 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013286
Kailang Yangdf694da2005-12-05 19:42:22 +010013287 /* Unmute DAC0~3 & spdif out*/
13288 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13289 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13290 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13291 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013293
Kailang Yangdf694da2005-12-05 19:42:22 +010013294 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13295 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13296 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13297 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13298 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013299
Kailang Yangdf694da2005-12-05 19:42:22 +010013300 /* Unmute Stereo Mixer 15 */
13301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13305
13306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13308 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13313 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13314
13315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013317 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013319 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013323
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013325
13326 { }
13327};
13328
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013329static struct hda_verb alc861_toshiba_init_verbs[] = {
13330 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013331
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013332 { }
13333};
13334
13335/* toggle speaker-output according to the hp-jack state */
13336static void alc861_toshiba_automute(struct hda_codec *codec)
13337{
13338 unsigned int present;
13339
13340 present = snd_hda_codec_read(codec, 0x0f, 0,
13341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013342 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13343 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13344 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13345 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013346}
13347
13348static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13349 unsigned int res)
13350{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013351 if ((res >> 26) == ALC880_HP_EVENT)
13352 alc861_toshiba_automute(codec);
13353}
13354
Kailang Yangdf694da2005-12-05 19:42:22 +010013355/* pcm configuration: identiacal with ALC880 */
13356#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13357#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13358#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13359#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13360
13361
13362#define ALC861_DIGOUT_NID 0x07
13363
13364static struct hda_channel_mode alc861_8ch_modes[1] = {
13365 { 8, NULL }
13366};
13367
13368static hda_nid_t alc861_dac_nids[4] = {
13369 /* front, surround, clfe, side */
13370 0x03, 0x06, 0x05, 0x04
13371};
13372
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013373static hda_nid_t alc660_dac_nids[3] = {
13374 /* front, clfe, surround */
13375 0x03, 0x05, 0x06
13376};
13377
Kailang Yangdf694da2005-12-05 19:42:22 +010013378static hda_nid_t alc861_adc_nids[1] = {
13379 /* ADC0-2 */
13380 0x08,
13381};
13382
13383static struct hda_input_mux alc861_capture_source = {
13384 .num_items = 5,
13385 .items = {
13386 { "Mic", 0x0 },
13387 { "Front Mic", 0x3 },
13388 { "Line", 0x1 },
13389 { "CD", 0x4 },
13390 { "Mixer", 0x5 },
13391 },
13392};
13393
13394/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013395static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13396 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013397{
13398 int i;
13399 hda_nid_t nid;
13400
13401 spec->multiout.dac_nids = spec->private_dac_nids;
13402 for (i = 0; i < cfg->line_outs; i++) {
13403 nid = cfg->line_out_pins[i];
13404 if (nid) {
13405 if (i >= ARRAY_SIZE(alc861_dac_nids))
13406 continue;
13407 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13408 }
13409 }
13410 spec->multiout.num_dacs = cfg->line_outs;
13411 return 0;
13412}
13413
13414/* add playback controls from the parsed DAC table */
13415static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13416 const struct auto_pin_cfg *cfg)
13417{
13418 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013419 static const char *chname[4] = {
13420 "Front", "Surround", NULL /*CLFE*/, "Side"
13421 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013422 hda_nid_t nid;
13423 int i, idx, err;
13424
13425 for (i = 0; i < cfg->line_outs; i++) {
13426 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013427 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013428 continue;
13429 if (nid == 0x05) {
13430 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013431 err = add_control(spec, ALC_CTL_BIND_MUTE,
13432 "Center Playback Switch",
13433 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13434 HDA_OUTPUT));
13435 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013436 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013437 err = add_control(spec, ALC_CTL_BIND_MUTE,
13438 "LFE Playback Switch",
13439 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13440 HDA_OUTPUT));
13441 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013442 return err;
13443 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013444 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13445 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013446 if (nid == alc861_dac_nids[idx])
13447 break;
13448 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013449 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13450 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13451 HDA_OUTPUT));
13452 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013453 return err;
13454 }
13455 }
13456 return 0;
13457}
13458
13459static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13460{
13461 int err;
13462 hda_nid_t nid;
13463
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013464 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013465 return 0;
13466
13467 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13468 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013469 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13470 "Headphone Playback Switch",
13471 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13472 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013473 return err;
13474 spec->multiout.hp_nid = nid;
13475 }
13476 return 0;
13477}
13478
13479/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013480static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13481 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013482{
Kailang Yangdf694da2005-12-05 19:42:22 +010013483 struct hda_input_mux *imux = &spec->private_imux;
13484 int i, err, idx, idx1;
13485
13486 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013487 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 case 0x0c:
13489 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013490 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013491 break;
13492 case 0x0f:
13493 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013494 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013495 break;
13496 case 0x0d:
13497 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013498 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013499 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013500 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013501 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013502 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013503 break;
13504 case 0x11:
13505 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013506 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013507 break;
13508 default:
13509 continue;
13510 }
13511
Takashi Iwai4a471b72005-12-07 13:56:29 +010013512 err = new_analog_input(spec, cfg->input_pins[i],
13513 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013514 if (err < 0)
13515 return err;
13516
Takashi Iwai4a471b72005-12-07 13:56:29 +010013517 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013518 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013519 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013520 }
13521 return 0;
13522}
13523
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013524static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13525 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013526 int pin_type, int dac_idx)
13527{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013528 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13529 pin_type);
13530 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13531 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013532}
13533
13534static void alc861_auto_init_multi_out(struct hda_codec *codec)
13535{
13536 struct alc_spec *spec = codec->spec;
13537 int i;
13538
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013539 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013540 for (i = 0; i < spec->autocfg.line_outs; i++) {
13541 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013542 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013543 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013544 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013545 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013546 }
13547}
13548
13549static void alc861_auto_init_hp_out(struct hda_codec *codec)
13550{
13551 struct alc_spec *spec = codec->spec;
13552 hda_nid_t pin;
13553
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013554 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013555 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013556 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13557 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013558 pin = spec->autocfg.speaker_pins[0];
13559 if (pin)
13560 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013561}
13562
13563static void alc861_auto_init_analog_input(struct hda_codec *codec)
13564{
13565 struct alc_spec *spec = codec->spec;
13566 int i;
13567
13568 for (i = 0; i < AUTO_PIN_LAST; i++) {
13569 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013570 if (nid >= 0x0c && nid <= 0x11) {
13571 snd_hda_codec_write(codec, nid, 0,
13572 AC_VERB_SET_PIN_WIDGET_CONTROL,
13573 i <= AUTO_PIN_FRONT_MIC ?
13574 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013575 }
13576 }
13577}
13578
13579/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013580/* return 1 if successful, 0 if the proper config is not found,
13581 * or a negative error code
13582 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013583static int alc861_parse_auto_config(struct hda_codec *codec)
13584{
13585 struct alc_spec *spec = codec->spec;
13586 int err;
13587 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013589 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13590 alc861_ignore);
13591 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013592 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013593 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013594 return 0; /* can't find valid BIOS pin config */
13595
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013596 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13597 if (err < 0)
13598 return err;
13599 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13600 if (err < 0)
13601 return err;
13602 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13603 if (err < 0)
13604 return err;
13605 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13606 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013607 return err;
13608
13609 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13610
13611 if (spec->autocfg.dig_out_pin)
13612 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13613
Takashi Iwai603c4012008-07-30 15:01:44 +020013614 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013615 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013616
Takashi Iwaid88897e2008-10-31 15:01:37 +010013617 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013618
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013619 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013620 spec->input_mux = &spec->private_imux;
13621
13622 spec->adc_nids = alc861_adc_nids;
13623 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013624 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013625
Takashi Iwaie044c392008-10-27 16:56:24 +010013626 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013627 return 1;
13628}
13629
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013630/* additional initialization for auto-configuration model */
13631static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013632{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013633 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013634 alc861_auto_init_multi_out(codec);
13635 alc861_auto_init_hp_out(codec);
13636 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013637 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013638 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013639}
13640
Takashi Iwaicb53c622007-08-10 17:21:45 +020013641#ifdef CONFIG_SND_HDA_POWER_SAVE
13642static struct hda_amp_list alc861_loopbacks[] = {
13643 { 0x15, HDA_INPUT, 0 },
13644 { 0x15, HDA_INPUT, 1 },
13645 { 0x15, HDA_INPUT, 2 },
13646 { 0x15, HDA_INPUT, 3 },
13647 { } /* end */
13648};
13649#endif
13650
Kailang Yangdf694da2005-12-05 19:42:22 +010013651
13652/*
13653 * configuration and preset
13654 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013655static const char *alc861_models[ALC861_MODEL_LAST] = {
13656 [ALC861_3ST] = "3stack",
13657 [ALC660_3ST] = "3stack-660",
13658 [ALC861_3ST_DIG] = "3stack-dig",
13659 [ALC861_6ST_DIG] = "6stack-dig",
13660 [ALC861_UNIWILL_M31] = "uniwill-m31",
13661 [ALC861_TOSHIBA] = "toshiba",
13662 [ALC861_ASUS] = "asus",
13663 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13664 [ALC861_AUTO] = "auto",
13665};
13666
13667static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013668 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013669 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13670 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13671 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013672 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013673 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013674 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013675 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13676 * Any other models that need this preset?
13677 */
13678 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013679 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13680 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013681 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13682 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13683 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13684 /* FIXME: the below seems conflict */
13685 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13686 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13687 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013688 {}
13689};
13690
13691static struct alc_config_preset alc861_presets[] = {
13692 [ALC861_3ST] = {
13693 .mixers = { alc861_3ST_mixer },
13694 .init_verbs = { alc861_threestack_init_verbs },
13695 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13696 .dac_nids = alc861_dac_nids,
13697 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13698 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013699 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13701 .adc_nids = alc861_adc_nids,
13702 .input_mux = &alc861_capture_source,
13703 },
13704 [ALC861_3ST_DIG] = {
13705 .mixers = { alc861_base_mixer },
13706 .init_verbs = { alc861_threestack_init_verbs },
13707 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13708 .dac_nids = alc861_dac_nids,
13709 .dig_out_nid = ALC861_DIGOUT_NID,
13710 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13711 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013712 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013713 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13714 .adc_nids = alc861_adc_nids,
13715 .input_mux = &alc861_capture_source,
13716 },
13717 [ALC861_6ST_DIG] = {
13718 .mixers = { alc861_base_mixer },
13719 .init_verbs = { alc861_base_init_verbs },
13720 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13721 .dac_nids = alc861_dac_nids,
13722 .dig_out_nid = ALC861_DIGOUT_NID,
13723 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13724 .channel_mode = alc861_8ch_modes,
13725 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13726 .adc_nids = alc861_adc_nids,
13727 .input_mux = &alc861_capture_source,
13728 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013729 [ALC660_3ST] = {
13730 .mixers = { alc861_3ST_mixer },
13731 .init_verbs = { alc861_threestack_init_verbs },
13732 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13733 .dac_nids = alc660_dac_nids,
13734 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13735 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013736 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013737 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13738 .adc_nids = alc861_adc_nids,
13739 .input_mux = &alc861_capture_source,
13740 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013741 [ALC861_UNIWILL_M31] = {
13742 .mixers = { alc861_uniwill_m31_mixer },
13743 .init_verbs = { alc861_uniwill_m31_init_verbs },
13744 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13745 .dac_nids = alc861_dac_nids,
13746 .dig_out_nid = ALC861_DIGOUT_NID,
13747 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13748 .channel_mode = alc861_uniwill_m31_modes,
13749 .need_dac_fix = 1,
13750 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13751 .adc_nids = alc861_adc_nids,
13752 .input_mux = &alc861_capture_source,
13753 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013754 [ALC861_TOSHIBA] = {
13755 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013756 .init_verbs = { alc861_base_init_verbs,
13757 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013758 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13759 .dac_nids = alc861_dac_nids,
13760 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13761 .channel_mode = alc883_3ST_2ch_modes,
13762 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13763 .adc_nids = alc861_adc_nids,
13764 .input_mux = &alc861_capture_source,
13765 .unsol_event = alc861_toshiba_unsol_event,
13766 .init_hook = alc861_toshiba_automute,
13767 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013768 [ALC861_ASUS] = {
13769 .mixers = { alc861_asus_mixer },
13770 .init_verbs = { alc861_asus_init_verbs },
13771 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13772 .dac_nids = alc861_dac_nids,
13773 .dig_out_nid = ALC861_DIGOUT_NID,
13774 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13775 .channel_mode = alc861_asus_modes,
13776 .need_dac_fix = 1,
13777 .hp_nid = 0x06,
13778 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13779 .adc_nids = alc861_adc_nids,
13780 .input_mux = &alc861_capture_source,
13781 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013782 [ALC861_ASUS_LAPTOP] = {
13783 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13784 .init_verbs = { alc861_asus_init_verbs,
13785 alc861_asus_laptop_init_verbs },
13786 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13787 .dac_nids = alc861_dac_nids,
13788 .dig_out_nid = ALC861_DIGOUT_NID,
13789 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13790 .channel_mode = alc883_3ST_2ch_modes,
13791 .need_dac_fix = 1,
13792 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13793 .adc_nids = alc861_adc_nids,
13794 .input_mux = &alc861_capture_source,
13795 },
13796};
Kailang Yangdf694da2005-12-05 19:42:22 +010013797
13798
13799static int patch_alc861(struct hda_codec *codec)
13800{
13801 struct alc_spec *spec;
13802 int board_config;
13803 int err;
13804
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013805 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013806 if (spec == NULL)
13807 return -ENOMEM;
13808
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013809 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013810
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013811 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13812 alc861_models,
13813 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013814
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013815 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013816 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13817 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 board_config = ALC861_AUTO;
13819 }
13820
13821 if (board_config == ALC861_AUTO) {
13822 /* automatic parse from the BIOS config */
13823 err = alc861_parse_auto_config(codec);
13824 if (err < 0) {
13825 alc_free(codec);
13826 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013827 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013828 printk(KERN_INFO
13829 "hda_codec: Cannot set up configuration "
13830 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013831 board_config = ALC861_3ST_DIG;
13832 }
13833 }
13834
13835 if (board_config != ALC861_AUTO)
13836 setup_preset(spec, &alc861_presets[board_config]);
13837
13838 spec->stream_name_analog = "ALC861 Analog";
13839 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13840 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13841
13842 spec->stream_name_digital = "ALC861 Digital";
13843 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13844 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13845
Takashi Iwai2134ea42008-01-10 16:53:55 +010013846 spec->vmaster_nid = 0x03;
13847
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 codec->patch_ops = alc_patch_ops;
13849 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013850 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013851#ifdef CONFIG_SND_HDA_POWER_SAVE
13852 if (!spec->loopback.amplist)
13853 spec->loopback.amplist = alc861_loopbacks;
13854#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013855 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020013856
Kailang Yangdf694da2005-12-05 19:42:22 +010013857 return 0;
13858}
13859
13860/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013861 * ALC861-VD support
13862 *
13863 * Based on ALC882
13864 *
13865 * In addition, an independent DAC
13866 */
13867#define ALC861VD_DIGOUT_NID 0x06
13868
13869static hda_nid_t alc861vd_dac_nids[4] = {
13870 /* front, surr, clfe, side surr */
13871 0x02, 0x03, 0x04, 0x05
13872};
13873
13874/* dac_nids for ALC660vd are in a different order - according to
13875 * Realtek's driver.
13876 * This should probably tesult in a different mixer for 6stack models
13877 * of ALC660vd codecs, but for now there is only 3stack mixer
13878 * - and it is the same as in 861vd.
13879 * adc_nids in ALC660vd are (is) the same as in 861vd
13880 */
13881static hda_nid_t alc660vd_dac_nids[3] = {
13882 /* front, rear, clfe, rear_surr */
13883 0x02, 0x04, 0x03
13884};
13885
13886static hda_nid_t alc861vd_adc_nids[1] = {
13887 /* ADC0 */
13888 0x09,
13889};
13890
Takashi Iwaie1406342008-02-11 18:32:32 +010013891static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13892
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013893/* input MUX */
13894/* FIXME: should be a matrix-type input source selection */
13895static struct hda_input_mux alc861vd_capture_source = {
13896 .num_items = 4,
13897 .items = {
13898 { "Mic", 0x0 },
13899 { "Front Mic", 0x1 },
13900 { "Line", 0x2 },
13901 { "CD", 0x4 },
13902 },
13903};
13904
Kailang Yang272a5272007-05-14 11:00:38 +020013905static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013906 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013907 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013908 { "Ext Mic", 0x0 },
13909 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013910 },
13911};
13912
Kailang Yangd1a991a2007-08-15 16:21:59 +020013913static struct hda_input_mux alc861vd_hp_capture_source = {
13914 .num_items = 2,
13915 .items = {
13916 { "Front Mic", 0x0 },
13917 { "ATAPI Mic", 0x1 },
13918 },
13919};
13920
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013921/*
13922 * 2ch mode
13923 */
13924static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13925 { 2, NULL }
13926};
13927
13928/*
13929 * 6ch mode
13930 */
13931static struct hda_verb alc861vd_6stack_ch6_init[] = {
13932 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13933 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13934 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13935 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13936 { } /* end */
13937};
13938
13939/*
13940 * 8ch mode
13941 */
13942static struct hda_verb alc861vd_6stack_ch8_init[] = {
13943 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13944 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13945 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13946 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13947 { } /* end */
13948};
13949
13950static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13951 { 6, alc861vd_6stack_ch6_init },
13952 { 8, alc861vd_6stack_ch8_init },
13953};
13954
13955static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13956 {
13957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13958 .name = "Channel Mode",
13959 .info = alc_ch_mode_info,
13960 .get = alc_ch_mode_get,
13961 .put = alc_ch_mode_put,
13962 },
13963 { } /* end */
13964};
13965
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013966/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13967 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13968 */
13969static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13970 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13972
13973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13974 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13975
13976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13977 HDA_OUTPUT),
13978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13979 HDA_OUTPUT),
13980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13982
13983 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13985
13986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13987
13988 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13991
13992 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13995
13996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13998
13999 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14000 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14001
14002 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14003 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14004
14005 { } /* end */
14006};
14007
14008static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14009 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14010 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14011
14012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14013
14014 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14017
14018 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14019 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14020 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14021
14022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14024
14025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14027
14028 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14029 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14030
14031 { } /* end */
14032};
14033
Kailang Yangbdd148a2007-05-08 15:19:08 +020014034static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14035 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14036 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14037 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14038
14039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14040
14041 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14044
14045 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14048
14049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14051
14052 { } /* end */
14053};
14054
Tobin Davisb419f342008-03-07 11:57:51 +010014055/* Pin assignment: Speaker=0x14, HP = 0x15,
14056 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014057 */
14058static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014059 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14060 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14062 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014063 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14064 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14065 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14066 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14067 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14068 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14069 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14070 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014071 { } /* end */
14072};
14073
Kailang Yangd1a991a2007-08-15 16:21:59 +020014074/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14075 * Front Mic=0x18, ATAPI Mic = 0x19,
14076 */
14077static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14078 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14079 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14080 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14081 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14082 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14083 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14084 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14085 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014086
Kailang Yangd1a991a2007-08-15 16:21:59 +020014087 { } /* end */
14088};
14089
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014090/*
14091 * generic initialization of ADC, input mixers and output mixers
14092 */
14093static struct hda_verb alc861vd_volume_init_verbs[] = {
14094 /*
14095 * Unmute ADC0 and set the default input to mic-in
14096 */
14097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14099
14100 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14101 * the analog-loopback mixer widget
14102 */
14103 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014109
14110 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014115
14116 /*
14117 * Set up output mixers (0x02 - 0x05)
14118 */
14119 /* set vol=0 to output mixers */
14120 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14121 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14122 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14123 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14124
14125 /* set up input amps for analog loopback */
14126 /* Amp Indices: DAC = 0, mixer = 1 */
14127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14135
14136 { }
14137};
14138
14139/*
14140 * 3-stack pin configuration:
14141 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14142 */
14143static struct hda_verb alc861vd_3stack_init_verbs[] = {
14144 /*
14145 * Set pin mode and muting
14146 */
14147 /* set front pin widgets 0x14 for output */
14148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14151
14152 /* Mic (rear) pin: input vref at 80% */
14153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14155 /* Front Mic pin: input vref at 80% */
14156 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14157 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14158 /* Line In pin: input */
14159 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14160 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14161 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14163 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14165 /* CD pin widget for input */
14166 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14167
14168 { }
14169};
14170
14171/*
14172 * 6-stack pin configuration:
14173 */
14174static struct hda_verb alc861vd_6stack_init_verbs[] = {
14175 /*
14176 * Set pin mode and muting
14177 */
14178 /* set front pin widgets 0x14 for output */
14179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14181 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14182
14183 /* Rear Pin: output 1 (0x0d) */
14184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14187 /* CLFE Pin: output 2 (0x0e) */
14188 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14190 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14191 /* Side Pin: output 3 (0x0f) */
14192 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14194 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14195
14196 /* Mic (rear) pin: input vref at 80% */
14197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14199 /* Front Mic pin: input vref at 80% */
14200 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14202 /* Line In pin: input */
14203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14205 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14208 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14209 /* CD pin widget for input */
14210 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14211
14212 { }
14213};
14214
Kailang Yangbdd148a2007-05-08 15:19:08 +020014215static struct hda_verb alc861vd_eapd_verbs[] = {
14216 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14217 { }
14218};
14219
Kailang Yangf9423e72008-05-27 12:32:25 +020014220static struct hda_verb alc660vd_eapd_verbs[] = {
14221 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14222 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14223 { }
14224};
14225
Kailang Yangbdd148a2007-05-08 15:19:08 +020014226static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14230 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014231 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014232 {}
14233};
14234
14235/* toggle speaker-output according to the hp-jack state */
14236static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14237{
14238 unsigned int present;
14239 unsigned char bits;
14240
14241 present = snd_hda_codec_read(codec, 0x1b, 0,
14242 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014243 bits = present ? HDA_AMP_MUTE : 0;
14244 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14245 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014246}
14247
14248static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14249{
14250 unsigned int present;
14251 unsigned char bits;
14252
14253 present = snd_hda_codec_read(codec, 0x18, 0,
14254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014255 bits = present ? HDA_AMP_MUTE : 0;
14256 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14257 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014258}
14259
14260static void alc861vd_lenovo_automute(struct hda_codec *codec)
14261{
14262 alc861vd_lenovo_hp_automute(codec);
14263 alc861vd_lenovo_mic_automute(codec);
14264}
14265
14266static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14267 unsigned int res)
14268{
14269 switch (res >> 26) {
14270 case ALC880_HP_EVENT:
14271 alc861vd_lenovo_hp_automute(codec);
14272 break;
14273 case ALC880_MIC_EVENT:
14274 alc861vd_lenovo_mic_automute(codec);
14275 break;
14276 }
14277}
14278
Kailang Yang272a5272007-05-14 11:00:38 +020014279static struct hda_verb alc861vd_dallas_verbs[] = {
14280 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14281 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14282 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14283 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14284
14285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14286 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14292 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014293
Kailang Yang272a5272007-05-14 11:00:38 +020014294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14299 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14300 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14301 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14302
14303 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14305 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14310 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14311
14312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14316
14317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14320
14321 { } /* end */
14322};
14323
14324/* toggle speaker-output according to the hp-jack state */
14325static void alc861vd_dallas_automute(struct hda_codec *codec)
14326{
14327 unsigned int present;
14328
14329 present = snd_hda_codec_read(codec, 0x15, 0,
14330 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014331 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14332 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014333}
14334
14335static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14336{
14337 if ((res >> 26) == ALC880_HP_EVENT)
14338 alc861vd_dallas_automute(codec);
14339}
14340
Takashi Iwaicb53c622007-08-10 17:21:45 +020014341#ifdef CONFIG_SND_HDA_POWER_SAVE
14342#define alc861vd_loopbacks alc880_loopbacks
14343#endif
14344
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014345/* pcm configuration: identiacal with ALC880 */
14346#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14347#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14348#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14349#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14350
14351/*
14352 * configuration and preset
14353 */
14354static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14355 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014356 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014357 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014358 [ALC861VD_3ST] = "3stack",
14359 [ALC861VD_3ST_DIG] = "3stack-digout",
14360 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014361 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014362 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014363 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014364 [ALC861VD_AUTO] = "auto",
14365};
14366
14367static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014368 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14369 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014370 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014371 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014372 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014373 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014374 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014375 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014376 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014377 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014378 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014379 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014380 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014381 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14382 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014383 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014384 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014385 {}
14386};
14387
14388static struct alc_config_preset alc861vd_presets[] = {
14389 [ALC660VD_3ST] = {
14390 .mixers = { alc861vd_3st_mixer },
14391 .init_verbs = { alc861vd_volume_init_verbs,
14392 alc861vd_3stack_init_verbs },
14393 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14394 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014395 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14396 .channel_mode = alc861vd_3stack_2ch_modes,
14397 .input_mux = &alc861vd_capture_source,
14398 },
Mike Crash6963f842007-06-25 12:12:51 +020014399 [ALC660VD_3ST_DIG] = {
14400 .mixers = { alc861vd_3st_mixer },
14401 .init_verbs = { alc861vd_volume_init_verbs,
14402 alc861vd_3stack_init_verbs },
14403 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14404 .dac_nids = alc660vd_dac_nids,
14405 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014406 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14407 .channel_mode = alc861vd_3stack_2ch_modes,
14408 .input_mux = &alc861vd_capture_source,
14409 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014410 [ALC861VD_3ST] = {
14411 .mixers = { alc861vd_3st_mixer },
14412 .init_verbs = { alc861vd_volume_init_verbs,
14413 alc861vd_3stack_init_verbs },
14414 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14415 .dac_nids = alc861vd_dac_nids,
14416 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14417 .channel_mode = alc861vd_3stack_2ch_modes,
14418 .input_mux = &alc861vd_capture_source,
14419 },
14420 [ALC861VD_3ST_DIG] = {
14421 .mixers = { alc861vd_3st_mixer },
14422 .init_verbs = { alc861vd_volume_init_verbs,
14423 alc861vd_3stack_init_verbs },
14424 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14425 .dac_nids = alc861vd_dac_nids,
14426 .dig_out_nid = ALC861VD_DIGOUT_NID,
14427 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14428 .channel_mode = alc861vd_3stack_2ch_modes,
14429 .input_mux = &alc861vd_capture_source,
14430 },
14431 [ALC861VD_6ST_DIG] = {
14432 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14433 .init_verbs = { alc861vd_volume_init_verbs,
14434 alc861vd_6stack_init_verbs },
14435 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14436 .dac_nids = alc861vd_dac_nids,
14437 .dig_out_nid = ALC861VD_DIGOUT_NID,
14438 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14439 .channel_mode = alc861vd_6stack_modes,
14440 .input_mux = &alc861vd_capture_source,
14441 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014442 [ALC861VD_LENOVO] = {
14443 .mixers = { alc861vd_lenovo_mixer },
14444 .init_verbs = { alc861vd_volume_init_verbs,
14445 alc861vd_3stack_init_verbs,
14446 alc861vd_eapd_verbs,
14447 alc861vd_lenovo_unsol_verbs },
14448 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14449 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014450 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14451 .channel_mode = alc861vd_3stack_2ch_modes,
14452 .input_mux = &alc861vd_capture_source,
14453 .unsol_event = alc861vd_lenovo_unsol_event,
14454 .init_hook = alc861vd_lenovo_automute,
14455 },
Kailang Yang272a5272007-05-14 11:00:38 +020014456 [ALC861VD_DALLAS] = {
14457 .mixers = { alc861vd_dallas_mixer },
14458 .init_verbs = { alc861vd_dallas_verbs },
14459 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14460 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014461 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14462 .channel_mode = alc861vd_3stack_2ch_modes,
14463 .input_mux = &alc861vd_dallas_capture_source,
14464 .unsol_event = alc861vd_dallas_unsol_event,
14465 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014466 },
14467 [ALC861VD_HP] = {
14468 .mixers = { alc861vd_hp_mixer },
14469 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14470 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14471 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014472 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014473 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14474 .channel_mode = alc861vd_3stack_2ch_modes,
14475 .input_mux = &alc861vd_hp_capture_source,
14476 .unsol_event = alc861vd_dallas_unsol_event,
14477 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014478 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014479 [ALC660VD_ASUS_V1S] = {
14480 .mixers = { alc861vd_lenovo_mixer },
14481 .init_verbs = { alc861vd_volume_init_verbs,
14482 alc861vd_3stack_init_verbs,
14483 alc861vd_eapd_verbs,
14484 alc861vd_lenovo_unsol_verbs },
14485 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14486 .dac_nids = alc660vd_dac_nids,
14487 .dig_out_nid = ALC861VD_DIGOUT_NID,
14488 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14489 .channel_mode = alc861vd_3stack_2ch_modes,
14490 .input_mux = &alc861vd_capture_source,
14491 .unsol_event = alc861vd_lenovo_unsol_event,
14492 .init_hook = alc861vd_lenovo_automute,
14493 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014494};
14495
14496/*
14497 * BIOS auto configuration
14498 */
14499static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14500 hda_nid_t nid, int pin_type, int dac_idx)
14501{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014502 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014503}
14504
14505static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14506{
14507 struct alc_spec *spec = codec->spec;
14508 int i;
14509
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014510 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014511 for (i = 0; i <= HDA_SIDE; i++) {
14512 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014513 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014514 if (nid)
14515 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014516 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014517 }
14518}
14519
14520
14521static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14522{
14523 struct alc_spec *spec = codec->spec;
14524 hda_nid_t pin;
14525
14526 pin = spec->autocfg.hp_pins[0];
14527 if (pin) /* connect to front and use dac 0 */
14528 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014529 pin = spec->autocfg.speaker_pins[0];
14530 if (pin)
14531 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014532}
14533
14534#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14535#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14536
14537static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14538{
14539 struct alc_spec *spec = codec->spec;
14540 int i;
14541
14542 for (i = 0; i < AUTO_PIN_LAST; i++) {
14543 hda_nid_t nid = spec->autocfg.input_pins[i];
14544 if (alc861vd_is_input_pin(nid)) {
14545 snd_hda_codec_write(codec, nid, 0,
14546 AC_VERB_SET_PIN_WIDGET_CONTROL,
14547 i <= AUTO_PIN_FRONT_MIC ?
14548 PIN_VREF80 : PIN_IN);
14549 if (nid != ALC861VD_PIN_CD_NID)
14550 snd_hda_codec_write(codec, nid, 0,
14551 AC_VERB_SET_AMP_GAIN_MUTE,
14552 AMP_OUT_MUTE);
14553 }
14554 }
14555}
14556
Takashi Iwaif511b012008-08-15 16:46:42 +020014557#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14558
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014559#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14560#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14561
14562/* add playback controls from the parsed DAC table */
14563/* Based on ALC880 version. But ALC861VD has separate,
14564 * different NIDs for mute/unmute switch and volume control */
14565static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14566 const struct auto_pin_cfg *cfg)
14567{
14568 char name[32];
14569 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14570 hda_nid_t nid_v, nid_s;
14571 int i, err;
14572
14573 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014574 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014575 continue;
14576 nid_v = alc861vd_idx_to_mixer_vol(
14577 alc880_dac_to_idx(
14578 spec->multiout.dac_nids[i]));
14579 nid_s = alc861vd_idx_to_mixer_switch(
14580 alc880_dac_to_idx(
14581 spec->multiout.dac_nids[i]));
14582
14583 if (i == 2) {
14584 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14586 "Center Playback Volume",
14587 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14588 HDA_OUTPUT));
14589 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014591 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14592 "LFE Playback Volume",
14593 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14594 HDA_OUTPUT));
14595 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014597 err = add_control(spec, ALC_CTL_BIND_MUTE,
14598 "Center Playback Switch",
14599 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14600 HDA_INPUT));
14601 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014603 err = add_control(spec, ALC_CTL_BIND_MUTE,
14604 "LFE Playback Switch",
14605 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14606 HDA_INPUT));
14607 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014608 return err;
14609 } else {
14610 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014611 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14612 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14613 HDA_OUTPUT));
14614 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014615 return err;
14616 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014617 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014618 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014619 HDA_INPUT));
14620 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014621 return err;
14622 }
14623 }
14624 return 0;
14625}
14626
14627/* add playback controls for speaker and HP outputs */
14628/* Based on ALC880 version. But ALC861VD has separate,
14629 * different NIDs for mute/unmute switch and volume control */
14630static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14631 hda_nid_t pin, const char *pfx)
14632{
14633 hda_nid_t nid_v, nid_s;
14634 int err;
14635 char name[32];
14636
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014637 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014638 return 0;
14639
14640 if (alc880_is_fixed_pin(pin)) {
14641 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14642 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014643 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014644 spec->multiout.hp_nid = nid_v;
14645 else
14646 spec->multiout.extra_out_nid[0] = nid_v;
14647 /* control HP volume/switch on the output mixer amp */
14648 nid_v = alc861vd_idx_to_mixer_vol(
14649 alc880_fixed_pin_idx(pin));
14650 nid_s = alc861vd_idx_to_mixer_switch(
14651 alc880_fixed_pin_idx(pin));
14652
14653 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014654 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14655 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14656 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014657 return err;
14658 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014659 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14660 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14661 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014662 return err;
14663 } else if (alc880_is_multi_pin(pin)) {
14664 /* set manual connection */
14665 /* we have only a switch on HP-out PIN */
14666 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014667 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14668 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14669 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014670 return err;
14671 }
14672 return 0;
14673}
14674
14675/* parse the BIOS configuration and set up the alc_spec
14676 * return 1 if successful, 0 if the proper config is not found,
14677 * or a negative error code
14678 * Based on ALC880 version - had to change it to override
14679 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14680static int alc861vd_parse_auto_config(struct hda_codec *codec)
14681{
14682 struct alc_spec *spec = codec->spec;
14683 int err;
14684 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14685
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014686 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14687 alc861vd_ignore);
14688 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014689 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014690 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014691 return 0; /* can't find valid BIOS pin config */
14692
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014693 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14694 if (err < 0)
14695 return err;
14696 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14697 if (err < 0)
14698 return err;
14699 err = alc861vd_auto_create_extra_out(spec,
14700 spec->autocfg.speaker_pins[0],
14701 "Speaker");
14702 if (err < 0)
14703 return err;
14704 err = alc861vd_auto_create_extra_out(spec,
14705 spec->autocfg.hp_pins[0],
14706 "Headphone");
14707 if (err < 0)
14708 return err;
14709 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14710 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014711 return err;
14712
14713 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14714
14715 if (spec->autocfg.dig_out_pin)
14716 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14717
Takashi Iwai603c4012008-07-30 15:01:44 +020014718 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014719 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014720
Takashi Iwaid88897e2008-10-31 15:01:37 +010014721 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014722
14723 spec->num_mux_defs = 1;
14724 spec->input_mux = &spec->private_imux;
14725
Takashi Iwai776e1842007-08-29 15:07:11 +020014726 err = alc_auto_add_mic_boost(codec);
14727 if (err < 0)
14728 return err;
14729
Takashi Iwaie044c392008-10-27 16:56:24 +010014730 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014731 return 1;
14732}
14733
14734/* additional initialization for auto-configuration model */
14735static void alc861vd_auto_init(struct hda_codec *codec)
14736{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014737 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014738 alc861vd_auto_init_multi_out(codec);
14739 alc861vd_auto_init_hp_out(codec);
14740 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014741 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014742 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014743 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014744}
14745
14746static int patch_alc861vd(struct hda_codec *codec)
14747{
14748 struct alc_spec *spec;
14749 int err, board_config;
14750
14751 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14752 if (spec == NULL)
14753 return -ENOMEM;
14754
14755 codec->spec = spec;
14756
14757 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14758 alc861vd_models,
14759 alc861vd_cfg_tbl);
14760
14761 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14762 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14763 "ALC861VD, trying auto-probe from BIOS...\n");
14764 board_config = ALC861VD_AUTO;
14765 }
14766
14767 if (board_config == ALC861VD_AUTO) {
14768 /* automatic parse from the BIOS config */
14769 err = alc861vd_parse_auto_config(codec);
14770 if (err < 0) {
14771 alc_free(codec);
14772 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014773 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014774 printk(KERN_INFO
14775 "hda_codec: Cannot set up configuration "
14776 "from BIOS. Using base mode...\n");
14777 board_config = ALC861VD_3ST;
14778 }
14779 }
14780
14781 if (board_config != ALC861VD_AUTO)
14782 setup_preset(spec, &alc861vd_presets[board_config]);
14783
Kailang Yang2f893282008-05-27 12:14:47 +020014784 if (codec->vendor_id == 0x10ec0660) {
14785 spec->stream_name_analog = "ALC660-VD Analog";
14786 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014787 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014788 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014789 } else {
14790 spec->stream_name_analog = "ALC861VD Analog";
14791 spec->stream_name_digital = "ALC861VD Digital";
14792 }
14793
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014794 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14795 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14796
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014797 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14798 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14799
14800 spec->adc_nids = alc861vd_adc_nids;
14801 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014802 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014803 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014804
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014805 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014806
Takashi Iwai2134ea42008-01-10 16:53:55 +010014807 spec->vmaster_nid = 0x02;
14808
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014809 codec->patch_ops = alc_patch_ops;
14810
14811 if (board_config == ALC861VD_AUTO)
14812 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014813#ifdef CONFIG_SND_HDA_POWER_SAVE
14814 if (!spec->loopback.amplist)
14815 spec->loopback.amplist = alc861vd_loopbacks;
14816#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014817 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014818
14819 return 0;
14820}
14821
14822/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014823 * ALC662 support
14824 *
14825 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14826 * configuration. Each pin widget can choose any input DACs and a mixer.
14827 * Each ADC is connected from a mixer of all inputs. This makes possible
14828 * 6-channel independent captures.
14829 *
14830 * In addition, an independent DAC for the multi-playback (not used in this
14831 * driver yet).
14832 */
14833#define ALC662_DIGOUT_NID 0x06
14834#define ALC662_DIGIN_NID 0x0a
14835
14836static hda_nid_t alc662_dac_nids[4] = {
14837 /* front, rear, clfe, rear_surr */
14838 0x02, 0x03, 0x04
14839};
14840
14841static hda_nid_t alc662_adc_nids[1] = {
14842 /* ADC1-2 */
14843 0x09,
14844};
Takashi Iwaie1406342008-02-11 18:32:32 +010014845
Kailang Yang77a261b2008-02-19 11:38:05 +010014846static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014847
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014848/* input MUX */
14849/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014850static struct hda_input_mux alc662_capture_source = {
14851 .num_items = 4,
14852 .items = {
14853 { "Mic", 0x0 },
14854 { "Front Mic", 0x1 },
14855 { "Line", 0x2 },
14856 { "CD", 0x4 },
14857 },
14858};
14859
14860static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14861 .num_items = 2,
14862 .items = {
14863 { "Mic", 0x1 },
14864 { "Line", 0x2 },
14865 },
14866};
Kailang Yang291702f2007-10-16 14:28:03 +020014867
14868static struct hda_input_mux alc662_eeepc_capture_source = {
14869 .num_items = 2,
14870 .items = {
14871 { "i-Mic", 0x1 },
14872 { "e-Mic", 0x0 },
14873 },
14874};
14875
Kailang Yang6dda9f42008-05-27 12:05:31 +020014876static struct hda_input_mux alc663_capture_source = {
14877 .num_items = 3,
14878 .items = {
14879 { "Mic", 0x0 },
14880 { "Front Mic", 0x1 },
14881 { "Line", 0x2 },
14882 },
14883};
14884
14885static struct hda_input_mux alc663_m51va_capture_source = {
14886 .num_items = 2,
14887 .items = {
14888 { "Ext-Mic", 0x0 },
14889 { "D-Mic", 0x9 },
14890 },
14891};
14892
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014893/*
14894 * 2ch mode
14895 */
14896static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14897 { 2, NULL }
14898};
14899
14900/*
14901 * 2ch mode
14902 */
14903static struct hda_verb alc662_3ST_ch2_init[] = {
14904 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14905 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14908 { } /* end */
14909};
14910
14911/*
14912 * 6ch mode
14913 */
14914static struct hda_verb alc662_3ST_ch6_init[] = {
14915 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14916 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14917 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14918 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14919 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14920 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14921 { } /* end */
14922};
14923
14924static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14925 { 2, alc662_3ST_ch2_init },
14926 { 6, alc662_3ST_ch6_init },
14927};
14928
14929/*
14930 * 2ch mode
14931 */
14932static struct hda_verb alc662_sixstack_ch6_init[] = {
14933 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14934 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14935 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14936 { } /* end */
14937};
14938
14939/*
14940 * 6ch mode
14941 */
14942static struct hda_verb alc662_sixstack_ch8_init[] = {
14943 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14944 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14945 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14946 { } /* end */
14947};
14948
14949static struct hda_channel_mode alc662_5stack_modes[2] = {
14950 { 2, alc662_sixstack_ch6_init },
14951 { 6, alc662_sixstack_ch8_init },
14952};
14953
14954/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14955 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14956 */
14957
14958static struct snd_kcontrol_new alc662_base_mixer[] = {
14959 /* output mixer control */
14960 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014961 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014963 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014966 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14967 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14969
14970 /*Input mixer control */
14971 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14972 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14973 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14974 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14975 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14976 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014979 { } /* end */
14980};
14981
14982static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14983 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014984 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14994 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14995 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014996 { } /* end */
14997};
14998
14999static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15000 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015001 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015002 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015003 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015004 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15005 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015006 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15007 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15010 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15017 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15018 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015019 { } /* end */
15020};
15021
15022static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15023 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15024 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15026 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15029 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015032 { } /* end */
15033};
15034
Kailang Yang291702f2007-10-16 14:28:03 +020015035static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015036 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015037
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015038 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15039 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015040
15041 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15042 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15043 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15044
15045 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15046 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15047 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15048 { } /* end */
15049};
15050
Kailang Yang8c427222008-01-10 13:03:59 +010015051static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015052 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15053 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15055 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15056 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015060 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015061 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15066 { } /* end */
15067};
15068
Kailang Yangf1d4e282008-08-26 14:03:29 +020015069static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15070 .ops = &snd_hda_bind_vol,
15071 .values = {
15072 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15073 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15074 0
15075 },
15076};
15077
15078static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15079 .ops = &snd_hda_bind_sw,
15080 .values = {
15081 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15082 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15083 0
15084 },
15085};
15086
Kailang Yang6dda9f42008-05-27 12:05:31 +020015087static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015088 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15089 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15092 { } /* end */
15093};
15094
15095static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15096 .ops = &snd_hda_bind_sw,
15097 .values = {
15098 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15099 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15100 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15101 0
15102 },
15103};
15104
15105static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15106 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15107 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15110 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15111 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15112
15113 { } /* end */
15114};
15115
15116static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15117 .ops = &snd_hda_bind_sw,
15118 .values = {
15119 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15120 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15121 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15122 0
15123 },
15124};
15125
15126static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15127 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15128 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15131 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15132 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15133 { } /* end */
15134};
15135
15136static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015137 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15138 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15142 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15143 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15144 { } /* end */
15145};
15146
15147static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15148 .ops = &snd_hda_bind_vol,
15149 .values = {
15150 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15151 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15152 0
15153 },
15154};
15155
15156static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15157 .ops = &snd_hda_bind_sw,
15158 .values = {
15159 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15160 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15161 0
15162 },
15163};
15164
15165static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15166 HDA_BIND_VOL("Master Playback Volume",
15167 &alc663_asus_two_bind_master_vol),
15168 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15169 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015173 { } /* end */
15174};
15175
15176static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15177 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15178 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15179 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15180 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015183 { } /* end */
15184};
15185
15186static struct snd_kcontrol_new alc663_g71v_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_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15190 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15192
15193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15195 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15196 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15197 { } /* end */
15198};
15199
15200static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15201 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15202 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15204
15205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15207 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15208 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15211 { } /* end */
15212};
15213
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015214static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15215 {
15216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15217 .name = "Channel Mode",
15218 .info = alc_ch_mode_info,
15219 .get = alc_ch_mode_get,
15220 .put = alc_ch_mode_put,
15221 },
15222 { } /* end */
15223};
15224
15225static struct hda_verb alc662_init_verbs[] = {
15226 /* ADC: mute amp left and right */
15227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15228 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15229 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15230
Takashi Iwaicb53c622007-08-10 17:21:45 +020015231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015236
Kailang Yangb60dd392007-09-20 12:50:29 +020015237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15240 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15242 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015243
15244 /* Front Pin: output 0 (0x0c) */
15245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15247
15248 /* Rear Pin: output 1 (0x0d) */
15249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15251
15252 /* CLFE Pin: output 2 (0x0e) */
15253 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15255
15256 /* Mic (rear) pin: input vref at 80% */
15257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15259 /* Front Mic pin: input vref at 80% */
15260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15262 /* Line In pin: input */
15263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15265 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15269 /* CD pin widget for input */
15270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15271
15272 /* FIXME: use matrix-type input source selection */
15273 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15274 /* Input mixer */
15275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015279
15280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015284
15285 /* always trun on EAPD */
15286 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15287 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15288
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015289 { }
15290};
15291
15292static struct hda_verb alc662_sue_init_verbs[] = {
15293 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15294 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015295 {}
15296};
15297
15298static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15299 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15300 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15301 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015302};
15303
Kailang Yang8c427222008-01-10 13:03:59 +010015304/* Set Unsolicited Event*/
15305static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15307 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15308 {}
15309};
15310
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015311/*
15312 * generic initialization of ADC, input mixers and output mixers
15313 */
15314static struct hda_verb alc662_auto_init_verbs[] = {
15315 /*
15316 * Unmute ADC and set the default input to mic-in
15317 */
15318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15320
15321 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15322 * mixer widget
15323 * Note: PASD motherboards uses the Line In 2 as the input for front
15324 * panel mic (mic 2)
15325 */
15326 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015332
15333 /*
15334 * Set up output mixers (0x0c - 0x0f)
15335 */
15336 /* set vol=0 to output mixers */
15337 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15338 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15339 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15340
15341 /* set up input amps for analog loopback */
15342 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015349
15350
15351 /* FIXME: use matrix-type input source selection */
15352 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15353 /* Input mixer */
15354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015356 { }
15357};
15358
Takashi Iwai24fb9172008-09-02 14:48:20 +020015359/* additional verbs for ALC663 */
15360static struct hda_verb alc663_auto_init_verbs[] = {
15361 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15362 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15363 { }
15364};
15365
Kailang Yang6dda9f42008-05-27 12:05:31 +020015366static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15368 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015369 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15370 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015371 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015374 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15375 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15376 {}
15377};
15378
Kailang Yangf1d4e282008-08-26 14:03:29 +020015379static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15380 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15381 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15382 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15385 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15386 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15387 {}
15388};
15389
15390static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15392 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15394 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15397 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15398 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15399 {}
15400};
15401
15402static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15408 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15409 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15410 {}
15411};
15412
15413static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15415 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15416 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15417 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15420 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15423 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15424 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15425 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15426 {}
15427};
15428
15429static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15431 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15432 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15433 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15436 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15439 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15440 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15441 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15442 {}
15443};
15444
Kailang Yang6dda9f42008-05-27 12:05:31 +020015445static struct hda_verb alc663_g71v_init_verbs[] = {
15446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15447 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15448 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15449
15450 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15451 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15452 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15453
15454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15456 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15457 {}
15458};
15459
15460static struct hda_verb alc663_g50v_init_verbs[] = {
15461 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15462 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15463 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15464
15465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15466 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15467 {}
15468};
15469
Kailang Yangf1d4e282008-08-26 14:03:29 +020015470static struct hda_verb alc662_ecs_init_verbs[] = {
15471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15473 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15474 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15475 {}
15476};
15477
Kailang Yangf1d4e282008-08-26 14:03:29 +020015478static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15479 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15480 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15481 { } /* end */
15482};
15483
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015484static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15485{
15486 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015487 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015488
15489 present = snd_hda_codec_read(codec, 0x14, 0,
15490 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015491 bits = present ? HDA_AMP_MUTE : 0;
15492 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15493 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015494}
15495
15496static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15497{
15498 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015499 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015500
15501 present = snd_hda_codec_read(codec, 0x1b, 0,
15502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015503 bits = present ? HDA_AMP_MUTE : 0;
15504 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15505 HDA_AMP_MUTE, bits);
15506 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15507 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015508}
15509
15510static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15511 unsigned int res)
15512{
15513 if ((res >> 26) == ALC880_HP_EVENT)
15514 alc662_lenovo_101e_all_automute(codec);
15515 if ((res >> 26) == ALC880_FRONT_EVENT)
15516 alc662_lenovo_101e_ispeaker_automute(codec);
15517}
15518
Kailang Yang291702f2007-10-16 14:28:03 +020015519static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15520{
15521 unsigned int present;
15522
15523 present = snd_hda_codec_read(codec, 0x18, 0,
15524 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15525 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15526 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15527 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15528 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15529 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15530 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15531 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15532 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15533}
15534
15535/* unsolicited event for HP jack sensing */
15536static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15537 unsigned int res)
15538{
15539 if ((res >> 26) == ALC880_HP_EVENT)
15540 alc262_hippo1_automute( codec );
15541
15542 if ((res >> 26) == ALC880_MIC_EVENT)
15543 alc662_eeepc_mic_automute(codec);
15544}
15545
15546static void alc662_eeepc_inithook(struct hda_codec *codec)
15547{
15548 alc262_hippo1_automute( codec );
15549 alc662_eeepc_mic_automute(codec);
15550}
15551
Kailang Yang8c427222008-01-10 13:03:59 +010015552static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15553{
15554 unsigned int mute;
15555 unsigned int present;
15556
15557 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15558 present = snd_hda_codec_read(codec, 0x14, 0,
15559 AC_VERB_GET_PIN_SENSE, 0);
15560 present = (present & 0x80000000) != 0;
15561 if (present) {
15562 /* mute internal speaker */
15563 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015564 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015565 } else {
15566 /* unmute internal speaker if necessary */
15567 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15568 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015569 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015570 }
15571}
15572
15573/* unsolicited event for HP jack sensing */
15574static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15575 unsigned int res)
15576{
15577 if ((res >> 26) == ALC880_HP_EVENT)
15578 alc662_eeepc_ep20_automute(codec);
15579}
15580
15581static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15582{
15583 alc662_eeepc_ep20_automute(codec);
15584}
15585
Kailang Yang6dda9f42008-05-27 12:05:31 +020015586static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15587{
15588 unsigned int present;
15589 unsigned char bits;
15590
15591 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015592 AC_VERB_GET_PIN_SENSE, 0)
15593 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015594 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015595 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15596 AMP_IN_MUTE(0), bits);
15597 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15598 AMP_IN_MUTE(0), bits);
15599}
15600
15601static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15602{
15603 unsigned int present;
15604 unsigned char bits;
15605
15606 present = snd_hda_codec_read(codec, 0x21, 0,
15607 AC_VERB_GET_PIN_SENSE, 0)
15608 & AC_PINSENSE_PRESENCE;
15609 bits = present ? HDA_AMP_MUTE : 0;
15610 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15611 AMP_IN_MUTE(0), bits);
15612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15613 AMP_IN_MUTE(0), bits);
15614 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15615 AMP_IN_MUTE(0), bits);
15616 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15617 AMP_IN_MUTE(0), bits);
15618}
15619
15620static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15621{
15622 unsigned int present;
15623 unsigned char bits;
15624
15625 present = snd_hda_codec_read(codec, 0x15, 0,
15626 AC_VERB_GET_PIN_SENSE, 0)
15627 & AC_PINSENSE_PRESENCE;
15628 bits = present ? HDA_AMP_MUTE : 0;
15629 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15630 AMP_IN_MUTE(0), bits);
15631 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15632 AMP_IN_MUTE(0), bits);
15633 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15634 AMP_IN_MUTE(0), bits);
15635 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15636 AMP_IN_MUTE(0), bits);
15637}
15638
15639static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15640{
15641 unsigned int present;
15642 unsigned char bits;
15643
15644 present = snd_hda_codec_read(codec, 0x1b, 0,
15645 AC_VERB_GET_PIN_SENSE, 0)
15646 & AC_PINSENSE_PRESENCE;
15647 bits = present ? 0 : PIN_OUT;
15648 snd_hda_codec_write(codec, 0x14, 0,
15649 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15650}
15651
15652static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15653{
15654 unsigned int present1, present2;
15655
15656 present1 = snd_hda_codec_read(codec, 0x21, 0,
15657 AC_VERB_GET_PIN_SENSE, 0)
15658 & AC_PINSENSE_PRESENCE;
15659 present2 = snd_hda_codec_read(codec, 0x15, 0,
15660 AC_VERB_GET_PIN_SENSE, 0)
15661 & AC_PINSENSE_PRESENCE;
15662
15663 if (present1 || present2) {
15664 snd_hda_codec_write_cache(codec, 0x14, 0,
15665 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15666 } else {
15667 snd_hda_codec_write_cache(codec, 0x14, 0,
15668 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15669 }
15670}
15671
15672static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15673{
15674 unsigned int present1, present2;
15675
15676 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15677 AC_VERB_GET_PIN_SENSE, 0)
15678 & AC_PINSENSE_PRESENCE;
15679 present2 = snd_hda_codec_read(codec, 0x15, 0,
15680 AC_VERB_GET_PIN_SENSE, 0)
15681 & AC_PINSENSE_PRESENCE;
15682
15683 if (present1 || present2) {
15684 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15685 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15686 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15687 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15688 } else {
15689 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15690 AMP_IN_MUTE(0), 0);
15691 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15692 AMP_IN_MUTE(0), 0);
15693 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015694}
15695
15696static void alc663_m51va_mic_automute(struct hda_codec *codec)
15697{
15698 unsigned int present;
15699
15700 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015701 AC_VERB_GET_PIN_SENSE, 0)
15702 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015703 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015704 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015705 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015706 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015707 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015708 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015709 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015710 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015711}
15712
15713static void alc663_m51va_unsol_event(struct hda_codec *codec,
15714 unsigned int res)
15715{
15716 switch (res >> 26) {
15717 case ALC880_HP_EVENT:
15718 alc663_m51va_speaker_automute(codec);
15719 break;
15720 case ALC880_MIC_EVENT:
15721 alc663_m51va_mic_automute(codec);
15722 break;
15723 }
15724}
15725
15726static void alc663_m51va_inithook(struct hda_codec *codec)
15727{
15728 alc663_m51va_speaker_automute(codec);
15729 alc663_m51va_mic_automute(codec);
15730}
15731
Kailang Yangf1d4e282008-08-26 14:03:29 +020015732/* ***************** Mode1 ******************************/
15733static void alc663_mode1_unsol_event(struct hda_codec *codec,
15734 unsigned int res)
15735{
15736 switch (res >> 26) {
15737 case ALC880_HP_EVENT:
15738 alc663_m51va_speaker_automute(codec);
15739 break;
15740 case ALC880_MIC_EVENT:
15741 alc662_eeepc_mic_automute(codec);
15742 break;
15743 }
15744}
15745
15746static void alc663_mode1_inithook(struct hda_codec *codec)
15747{
15748 alc663_m51va_speaker_automute(codec);
15749 alc662_eeepc_mic_automute(codec);
15750}
15751/* ***************** Mode2 ******************************/
15752static void alc662_mode2_unsol_event(struct hda_codec *codec,
15753 unsigned int res)
15754{
15755 switch (res >> 26) {
15756 case ALC880_HP_EVENT:
15757 alc662_f5z_speaker_automute(codec);
15758 break;
15759 case ALC880_MIC_EVENT:
15760 alc662_eeepc_mic_automute(codec);
15761 break;
15762 }
15763}
15764
15765static void alc662_mode2_inithook(struct hda_codec *codec)
15766{
15767 alc662_f5z_speaker_automute(codec);
15768 alc662_eeepc_mic_automute(codec);
15769}
15770/* ***************** Mode3 ******************************/
15771static void alc663_mode3_unsol_event(struct hda_codec *codec,
15772 unsigned int res)
15773{
15774 switch (res >> 26) {
15775 case ALC880_HP_EVENT:
15776 alc663_two_hp_m1_speaker_automute(codec);
15777 break;
15778 case ALC880_MIC_EVENT:
15779 alc662_eeepc_mic_automute(codec);
15780 break;
15781 }
15782}
15783
15784static void alc663_mode3_inithook(struct hda_codec *codec)
15785{
15786 alc663_two_hp_m1_speaker_automute(codec);
15787 alc662_eeepc_mic_automute(codec);
15788}
15789/* ***************** Mode4 ******************************/
15790static void alc663_mode4_unsol_event(struct hda_codec *codec,
15791 unsigned int res)
15792{
15793 switch (res >> 26) {
15794 case ALC880_HP_EVENT:
15795 alc663_21jd_two_speaker_automute(codec);
15796 break;
15797 case ALC880_MIC_EVENT:
15798 alc662_eeepc_mic_automute(codec);
15799 break;
15800 }
15801}
15802
15803static void alc663_mode4_inithook(struct hda_codec *codec)
15804{
15805 alc663_21jd_two_speaker_automute(codec);
15806 alc662_eeepc_mic_automute(codec);
15807}
15808/* ***************** Mode5 ******************************/
15809static void alc663_mode5_unsol_event(struct hda_codec *codec,
15810 unsigned int res)
15811{
15812 switch (res >> 26) {
15813 case ALC880_HP_EVENT:
15814 alc663_15jd_two_speaker_automute(codec);
15815 break;
15816 case ALC880_MIC_EVENT:
15817 alc662_eeepc_mic_automute(codec);
15818 break;
15819 }
15820}
15821
15822static void alc663_mode5_inithook(struct hda_codec *codec)
15823{
15824 alc663_15jd_two_speaker_automute(codec);
15825 alc662_eeepc_mic_automute(codec);
15826}
15827/* ***************** Mode6 ******************************/
15828static void alc663_mode6_unsol_event(struct hda_codec *codec,
15829 unsigned int res)
15830{
15831 switch (res >> 26) {
15832 case ALC880_HP_EVENT:
15833 alc663_two_hp_m2_speaker_automute(codec);
15834 break;
15835 case ALC880_MIC_EVENT:
15836 alc662_eeepc_mic_automute(codec);
15837 break;
15838 }
15839}
15840
15841static void alc663_mode6_inithook(struct hda_codec *codec)
15842{
15843 alc663_two_hp_m2_speaker_automute(codec);
15844 alc662_eeepc_mic_automute(codec);
15845}
15846
Kailang Yang6dda9f42008-05-27 12:05:31 +020015847static void alc663_g71v_hp_automute(struct hda_codec *codec)
15848{
15849 unsigned int present;
15850 unsigned char bits;
15851
15852 present = snd_hda_codec_read(codec, 0x21, 0,
15853 AC_VERB_GET_PIN_SENSE, 0)
15854 & AC_PINSENSE_PRESENCE;
15855 bits = present ? HDA_AMP_MUTE : 0;
15856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15857 HDA_AMP_MUTE, bits);
15858 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15859 HDA_AMP_MUTE, bits);
15860}
15861
15862static void alc663_g71v_front_automute(struct hda_codec *codec)
15863{
15864 unsigned int present;
15865 unsigned char bits;
15866
15867 present = snd_hda_codec_read(codec, 0x15, 0,
15868 AC_VERB_GET_PIN_SENSE, 0)
15869 & AC_PINSENSE_PRESENCE;
15870 bits = present ? HDA_AMP_MUTE : 0;
15871 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15872 HDA_AMP_MUTE, bits);
15873}
15874
15875static void alc663_g71v_unsol_event(struct hda_codec *codec,
15876 unsigned int res)
15877{
15878 switch (res >> 26) {
15879 case ALC880_HP_EVENT:
15880 alc663_g71v_hp_automute(codec);
15881 break;
15882 case ALC880_FRONT_EVENT:
15883 alc663_g71v_front_automute(codec);
15884 break;
15885 case ALC880_MIC_EVENT:
15886 alc662_eeepc_mic_automute(codec);
15887 break;
15888 }
15889}
15890
15891static void alc663_g71v_inithook(struct hda_codec *codec)
15892{
15893 alc663_g71v_front_automute(codec);
15894 alc663_g71v_hp_automute(codec);
15895 alc662_eeepc_mic_automute(codec);
15896}
15897
15898static void alc663_g50v_unsol_event(struct hda_codec *codec,
15899 unsigned int res)
15900{
15901 switch (res >> 26) {
15902 case ALC880_HP_EVENT:
15903 alc663_m51va_speaker_automute(codec);
15904 break;
15905 case ALC880_MIC_EVENT:
15906 alc662_eeepc_mic_automute(codec);
15907 break;
15908 }
15909}
15910
15911static void alc663_g50v_inithook(struct hda_codec *codec)
15912{
15913 alc663_m51va_speaker_automute(codec);
15914 alc662_eeepc_mic_automute(codec);
15915}
15916
Kailang Yangf1d4e282008-08-26 14:03:29 +020015917/* bind hp and internal speaker mute (with plug check) */
15918static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15919 struct snd_ctl_elem_value *ucontrol)
15920{
15921 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15922 long *valp = ucontrol->value.integer.value;
15923 int change;
15924
15925 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15926 HDA_AMP_MUTE,
15927 valp[0] ? 0 : HDA_AMP_MUTE);
15928 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15929 HDA_AMP_MUTE,
15930 valp[1] ? 0 : HDA_AMP_MUTE);
15931 if (change)
15932 alc262_hippo1_automute(codec);
15933 return change;
15934}
15935
15936static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15937 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15938 {
15939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15940 .name = "Master Playback Switch",
15941 .info = snd_hda_mixer_amp_switch_info,
15942 .get = snd_hda_mixer_amp_switch_get,
15943 .put = alc662_ecs_master_sw_put,
15944 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15945 },
15946
15947 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15948 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15949 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15950
15951 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15952 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15953 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15954 { } /* end */
15955};
15956
Takashi Iwaicb53c622007-08-10 17:21:45 +020015957#ifdef CONFIG_SND_HDA_POWER_SAVE
15958#define alc662_loopbacks alc880_loopbacks
15959#endif
15960
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015961
15962/* pcm configuration: identiacal with ALC880 */
15963#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15964#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15965#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15966#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15967
15968/*
15969 * configuration and preset
15970 */
15971static const char *alc662_models[ALC662_MODEL_LAST] = {
15972 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15973 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15974 [ALC662_3ST_6ch] = "3stack-6ch",
15975 [ALC662_5ST_DIG] = "6stack-dig",
15976 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015977 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015978 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015979 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015980 [ALC663_ASUS_M51VA] = "m51va",
15981 [ALC663_ASUS_G71V] = "g71v",
15982 [ALC663_ASUS_H13] = "h13",
15983 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015984 [ALC663_ASUS_MODE1] = "asus-mode1",
15985 [ALC662_ASUS_MODE2] = "asus-mode2",
15986 [ALC663_ASUS_MODE3] = "asus-mode3",
15987 [ALC663_ASUS_MODE4] = "asus-mode4",
15988 [ALC663_ASUS_MODE5] = "asus-mode5",
15989 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015990 [ALC662_AUTO] = "auto",
15991};
15992
15993static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015994 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015995 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015996 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015997 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015998 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015999 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16000 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
16001 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16002 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16003 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16004 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
16005 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16006 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16007 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016008 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016009 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16010 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16011 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16012 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16013 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16014 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16015 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16016 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16017 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16018 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16019 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16020 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16021 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16022 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16023 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16024 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16025 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16026 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16027 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16028 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16029 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16030 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016031 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16032 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016033 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016034 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16035 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016036 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16037 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016038 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020016039 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016040 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016041 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
16042 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
16043 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044 {}
16045};
16046
16047static struct alc_config_preset alc662_presets[] = {
16048 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016049 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016050 .init_verbs = { alc662_init_verbs },
16051 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16052 .dac_nids = alc662_dac_nids,
16053 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016054 .dig_in_nid = ALC662_DIGIN_NID,
16055 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16056 .channel_mode = alc662_3ST_2ch_modes,
16057 .input_mux = &alc662_capture_source,
16058 },
16059 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016060 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016061 .init_verbs = { alc662_init_verbs },
16062 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16063 .dac_nids = alc662_dac_nids,
16064 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016065 .dig_in_nid = ALC662_DIGIN_NID,
16066 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16067 .channel_mode = alc662_3ST_6ch_modes,
16068 .need_dac_fix = 1,
16069 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016070 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016072 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016073 .init_verbs = { alc662_init_verbs },
16074 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16075 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16077 .channel_mode = alc662_3ST_6ch_modes,
16078 .need_dac_fix = 1,
16079 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016080 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016081 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016082 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016083 .init_verbs = { alc662_init_verbs },
16084 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16085 .dac_nids = alc662_dac_nids,
16086 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016087 .dig_in_nid = ALC662_DIGIN_NID,
16088 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16089 .channel_mode = alc662_5stack_modes,
16090 .input_mux = &alc662_capture_source,
16091 },
16092 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016093 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016094 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16095 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16096 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016097 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16098 .channel_mode = alc662_3ST_2ch_modes,
16099 .input_mux = &alc662_lenovo_101e_capture_source,
16100 .unsol_event = alc662_lenovo_101e_unsol_event,
16101 .init_hook = alc662_lenovo_101e_all_automute,
16102 },
Kailang Yang291702f2007-10-16 14:28:03 +020016103 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016104 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016105 .init_verbs = { alc662_init_verbs,
16106 alc662_eeepc_sue_init_verbs },
16107 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16108 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016109 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16110 .channel_mode = alc662_3ST_2ch_modes,
16111 .input_mux = &alc662_eeepc_capture_source,
16112 .unsol_event = alc662_eeepc_unsol_event,
16113 .init_hook = alc662_eeepc_inithook,
16114 },
Kailang Yang8c427222008-01-10 13:03:59 +010016115 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016116 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016117 alc662_chmode_mixer },
16118 .init_verbs = { alc662_init_verbs,
16119 alc662_eeepc_ep20_sue_init_verbs },
16120 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16121 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016122 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16123 .channel_mode = alc662_3ST_6ch_modes,
16124 .input_mux = &alc662_lenovo_101e_capture_source,
16125 .unsol_event = alc662_eeepc_ep20_unsol_event,
16126 .init_hook = alc662_eeepc_ep20_inithook,
16127 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016128 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016129 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016130 .init_verbs = { alc662_init_verbs,
16131 alc662_ecs_init_verbs },
16132 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16133 .dac_nids = alc662_dac_nids,
16134 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16135 .channel_mode = alc662_3ST_2ch_modes,
16136 .input_mux = &alc662_eeepc_capture_source,
16137 .unsol_event = alc662_eeepc_unsol_event,
16138 .init_hook = alc662_eeepc_inithook,
16139 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016140 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016141 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016142 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16143 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16144 .dac_nids = alc662_dac_nids,
16145 .dig_out_nid = ALC662_DIGOUT_NID,
16146 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16147 .channel_mode = alc662_3ST_2ch_modes,
16148 .input_mux = &alc663_m51va_capture_source,
16149 .unsol_event = alc663_m51va_unsol_event,
16150 .init_hook = alc663_m51va_inithook,
16151 },
16152 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016153 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016154 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16155 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16156 .dac_nids = alc662_dac_nids,
16157 .dig_out_nid = ALC662_DIGOUT_NID,
16158 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16159 .channel_mode = alc662_3ST_2ch_modes,
16160 .input_mux = &alc662_eeepc_capture_source,
16161 .unsol_event = alc663_g71v_unsol_event,
16162 .init_hook = alc663_g71v_inithook,
16163 },
16164 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016165 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016166 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16167 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16168 .dac_nids = alc662_dac_nids,
16169 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16170 .channel_mode = alc662_3ST_2ch_modes,
16171 .input_mux = &alc663_m51va_capture_source,
16172 .unsol_event = alc663_m51va_unsol_event,
16173 .init_hook = alc663_m51va_inithook,
16174 },
16175 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016176 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016177 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16178 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16179 .dac_nids = alc662_dac_nids,
16180 .dig_out_nid = ALC662_DIGOUT_NID,
16181 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16182 .channel_mode = alc662_3ST_6ch_modes,
16183 .input_mux = &alc663_capture_source,
16184 .unsol_event = alc663_g50v_unsol_event,
16185 .init_hook = alc663_g50v_inithook,
16186 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016187 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016188 .mixers = { alc663_m51va_mixer },
16189 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016190 .init_verbs = { alc662_init_verbs,
16191 alc663_21jd_amic_init_verbs },
16192 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16193 .hp_nid = 0x03,
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 = alc663_mode1_unsol_event,
16200 .init_hook = alc663_mode1_inithook,
16201 },
16202 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016203 .mixers = { alc662_1bjd_mixer },
16204 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016205 .init_verbs = { alc662_init_verbs,
16206 alc662_1bjd_amic_init_verbs },
16207 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16208 .dac_nids = alc662_dac_nids,
16209 .dig_out_nid = ALC662_DIGOUT_NID,
16210 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16211 .channel_mode = alc662_3ST_2ch_modes,
16212 .input_mux = &alc662_eeepc_capture_source,
16213 .unsol_event = alc662_mode2_unsol_event,
16214 .init_hook = alc662_mode2_inithook,
16215 },
16216 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016217 .mixers = { alc663_two_hp_m1_mixer },
16218 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016219 .init_verbs = { alc662_init_verbs,
16220 alc663_two_hp_amic_m1_init_verbs },
16221 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16222 .hp_nid = 0x03,
16223 .dac_nids = alc662_dac_nids,
16224 .dig_out_nid = ALC662_DIGOUT_NID,
16225 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16226 .channel_mode = alc662_3ST_2ch_modes,
16227 .input_mux = &alc662_eeepc_capture_source,
16228 .unsol_event = alc663_mode3_unsol_event,
16229 .init_hook = alc663_mode3_inithook,
16230 },
16231 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016232 .mixers = { alc663_asus_21jd_clfe_mixer },
16233 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016234 .init_verbs = { alc662_init_verbs,
16235 alc663_21jd_amic_init_verbs},
16236 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16237 .hp_nid = 0x03,
16238 .dac_nids = alc662_dac_nids,
16239 .dig_out_nid = ALC662_DIGOUT_NID,
16240 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16241 .channel_mode = alc662_3ST_2ch_modes,
16242 .input_mux = &alc662_eeepc_capture_source,
16243 .unsol_event = alc663_mode4_unsol_event,
16244 .init_hook = alc663_mode4_inithook,
16245 },
16246 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016247 .mixers = { alc663_asus_15jd_clfe_mixer },
16248 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016249 .init_verbs = { alc662_init_verbs,
16250 alc663_15jd_amic_init_verbs },
16251 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16252 .hp_nid = 0x03,
16253 .dac_nids = alc662_dac_nids,
16254 .dig_out_nid = ALC662_DIGOUT_NID,
16255 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16256 .channel_mode = alc662_3ST_2ch_modes,
16257 .input_mux = &alc662_eeepc_capture_source,
16258 .unsol_event = alc663_mode5_unsol_event,
16259 .init_hook = alc663_mode5_inithook,
16260 },
16261 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016262 .mixers = { alc663_two_hp_m2_mixer },
16263 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016264 .init_verbs = { alc662_init_verbs,
16265 alc663_two_hp_amic_m2_init_verbs },
16266 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16267 .hp_nid = 0x03,
16268 .dac_nids = alc662_dac_nids,
16269 .dig_out_nid = ALC662_DIGOUT_NID,
16270 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16271 .channel_mode = alc662_3ST_2ch_modes,
16272 .input_mux = &alc662_eeepc_capture_source,
16273 .unsol_event = alc663_mode6_unsol_event,
16274 .init_hook = alc663_mode6_inithook,
16275 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016276};
16277
16278
16279/*
16280 * BIOS auto configuration
16281 */
16282
16283/* add playback controls from the parsed DAC table */
16284static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16285 const struct auto_pin_cfg *cfg)
16286{
16287 char name[32];
16288 static const char *chname[4] = {
16289 "Front", "Surround", NULL /*CLFE*/, "Side"
16290 };
16291 hda_nid_t nid;
16292 int i, err;
16293
16294 for (i = 0; i < cfg->line_outs; i++) {
16295 if (!spec->multiout.dac_nids[i])
16296 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016297 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016298 if (i == 2) {
16299 /* Center/LFE */
16300 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16301 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016302 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16303 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016304 if (err < 0)
16305 return err;
16306 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16307 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016308 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16309 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016310 if (err < 0)
16311 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016312 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016313 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016314 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016315 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016316 if (err < 0)
16317 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016318 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016319 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016320 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016321 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016322 if (err < 0)
16323 return err;
16324 } else {
16325 sprintf(name, "%s Playback Volume", chname[i]);
16326 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016327 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16328 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329 if (err < 0)
16330 return err;
16331 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016332 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16333 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16334 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335 if (err < 0)
16336 return err;
16337 }
16338 }
16339 return 0;
16340}
16341
16342/* add playback controls for speaker and HP outputs */
16343static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16344 const char *pfx)
16345{
16346 hda_nid_t nid;
16347 int err;
16348 char name[32];
16349
16350 if (!pin)
16351 return 0;
16352
Takashi Iwai24fb9172008-09-02 14:48:20 +020016353 if (pin == 0x17) {
16354 /* ALC663 has a mono output pin on 0x17 */
16355 sprintf(name, "%s Playback Switch", pfx);
16356 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16357 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16358 return err;
16359 }
16360
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016361 if (alc880_is_fixed_pin(pin)) {
16362 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16363 /* printk("DAC nid=%x\n",nid); */
16364 /* specify the DAC as the extra output */
16365 if (!spec->multiout.hp_nid)
16366 spec->multiout.hp_nid = nid;
16367 else
16368 spec->multiout.extra_out_nid[0] = nid;
16369 /* control HP volume/switch on the output mixer amp */
16370 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16371 sprintf(name, "%s Playback Volume", pfx);
16372 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16373 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16374 if (err < 0)
16375 return err;
16376 sprintf(name, "%s Playback Switch", pfx);
16377 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16378 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16379 if (err < 0)
16380 return err;
16381 } else if (alc880_is_multi_pin(pin)) {
16382 /* set manual connection */
16383 /* we have only a switch on HP-out PIN */
16384 sprintf(name, "%s Playback Switch", pfx);
16385 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16386 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16387 if (err < 0)
16388 return err;
16389 }
16390 return 0;
16391}
16392
16393/* create playback/capture controls for input pins */
16394static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16395 const struct auto_pin_cfg *cfg)
16396{
16397 struct hda_input_mux *imux = &spec->private_imux;
16398 int i, err, idx;
16399
16400 for (i = 0; i < AUTO_PIN_LAST; i++) {
16401 if (alc880_is_input_pin(cfg->input_pins[i])) {
16402 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16403 err = new_analog_input(spec, cfg->input_pins[i],
16404 auto_pin_cfg_labels[i],
16405 idx, 0x0b);
16406 if (err < 0)
16407 return err;
16408 imux->items[imux->num_items].label =
16409 auto_pin_cfg_labels[i];
16410 imux->items[imux->num_items].index =
16411 alc880_input_pin_idx(cfg->input_pins[i]);
16412 imux->num_items++;
16413 }
16414 }
16415 return 0;
16416}
16417
16418static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16419 hda_nid_t nid, int pin_type,
16420 int dac_idx)
16421{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016422 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016423 /* need the manual connection? */
16424 if (alc880_is_multi_pin(nid)) {
16425 struct alc_spec *spec = codec->spec;
16426 int idx = alc880_multi_pin_idx(nid);
16427 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16428 AC_VERB_SET_CONNECT_SEL,
16429 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16430 }
16431}
16432
16433static void alc662_auto_init_multi_out(struct hda_codec *codec)
16434{
16435 struct alc_spec *spec = codec->spec;
16436 int i;
16437
Kailang Yang8c427222008-01-10 13:03:59 +010016438 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016439 for (i = 0; i <= HDA_SIDE; i++) {
16440 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016441 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016442 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016443 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016444 i);
16445 }
16446}
16447
16448static void alc662_auto_init_hp_out(struct hda_codec *codec)
16449{
16450 struct alc_spec *spec = codec->spec;
16451 hda_nid_t pin;
16452
16453 pin = spec->autocfg.hp_pins[0];
16454 if (pin) /* connect to front */
16455 /* use dac 0 */
16456 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016457 pin = spec->autocfg.speaker_pins[0];
16458 if (pin)
16459 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016460}
16461
16462#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16463#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16464
16465static void alc662_auto_init_analog_input(struct hda_codec *codec)
16466{
16467 struct alc_spec *spec = codec->spec;
16468 int i;
16469
16470 for (i = 0; i < AUTO_PIN_LAST; i++) {
16471 hda_nid_t nid = spec->autocfg.input_pins[i];
16472 if (alc662_is_input_pin(nid)) {
16473 snd_hda_codec_write(codec, nid, 0,
16474 AC_VERB_SET_PIN_WIDGET_CONTROL,
16475 (i <= AUTO_PIN_FRONT_MIC ?
16476 PIN_VREF80 : PIN_IN));
16477 if (nid != ALC662_PIN_CD_NID)
16478 snd_hda_codec_write(codec, nid, 0,
16479 AC_VERB_SET_AMP_GAIN_MUTE,
16480 AMP_OUT_MUTE);
16481 }
16482 }
16483}
16484
Takashi Iwaif511b012008-08-15 16:46:42 +020016485#define alc662_auto_init_input_src alc882_auto_init_input_src
16486
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016487static int alc662_parse_auto_config(struct hda_codec *codec)
16488{
16489 struct alc_spec *spec = codec->spec;
16490 int err;
16491 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16492
16493 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16494 alc662_ignore);
16495 if (err < 0)
16496 return err;
16497 if (!spec->autocfg.line_outs)
16498 return 0; /* can't find valid BIOS pin config */
16499
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016500 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16501 if (err < 0)
16502 return err;
16503 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16504 if (err < 0)
16505 return err;
16506 err = alc662_auto_create_extra_out(spec,
16507 spec->autocfg.speaker_pins[0],
16508 "Speaker");
16509 if (err < 0)
16510 return err;
16511 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16512 "Headphone");
16513 if (err < 0)
16514 return err;
16515 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16516 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016517 return err;
16518
16519 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16520
16521 if (spec->autocfg.dig_out_pin)
16522 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16523
Takashi Iwai603c4012008-07-30 15:01:44 +020016524 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016525 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016526
16527 spec->num_mux_defs = 1;
16528 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016529
Takashi Iwaid88897e2008-10-31 15:01:37 +010016530 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016531 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016532 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016533
16534 err = alc_auto_add_mic_boost(codec);
16535 if (err < 0)
16536 return err;
16537
Takashi Iwaie044c392008-10-27 16:56:24 +010016538 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016539 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016540}
16541
16542/* additional initialization for auto-configuration model */
16543static void alc662_auto_init(struct hda_codec *codec)
16544{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016545 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016546 alc662_auto_init_multi_out(codec);
16547 alc662_auto_init_hp_out(codec);
16548 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016549 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016550 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016551 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016552}
16553
16554static int patch_alc662(struct hda_codec *codec)
16555{
16556 struct alc_spec *spec;
16557 int err, board_config;
16558
16559 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16560 if (!spec)
16561 return -ENOMEM;
16562
16563 codec->spec = spec;
16564
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016565 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16566
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016567 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16568 alc662_models,
16569 alc662_cfg_tbl);
16570 if (board_config < 0) {
16571 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16572 "trying auto-probe from BIOS...\n");
16573 board_config = ALC662_AUTO;
16574 }
16575
16576 if (board_config == ALC662_AUTO) {
16577 /* automatic parse from the BIOS config */
16578 err = alc662_parse_auto_config(codec);
16579 if (err < 0) {
16580 alc_free(codec);
16581 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016582 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016583 printk(KERN_INFO
16584 "hda_codec: Cannot set up configuration "
16585 "from BIOS. Using base mode...\n");
16586 board_config = ALC662_3ST_2ch_DIG;
16587 }
16588 }
16589
16590 if (board_config != ALC662_AUTO)
16591 setup_preset(spec, &alc662_presets[board_config]);
16592
Kailang Yang6dda9f42008-05-27 12:05:31 +020016593 if (codec->vendor_id == 0x10ec0663) {
16594 spec->stream_name_analog = "ALC663 Analog";
16595 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016596 } else if (codec->vendor_id == 0x10ec0272) {
16597 spec->stream_name_analog = "ALC272 Analog";
16598 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016599 } else {
16600 spec->stream_name_analog = "ALC662 Analog";
16601 spec->stream_name_digital = "ALC662 Digital";
16602 }
16603
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016604 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16605 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16606
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016607 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16608 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16609
Takashi Iwaie1406342008-02-11 18:32:32 +010016610 spec->adc_nids = alc662_adc_nids;
16611 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16612 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016613 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016615 if (!spec->cap_mixer)
16616 set_capture_mixer(spec);
16617
Takashi Iwai2134ea42008-01-10 16:53:55 +010016618 spec->vmaster_nid = 0x02;
16619
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016620 codec->patch_ops = alc_patch_ops;
16621 if (board_config == ALC662_AUTO)
16622 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016623#ifdef CONFIG_SND_HDA_POWER_SAVE
16624 if (!spec->loopback.amplist)
16625 spec->loopback.amplist = alc662_loopbacks;
16626#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016627 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016628
16629 return 0;
16630}
16631
16632/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016633 * patch entries
16634 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016635static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016636 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016637 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016638 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016639 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016640 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016641 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016642 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016643 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016644 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16645 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16646 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016647 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16648 .patch = patch_alc883 },
16649 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16650 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016651 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016652 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016653 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016654 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016655 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16656 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016657 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016658 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016659 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016660 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016661 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16662 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016663 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016664 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016665 {} /* terminator */
16666};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016667
16668MODULE_ALIAS("snd-hda-codec-id:10ec*");
16669
16670MODULE_LICENSE("GPL");
16671MODULE_DESCRIPTION("Realtek HD-audio codec");
16672
16673static struct hda_codec_preset_list realtek_list = {
16674 .preset = snd_hda_preset_realtek,
16675 .owner = THIS_MODULE,
16676};
16677
16678static int __init patch_realtek_init(void)
16679{
16680 return snd_hda_add_codec_preset(&realtek_list);
16681}
16682
16683static void __exit patch_realtek_exit(void)
16684{
16685 snd_hda_delete_codec_preset(&realtek_list);
16686}
16687
16688module_init(patch_realtek_init)
16689module_exit(patch_realtek_exit)