blob: 4cfa78c5439839211762963e33105c10d0c26a32 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33
Kailang Yangccc656c2006-10-17 12:32:26 +020034#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/* ALC880 board config type */
40enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020046 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020047 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020048 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010053 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010054 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020055 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020056 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010058 ALC880_CLEVO,
59 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010060 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010061 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020062 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020074 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010075 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010077 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020078 ALC260_WILL,
79 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010080#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010083 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020084 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Kailang Yangdf694da2005-12-05 19:42:22 +010087/* ALC262 models */
88enum {
89 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020090 ALC262_HIPPO,
91 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010092 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020093 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010094 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010096 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010097 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020098 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020099 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200100 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200101 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100102 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200103 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200104 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200105 ALC262_TOSHIBA_RX1,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100116 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200117 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100118 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100119 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100120#ifdef CONFIG_SND_DEBUG
121 ALC268_TEST,
122#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200123 ALC268_AUTO,
124 ALC268_MODEL_LAST /* last tag */
125};
126
Kailang Yangf6a92242007-12-13 16:52:54 +0100127/* ALC269 models */
128enum {
129 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200130 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100133 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000134 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100135 ALC269_AUTO,
136 ALC269_MODEL_LAST /* last tag */
137};
138
Kailang Yangdf694da2005-12-05 19:42:22 +0100139/* ALC861 models */
140enum {
141 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200142 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100143 ALC861_3ST_DIG,
144 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200145 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200146 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200147 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100148 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 ALC861_AUTO,
150 ALC861_MODEL_LAST,
151};
152
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100153/* ALC861-VD models */
154enum {
155 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200156 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100157 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158 ALC861VD_3ST,
159 ALC861VD_3ST_DIG,
160 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200161 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200162 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200163 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100164 ALC861VD_AUTO,
165 ALC861VD_MODEL_LAST,
166};
167
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200168/* ALC662 models */
169enum {
170 ALC662_3ST_2ch_DIG,
171 ALC662_3ST_6ch_DIG,
172 ALC662_3ST_6ch,
173 ALC662_5ST_DIG,
174 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200175 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100176 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200177 ALC663_ASUS_M51VA,
178 ALC663_ASUS_G71V,
179 ALC663_ASUS_H13,
180 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200181 ALC662_ECS,
182 ALC663_ASUS_MODE1,
183 ALC662_ASUS_MODE2,
184 ALC663_ASUS_MODE3,
185 ALC663_ASUS_MODE4,
186 ALC663_ASUS_MODE5,
187 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200188 ALC662_AUTO,
189 ALC662_MODEL_LAST,
190};
191
Kailang Yangdf694da2005-12-05 19:42:22 +0100192/* ALC882 models */
193enum {
194 ALC882_3ST_DIG,
195 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200196 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200197 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200198 ALC882_TARGA,
199 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200200 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100201 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200202 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200203 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100205 ALC882_MODEL_LAST,
206};
207
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200208/* ALC883 models */
209enum {
210 ALC883_3ST_2ch_DIG,
211 ALC883_3ST_6ch_DIG,
212 ALC883_3ST_6ch,
213 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200214 ALC883_TARGA_DIG,
215 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200216 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200217 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800218 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200219 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200220 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100221 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200222 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200223 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200224 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200225 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200226 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200227 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100228 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100229 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100230 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100231 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800232 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200233 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200234 ALC888_ASUS_M90V,
235 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100236 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200237 ALC883_AUTO,
238 ALC883_MODEL_LAST,
239};
240
Kailang Yangdf694da2005-12-05 19:42:22 +0100241/* for GPIO Poll */
242#define GPIO_MASK 0x03
243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244struct alc_spec {
245 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200251 * don't forget NULL
252 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200253 */
254 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
Takashi Iwai16ded522005-06-10 19:58:24 +0200256 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 struct hda_pcm_stream *stream_analog_playback;
258 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100259 struct hda_pcm_stream *stream_analog_alt_playback;
260 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200262 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 struct hda_pcm_stream *stream_digital_playback;
264 struct hda_pcm_stream *stream_digital_capture;
265
266 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 struct hda_multi_out multiout; /* playback set-up
268 * max_channels, dacs must be set
269 * dig_out_nid and hp_nid are optional
270 */
Takashi Iwai63300792008-01-24 15:31:36 +0100271 hda_nid_t alt_dac_nid;
Takashi Iwai8c441982009-01-20 18:30:20 +0100272 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274 /* capture */
275 unsigned int num_adc_nids;
276 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100277 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100279 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200282 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 const struct hda_input_mux *input_mux;
284 unsigned int cur_mux[3];
285
286 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100287 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200289 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
291 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100292 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200293
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200294 /* dynamic controls, init_verbs and input_mux */
295 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200296 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200297 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200298 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100299
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100300 /* hooks */
301 void (*init_hook)(struct hda_codec *codec);
302 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
303
Takashi Iwai834be882006-03-01 14:16:17 +0100304 /* for pin sensing */
305 unsigned int sense_updated: 1;
306 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100307 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200308
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100309 /* other flags */
310 unsigned int no_analog :1; /* digital I/O only */
311
Takashi Iwai2134ea42008-01-10 16:53:55 +0100312 /* for virtual master */
313 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200314#ifdef CONFIG_SND_HDA_POWER_SAVE
315 struct hda_loopback_check loopback;
316#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200317
318 /* for PLL fix */
319 hda_nid_t pll_nid;
320 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100321
322#ifdef SND_HDA_NEEDS_RESUME
323#define ALC_MAX_PINS 16
324 unsigned int num_pins;
325 hda_nid_t pin_nids[ALC_MAX_PINS];
326 unsigned int pin_cfgs[ALC_MAX_PINS];
327#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100328};
329
330/*
331 * configuration template - to be copied to the spec instance
332 */
333struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200334 struct snd_kcontrol_new *mixers[5]; /* should be identical size
335 * with spec
336 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100337 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100338 const struct hda_verb *init_verbs[5];
339 unsigned int num_dacs;
340 hda_nid_t *dac_nids;
341 hda_nid_t dig_out_nid; /* optional */
342 hda_nid_t hp_nid; /* optional */
343 unsigned int num_adc_nids;
344 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100345 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100346 hda_nid_t dig_in_nid;
347 unsigned int num_channel_mode;
348 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200349 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200350 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100351 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100352 void (*unsol_event)(struct hda_codec *, unsigned int);
353 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200354#ifdef CONFIG_SND_HDA_POWER_SAVE
355 struct hda_amp_list *loopbacks;
356#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357};
358
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360/*
361 * input MUX handling
362 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365{
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200368 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
369 if (mux_idx >= spec->num_mux_defs)
370 mux_idx = 0;
371 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372}
373
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200374static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
375 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
378 struct alc_spec *spec = codec->spec;
379 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
380
381 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
382 return 0;
383}
384
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200385static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
389 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100390 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100392 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100393 hda_nid_t nid = spec->capsrc_nids ?
394 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Takashi Iwaicd896c32008-11-18 12:36:33 +0100396 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
397 imux = &spec->input_mux[mux_idx];
398
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100399 if (spec->is_mix_capture) {
400 /* Matrix-mixer style (e.g. ALC882) */
401 unsigned int *cur_val = &spec->cur_mux[adc_idx];
402 unsigned int i, idx;
403
404 idx = ucontrol->value.enumerated.item[0];
405 if (idx >= imux->num_items)
406 idx = imux->num_items - 1;
407 if (*cur_val == idx)
408 return 0;
409 for (i = 0; i < imux->num_items; i++) {
410 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
411 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
412 imux->items[i].index,
413 HDA_AMP_MUTE, v);
414 }
415 *cur_val = idx;
416 return 1;
417 } else {
418 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100419 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100420 &spec->cur_mux[adc_idx]);
421 }
422}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424/*
425 * channel mode setting
426 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100432 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
433 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434}
435
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200436static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
437 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438{
439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
440 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100441 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442 spec->num_channel_mode,
443 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444}
445
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200451 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
452 spec->num_channel_mode,
453 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200454 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200455 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
456 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200461 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100462 * being part of a format specifier. Maximum allowed length of a value is
463 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100464 *
465 * Note: some retasking pin complexes seem to ignore requests for input
466 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
467 * are requested. Therefore order this list so that this behaviour will not
468 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200469 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
470 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200471 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100473 "Mic 50pc bias", "Mic 80pc bias",
474 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100475};
476static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100477 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100478};
479/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200480 * in the pin being assumed to be exclusively an input or an output pin. In
481 * addition, "input" pins may or may not process the mic bias option
482 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
483 * accept requests for bias as of chip versions up to March 2006) and/or
484 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200486#define ALC_PIN_DIR_IN 0x00
487#define ALC_PIN_DIR_OUT 0x01
488#define ALC_PIN_DIR_INOUT 0x02
489#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
490#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491
Kailang Yangea1fb292008-08-26 12:58:38 +0200492/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493 * For each direction the minimum and maximum values are given.
494 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200495static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496 { 0, 2 }, /* ALC_PIN_DIR_IN */
497 { 3, 4 }, /* ALC_PIN_DIR_OUT */
498 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200499 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
500 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501};
502#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
503#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
504#define alc_pin_mode_n_items(_dir) \
505 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
506
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200507static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200509{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510 unsigned int item_num = uinfo->value.enumerated.item;
511 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
512
513 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200514 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
516
517 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
518 item_num = alc_pin_mode_min(dir);
519 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200520 return 0;
521}
522
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200525{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100529 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
532 AC_VERB_GET_PIN_WIDGET_CONTROL,
533 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 /* Find enumerated value for current pinctl setting */
536 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200537 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 return 0;
541}
542
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545{
546 signed int change;
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 hda_nid_t nid = kcontrol->private_value & 0xffff;
549 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
550 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
552 AC_VERB_GET_PIN_WIDGET_CONTROL,
553 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200555 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556 val = alc_pin_mode_min(dir);
557
558 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100559 if (change) {
560 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200561 snd_hda_codec_write_cache(codec, nid, 0,
562 AC_VERB_SET_PIN_WIDGET_CONTROL,
563 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100564
Kailang Yangea1fb292008-08-26 12:58:38 +0200565 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100566 * for the requested pin mode. Enum values of 2 or less are
567 * input modes.
568 *
569 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200570 * reduces noise slightly (particularly on input) so we'll
571 * do it. However, having both input and output buffers
572 * enabled simultaneously doesn't seem to be problematic if
573 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100574 */
575 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200576 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
577 HDA_AMP_MUTE, HDA_AMP_MUTE);
578 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
579 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100580 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200581 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
582 HDA_AMP_MUTE, HDA_AMP_MUTE);
583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100585 }
586 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200587 return change;
588}
589
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200591 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 .info = alc_pin_mode_info, \
593 .get = alc_pin_mode_get, \
594 .put = alc_pin_mode_put, \
595 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100596
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100597/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
598 * together using a mask with more than one bit set. This control is
599 * currently used only by the ALC260 test model. At this stage they are not
600 * needed for any "production" models.
601 */
602#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200603#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200604
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100607{
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 hda_nid_t nid = kcontrol->private_value & 0xffff;
610 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
611 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612 unsigned int val = snd_hda_codec_read(codec, nid, 0,
613 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100614
615 *valp = (val & mask) != 0;
616 return 0;
617}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200618static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100620{
621 signed int change;
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 hda_nid_t nid = kcontrol->private_value & 0xffff;
624 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
625 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
627 AC_VERB_GET_GPIO_DATA,
628 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629
630 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
632 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100633 gpio_data &= ~mask;
634 else
635 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200636 snd_hda_codec_write_cache(codec, nid, 0,
637 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100638
639 return change;
640}
641#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
642 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
643 .info = alc_gpio_data_info, \
644 .get = alc_gpio_data_get, \
645 .put = alc_gpio_data_put, \
646 .private_value = nid | (mask<<16) }
647#endif /* CONFIG_SND_DEBUG */
648
Jonathan Woithe92621f12006-02-28 11:47:47 +0100649/* A switch control to allow the enabling of the digital IO pins on the
650 * ALC260. This is incredibly simplistic; the intention of this control is
651 * to provide something in the test model allowing digital outputs to be
652 * identified if present. If models are found which can utilise these
653 * outputs a more complete mixer control can be devised for those models if
654 * necessary.
655 */
656#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200657#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200658
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200659static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100661{
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 hda_nid_t nid = kcontrol->private_value & 0xffff;
664 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
665 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100667 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100668
669 *valp = (val & mask) != 0;
670 return 0;
671}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200672static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100674{
675 signed int change;
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 hda_nid_t nid = kcontrol->private_value & 0xffff;
678 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
679 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100681 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200682 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683
684 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686 if (val==0)
687 ctrl_data &= ~mask;
688 else
689 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200690 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
691 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100692
693 return change;
694}
695#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
696 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
697 .info = alc_spdif_ctrl_info, \
698 .get = alc_spdif_ctrl_get, \
699 .put = alc_spdif_ctrl_put, \
700 .private_value = nid | (mask<<16) }
701#endif /* CONFIG_SND_DEBUG */
702
Jonathan Woithef8225f62008-01-08 12:16:54 +0100703/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
704 * Again, this is only used in the ALC26x test models to help identify when
705 * the EAPD line must be asserted for features to work.
706 */
707#ifdef CONFIG_SND_DEBUG
708#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
709
710static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
712{
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long *valp = ucontrol->value.integer.value;
717 unsigned int val = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
719
720 *valp = (val & mask) != 0;
721 return 0;
722}
723
724static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
726{
727 int change;
728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
729 hda_nid_t nid = kcontrol->private_value & 0xffff;
730 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
731 long val = *ucontrol->value.integer.value;
732 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
733 AC_VERB_GET_EAPD_BTLENABLE,
734 0x00);
735
736 /* Set/unset the masked control bit(s) as needed */
737 change = (!val ? 0 : mask) != (ctrl_data & mask);
738 if (!val)
739 ctrl_data &= ~mask;
740 else
741 ctrl_data |= mask;
742 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
743 ctrl_data);
744
745 return change;
746}
747
748#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
749 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
750 .info = alc_eapd_ctrl_info, \
751 .get = alc_eapd_ctrl_get, \
752 .put = alc_eapd_ctrl_put, \
753 .private_value = nid | (mask<<16) }
754#endif /* CONFIG_SND_DEBUG */
755
Kailang Yangdf694da2005-12-05 19:42:22 +0100756/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100757 */
758static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
759{
760 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
761 return;
762 spec->mixers[spec->num_mixers++] = mix;
763}
764
765static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
766{
767 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
768 return;
769 spec->init_verbs[spec->num_init_verbs++] = verb;
770}
771
Takashi Iwaidaead532008-11-28 12:55:36 +0100772#ifdef CONFIG_PROC_FS
773/*
774 * hook for proc
775 */
776static void print_realtek_coef(struct snd_info_buffer *buffer,
777 struct hda_codec *codec, hda_nid_t nid)
778{
779 int coeff;
780
781 if (nid != 0x20)
782 return;
783 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
784 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
785 coeff = snd_hda_codec_read(codec, nid, 0,
786 AC_VERB_GET_COEF_INDEX, 0);
787 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
788}
789#else
790#define print_realtek_coef NULL
791#endif
792
Takashi Iwaid88897e2008-10-31 15:01:37 +0100793/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100794 * set up from the preset table
795 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200796static void setup_preset(struct alc_spec *spec,
797 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100798{
799 int i;
800
801 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100802 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100803 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200804 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
805 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100806 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200807
Kailang Yangdf694da2005-12-05 19:42:22 +0100808 spec->channel_mode = preset->channel_mode;
809 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200810 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100811
812 spec->multiout.max_channels = spec->channel_mode[0].channels;
813
814 spec->multiout.num_dacs = preset->num_dacs;
815 spec->multiout.dac_nids = preset->dac_nids;
816 spec->multiout.dig_out_nid = preset->dig_out_nid;
817 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200818
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200819 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200820 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200821 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100822 spec->input_mux = preset->input_mux;
823
824 spec->num_adc_nids = preset->num_adc_nids;
825 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100826 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100827 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100828
829 spec->unsol_event = preset->unsol_event;
830 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200831#ifdef CONFIG_SND_HDA_POWER_SAVE
832 spec->loopback.amplist = preset->loopbacks;
833#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100834}
835
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200836/* Enable GPIO mask and set output */
837static struct hda_verb alc_gpio1_init_verbs[] = {
838 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
839 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
840 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
841 { }
842};
843
844static struct hda_verb alc_gpio2_init_verbs[] = {
845 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
846 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
847 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
848 { }
849};
850
Kailang Yangbdd148a2007-05-08 15:19:08 +0200851static struct hda_verb alc_gpio3_init_verbs[] = {
852 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
854 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
855 { }
856};
857
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200858/*
859 * Fix hardware PLL issue
860 * On some codecs, the analog PLL gating control must be off while
861 * the default value is 1.
862 */
863static void alc_fix_pll(struct hda_codec *codec)
864{
865 struct alc_spec *spec = codec->spec;
866 unsigned int val;
867
868 if (!spec->pll_nid)
869 return;
870 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
871 spec->pll_coef_idx);
872 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
873 AC_VERB_GET_PROC_COEF, 0);
874 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
875 spec->pll_coef_idx);
876 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
877 val & ~(1 << spec->pll_coef_bit));
878}
879
880static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
881 unsigned int coef_idx, unsigned int coef_bit)
882{
883 struct alc_spec *spec = codec->spec;
884 spec->pll_nid = nid;
885 spec->pll_coef_idx = coef_idx;
886 spec->pll_coef_bit = coef_bit;
887 alc_fix_pll(codec);
888}
889
Kailang Yangc9b58002007-10-16 14:30:01 +0200890static void alc_sku_automute(struct hda_codec *codec)
891{
892 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200893 unsigned int present;
894 unsigned int hp_nid = spec->autocfg.hp_pins[0];
895 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
896
897 /* need to execute and sync at first */
898 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
899 present = snd_hda_codec_read(codec, hp_nid, 0,
900 AC_VERB_GET_PIN_SENSE, 0);
901 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100902 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
903 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200904}
905
Takashi Iwai4605b712008-10-31 14:18:24 +0100906#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200907static void alc_mic_automute(struct hda_codec *codec)
908{
909 struct alc_spec *spec = codec->spec;
910 unsigned int present;
911 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
912 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
913 unsigned int mix_nid = spec->capsrc_nids[0];
914 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
915
916 capsrc_idx_mic = mic_nid - 0x18;
917 capsrc_idx_fmic = fmic_nid - 0x18;
918 present = snd_hda_codec_read(codec, mic_nid, 0,
919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
920 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
921 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
922 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
923 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
924 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
925 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
926}
Takashi Iwai4605b712008-10-31 14:18:24 +0100927#else
928#define alc_mic_automute(codec) /* NOP */
929#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200930
Kailang Yangc9b58002007-10-16 14:30:01 +0200931/* unsolicited event for HP jack sensing */
932static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
933{
934 if (codec->vendor_id == 0x10ec0880)
935 res >>= 28;
936 else
937 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200938 if (res == ALC880_HP_EVENT)
939 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200940
Kailang Yang7fb0d782008-10-15 11:12:35 +0200941 if (res == ALC880_MIC_EVENT)
942 alc_mic_automute(codec);
943}
944
945static void alc_inithook(struct hda_codec *codec)
946{
Kailang Yangc9b58002007-10-16 14:30:01 +0200947 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200948 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200949}
950
Kailang Yangf9423e72008-05-27 12:32:25 +0200951/* additional initialization for ALC888 variants */
952static void alc888_coef_init(struct hda_codec *codec)
953{
954 unsigned int tmp;
955
956 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
957 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
958 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
959 if ((tmp & 0xf0) == 2)
960 /* alc888S-VC */
961 snd_hda_codec_read(codec, 0x20, 0,
962 AC_VERB_SET_PROC_COEF, 0x830);
963 else
964 /* alc888-VB */
965 snd_hda_codec_read(codec, 0x20, 0,
966 AC_VERB_SET_PROC_COEF, 0x3030);
967}
968
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200969/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
970 * 31 ~ 16 : Manufacture ID
971 * 15 ~ 8 : SKU ID
972 * 7 ~ 0 : Assembly ID
973 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
974 */
975static void alc_subsystem_id(struct hda_codec *codec,
976 unsigned int porta, unsigned int porte,
977 unsigned int portd)
978{
Kailang Yangc9b58002007-10-16 14:30:01 +0200979 unsigned int ass, tmp, i;
980 unsigned nid;
981 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200982
Kailang Yangc9b58002007-10-16 14:30:01 +0200983 ass = codec->subsystem_id & 0xffff;
984 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
985 goto do_sku;
986
Kailang Yangea1fb292008-08-26 12:58:38 +0200987 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200988 * 31~30 : port conetcivity
989 * 29~21 : reserve
990 * 20 : PCBEEP input
991 * 19~16 : Check sum (15:1)
992 * 15~1 : Custom
993 * 0 : override
994 */
995 nid = 0x1d;
996 if (codec->vendor_id == 0x10ec0260)
997 nid = 0x17;
998 ass = snd_hda_codec_read(codec, nid, 0,
999 AC_VERB_GET_CONFIG_DEFAULT, 0);
1000 if (!(ass & 1) && !(ass & 0x100000))
1001 return;
1002 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001003 return;
1004
Kailang Yangc9b58002007-10-16 14:30:01 +02001005 /* check sum */
1006 tmp = 0;
1007 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001008 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001009 tmp++;
1010 }
1011 if (((ass >> 16) & 0xf) != tmp)
1012 return;
1013do_sku:
1014 /*
1015 * 0 : override
1016 * 1 : Swap Jack
1017 * 2 : 0 --> Desktop, 1 --> Laptop
1018 * 3~5 : External Amplifier control
1019 * 7~6 : Reserved
1020 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001021 tmp = (ass & 0x38) >> 3; /* external Amp control */
1022 switch (tmp) {
1023 case 1:
1024 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1025 break;
1026 case 3:
1027 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1028 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001029 case 7:
1030 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1031 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001032 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001033 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001034 case 0x10ec0260:
1035 snd_hda_codec_write(codec, 0x0f, 0,
1036 AC_VERB_SET_EAPD_BTLENABLE, 2);
1037 snd_hda_codec_write(codec, 0x10, 0,
1038 AC_VERB_SET_EAPD_BTLENABLE, 2);
1039 break;
1040 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001041 case 0x10ec0267:
1042 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001043 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001044 case 0x10ec0660:
1045 case 0x10ec0662:
1046 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001047 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001048 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001049 snd_hda_codec_write(codec, 0x14, 0,
1050 AC_VERB_SET_EAPD_BTLENABLE, 2);
1051 snd_hda_codec_write(codec, 0x15, 0,
1052 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001053 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 switch (codec->vendor_id) {
1056 case 0x10ec0260:
1057 snd_hda_codec_write(codec, 0x1a, 0,
1058 AC_VERB_SET_COEF_INDEX, 7);
1059 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1060 AC_VERB_GET_PROC_COEF, 0);
1061 snd_hda_codec_write(codec, 0x1a, 0,
1062 AC_VERB_SET_COEF_INDEX, 7);
1063 snd_hda_codec_write(codec, 0x1a, 0,
1064 AC_VERB_SET_PROC_COEF,
1065 tmp | 0x2010);
1066 break;
1067 case 0x10ec0262:
1068 case 0x10ec0880:
1069 case 0x10ec0882:
1070 case 0x10ec0883:
1071 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001072 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001073 snd_hda_codec_write(codec, 0x20, 0,
1074 AC_VERB_SET_COEF_INDEX, 7);
1075 tmp = snd_hda_codec_read(codec, 0x20, 0,
1076 AC_VERB_GET_PROC_COEF, 0);
1077 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001078 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001079 snd_hda_codec_write(codec, 0x20, 0,
1080 AC_VERB_SET_PROC_COEF,
1081 tmp | 0x2010);
1082 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001083 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001084 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001085 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001086 case 0x10ec0267:
1087 case 0x10ec0268:
1088 snd_hda_codec_write(codec, 0x20, 0,
1089 AC_VERB_SET_COEF_INDEX, 7);
1090 tmp = snd_hda_codec_read(codec, 0x20, 0,
1091 AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001093 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001094 snd_hda_codec_write(codec, 0x20, 0,
1095 AC_VERB_SET_PROC_COEF,
1096 tmp | 0x3000);
1097 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001099 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 break;
1101 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001102
Kailang Yang8c427222008-01-10 13:03:59 +01001103 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 * when the external headphone out jack is plugged"
1105 */
Kailang Yang8c427222008-01-10 13:03:59 +01001106 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001107 return;
1108 /*
1109 * 10~8 : Jack location
1110 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1111 * 14~13: Resvered
1112 * 15 : 1 --> enable the function "Mute internal speaker
1113 * when the external headphone out jack is plugged"
1114 */
1115 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001116 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001118 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 else
1120 return;
1121 }
1122
1123 if (!spec->autocfg.hp_pins[0]) {
1124 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1125 if (tmp == 0)
1126 spec->autocfg.hp_pins[0] = porta;
1127 else if (tmp == 1)
1128 spec->autocfg.hp_pins[0] = porte;
1129 else if (tmp == 2)
1130 spec->autocfg.hp_pins[0] = portd;
1131 else
1132 return;
1133 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001134 if (spec->autocfg.hp_pins[0])
1135 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1136 AC_VERB_SET_UNSOLICITED_ENABLE,
1137 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001138
Takashi Iwai4605b712008-10-31 14:18:24 +01001139#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001140 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1141 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1142 snd_hda_codec_write(codec,
1143 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1144 AC_VERB_SET_UNSOLICITED_ENABLE,
1145 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001146#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001147
Kailang Yangc9b58002007-10-16 14:30:01 +02001148 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001149}
1150
Takashi Iwai41e41f12005-06-08 14:48:49 +02001151/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001152 * Fix-up pin default configurations
1153 */
1154
1155struct alc_pincfg {
1156 hda_nid_t nid;
1157 u32 val;
1158};
1159
1160static void alc_fix_pincfg(struct hda_codec *codec,
1161 const struct snd_pci_quirk *quirk,
1162 const struct alc_pincfg **pinfix)
1163{
1164 const struct alc_pincfg *cfg;
1165
1166 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1167 if (!quirk)
1168 return;
1169
1170 cfg = pinfix[quirk->value];
1171 for (; cfg->nid; cfg++) {
1172 int i;
1173 u32 val = cfg->val;
1174 for (i = 0; i < 4; i++) {
1175 snd_hda_codec_write(codec, cfg->nid, 0,
1176 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1177 val & 0xff);
1178 val >>= 8;
1179 }
1180 }
1181}
1182
1183/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001184 * ALC888
1185 */
1186
1187/*
1188 * 2ch mode
1189 */
1190static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1191/* Mic-in jack as mic in */
1192 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1193 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1194/* Line-in jack as Line in */
1195 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1196 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1197/* Line-Out as Front */
1198 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1199 { } /* end */
1200};
1201
1202/*
1203 * 4ch mode
1204 */
1205static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1206/* Mic-in jack as mic in */
1207 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1208 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1209/* Line-in jack as Surround */
1210 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1211 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1212/* Line-Out as Front */
1213 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1214 { } /* end */
1215};
1216
1217/*
1218 * 6ch mode
1219 */
1220static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1221/* Mic-in jack as CLFE */
1222 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1223 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1224/* Line-in jack as Surround */
1225 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1226 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1227/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1228 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1229 { } /* end */
1230};
1231
1232/*
1233 * 8ch mode
1234 */
1235static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1236/* Mic-in jack as CLFE */
1237 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1238 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1239/* Line-in jack as Surround */
1240 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1241 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1242/* Line-Out as Side */
1243 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1244 { } /* end */
1245};
1246
1247static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1248 { 2, alc888_4ST_ch2_intel_init },
1249 { 4, alc888_4ST_ch4_intel_init },
1250 { 6, alc888_4ST_ch6_intel_init },
1251 { 8, alc888_4ST_ch8_intel_init },
1252};
1253
1254/*
1255 * ALC888 Fujitsu Siemens Amillo xa3530
1256 */
1257
1258static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1259/* Front Mic: set to PIN_IN (empty by default) */
1260 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1261/* Connect Internal HP to Front */
1262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1265/* Connect Bass HP to Front */
1266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1268 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1269/* Connect Line-Out side jack (SPDIF) to Side */
1270 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1273/* Connect Mic jack to CLFE */
1274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1276 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1277/* Connect Line-in jack to Surround */
1278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1281/* Connect HP out jack to Front */
1282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1284 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1285/* Enable unsolicited event for HP jack and Line-out jack */
1286 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1287 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1288 {}
1289};
1290
1291static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1292{
1293 unsigned int present;
1294 unsigned int bits;
1295 /* Line out presence */
1296 present = snd_hda_codec_read(codec, 0x17, 0,
1297 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1298 /* HP out presence */
1299 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1301 bits = present ? HDA_AMP_MUTE : 0;
1302 /* Toggle internal speakers muting */
1303 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1304 HDA_AMP_MUTE, bits);
1305 /* Toggle internal bass muting */
1306 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1307 HDA_AMP_MUTE, bits);
1308}
1309
1310static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1311 unsigned int res)
1312{
1313 if (res >> 26 == ALC880_HP_EVENT)
1314 alc888_fujitsu_xa3530_automute(codec);
1315}
1316
1317
1318/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001319 * ALC888 Acer Aspire 4930G model
1320 */
1321
1322static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1323/* Front Mic: set to PIN_IN (empty by default) */
1324 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1325/* Unselect Front Mic by default in input mixer 3 */
1326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001327/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001328 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1329/* Connect Internal HP to front */
1330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1332 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1333/* Connect HP out to front */
1334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1337 { }
1338};
1339
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001340static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001341 /* Front mic only available on one ADC */
1342 {
1343 .num_items = 4,
1344 .items = {
1345 { "Mic", 0x0 },
1346 { "Line", 0x2 },
1347 { "CD", 0x4 },
1348 { "Front Mic", 0xb },
1349 },
1350 },
1351 {
1352 .num_items = 3,
1353 .items = {
1354 { "Mic", 0x0 },
1355 { "Line", 0x2 },
1356 { "CD", 0x4 },
1357 },
1358 }
1359};
1360
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001361static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001362 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1363 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1364 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1365 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1366 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1367 HDA_OUTPUT),
1368 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1369 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1370 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1371 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1372 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1375 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1382 { } /* end */
1383};
1384
1385static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1386{
1387 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001388 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001389 present = snd_hda_codec_read(codec, 0x15, 0,
1390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001391 bits = present ? HDA_AMP_MUTE : 0;
1392 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1393 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001394}
1395
1396static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1397 unsigned int res)
1398{
1399 if (res >> 26 == ALC880_HP_EVENT)
1400 alc888_acer_aspire_4930g_automute(codec);
1401}
1402
1403/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001404 * ALC880 3-stack model
1405 *
1406 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001407 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1408 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 */
1410
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001411static hda_nid_t alc880_dac_nids[4] = {
1412 /* front, rear, clfe, rear_surr */
1413 0x02, 0x05, 0x04, 0x03
1414};
1415
1416static hda_nid_t alc880_adc_nids[3] = {
1417 /* ADC0-2 */
1418 0x07, 0x08, 0x09,
1419};
1420
1421/* The datasheet says the node 0x07 is connected from inputs,
1422 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001423 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001425static hda_nid_t alc880_adc_nids_alt[2] = {
1426 /* ADC1-2 */
1427 0x08, 0x09,
1428};
1429
1430#define ALC880_DIGOUT_NID 0x06
1431#define ALC880_DIGIN_NID 0x0a
1432
1433static struct hda_input_mux alc880_capture_source = {
1434 .num_items = 4,
1435 .items = {
1436 { "Mic", 0x0 },
1437 { "Front Mic", 0x3 },
1438 { "Line", 0x2 },
1439 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001441};
1442
1443/* channel source setting (2/6 channel selection for 3-stack) */
1444/* 2ch mode */
1445static struct hda_verb alc880_threestack_ch2_init[] = {
1446 /* set line-in to input, mute it */
1447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1449 /* set mic-in to input vref 80%, mute it */
1450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 { } /* end */
1453};
1454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455/* 6ch mode */
1456static struct hda_verb alc880_threestack_ch6_init[] = {
1457 /* set line-in to output, unmute it */
1458 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1459 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1460 /* set mic-in to output, unmute it */
1461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1463 { } /* end */
1464};
1465
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001466static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 { 2, alc880_threestack_ch2_init },
1468 { 6, alc880_threestack_ch6_init },
1469};
1470
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001471static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001472 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001473 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001475 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001476 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1477 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001478 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1479 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1488 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1489 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001491 {
1492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1493 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001494 .info = alc_ch_mode_info,
1495 .get = alc_ch_mode_get,
1496 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001497 },
1498 { } /* end */
1499};
1500
1501/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001502static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1503 struct snd_ctl_elem_info *uinfo)
1504{
1505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1506 struct alc_spec *spec = codec->spec;
1507 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001508
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001509 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001510 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1511 HDA_INPUT);
1512 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001513 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001514 return err;
1515}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001517static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1518 unsigned int size, unsigned int __user *tlv)
1519{
1520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1521 struct alc_spec *spec = codec->spec;
1522 int err;
1523
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001524 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001525 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1526 HDA_INPUT);
1527 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001528 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001529 return err;
1530}
1531
1532typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1533 struct snd_ctl_elem_value *ucontrol);
1534
1535static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1536 struct snd_ctl_elem_value *ucontrol,
1537 getput_call_t func)
1538{
1539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1540 struct alc_spec *spec = codec->spec;
1541 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1542 int err;
1543
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001544 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001545 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1546 3, 0, HDA_INPUT);
1547 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001548 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001549 return err;
1550}
1551
1552static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1553 struct snd_ctl_elem_value *ucontrol)
1554{
1555 return alc_cap_getput_caller(kcontrol, ucontrol,
1556 snd_hda_mixer_amp_volume_get);
1557}
1558
1559static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1560 struct snd_ctl_elem_value *ucontrol)
1561{
1562 return alc_cap_getput_caller(kcontrol, ucontrol,
1563 snd_hda_mixer_amp_volume_put);
1564}
1565
1566/* capture mixer elements */
1567#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1568
1569static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1570 struct snd_ctl_elem_value *ucontrol)
1571{
1572 return alc_cap_getput_caller(kcontrol, ucontrol,
1573 snd_hda_mixer_amp_switch_get);
1574}
1575
1576static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1577 struct snd_ctl_elem_value *ucontrol)
1578{
1579 return alc_cap_getput_caller(kcontrol, ucontrol,
1580 snd_hda_mixer_amp_switch_put);
1581}
1582
1583#define DEFINE_CAPMIX(num) \
1584static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1585 { \
1586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1587 .name = "Capture Switch", \
1588 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1589 .count = num, \
1590 .info = alc_cap_sw_info, \
1591 .get = alc_cap_sw_get, \
1592 .put = alc_cap_sw_put, \
1593 }, \
1594 { \
1595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1596 .name = "Capture Volume", \
1597 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1598 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1599 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1600 .count = num, \
1601 .info = alc_cap_vol_info, \
1602 .get = alc_cap_vol_get, \
1603 .put = alc_cap_vol_put, \
1604 .tlv = { .c = alc_cap_vol_tlv }, \
1605 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001606 { \
1607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1608 /* .name = "Capture Source", */ \
1609 .name = "Input Source", \
1610 .count = num, \
1611 .info = alc_mux_enum_info, \
1612 .get = alc_mux_enum_get, \
1613 .put = alc_mux_enum_put, \
1614 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001615 { } /* end */ \
1616}
1617
1618/* up to three ADCs */
1619DEFINE_CAPMIX(1);
1620DEFINE_CAPMIX(2);
1621DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001622
1623
1624/*
1625 * ALC880 5-stack model
1626 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001627 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1628 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001629 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1630 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1631 */
1632
1633/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001634static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001635 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001636 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 { } /* end */
1638};
1639
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001640/* channel source setting (6/8 channel selection for 5-stack) */
1641/* 6ch mode */
1642static struct hda_verb alc880_fivestack_ch6_init[] = {
1643 /* set line-in to input, mute it */
1644 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1645 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001646 { } /* end */
1647};
1648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001649/* 8ch mode */
1650static struct hda_verb alc880_fivestack_ch8_init[] = {
1651 /* set line-in to output, unmute it */
1652 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1653 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1654 { } /* end */
1655};
1656
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001657static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 { 6, alc880_fivestack_ch6_init },
1659 { 8, alc880_fivestack_ch8_init },
1660};
1661
1662
1663/*
1664 * ALC880 6-stack model
1665 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001666 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1667 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001668 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1669 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1670 */
1671
1672static hda_nid_t alc880_6st_dac_nids[4] = {
1673 /* front, rear, clfe, rear_surr */
1674 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001675};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001676
1677static struct hda_input_mux alc880_6stack_capture_source = {
1678 .num_items = 4,
1679 .items = {
1680 { "Mic", 0x0 },
1681 { "Front Mic", 0x1 },
1682 { "Line", 0x2 },
1683 { "CD", 0x4 },
1684 },
1685};
1686
1687/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001688static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001689 { 8, NULL },
1690};
1691
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001692static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001694 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001695 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001696 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001697 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1698 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001699 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1700 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001701 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001702 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1711 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1712 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001713 {
1714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1715 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001716 .info = alc_ch_mode_info,
1717 .get = alc_ch_mode_get,
1718 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001719 },
1720 { } /* end */
1721};
1722
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001723
1724/*
1725 * ALC880 W810 model
1726 *
1727 * W810 has rear IO for:
1728 * Front (DAC 02)
1729 * Surround (DAC 03)
1730 * Center/LFE (DAC 04)
1731 * Digital out (06)
1732 *
1733 * The system also has a pair of internal speakers, and a headphone jack.
1734 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001735 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001736 * There is a variable resistor to control the speaker or headphone
1737 * volume. This is a hardware-only device without a software API.
1738 *
1739 * Plugging headphones in will disable the internal speakers. This is
1740 * implemented in hardware, not via the driver using jack sense. In
1741 * a similar fashion, plugging into the rear socket marked "front" will
1742 * disable both the speakers and headphones.
1743 *
1744 * For input, there's a microphone jack, and an "audio in" jack.
1745 * These may not do anything useful with this driver yet, because I
1746 * haven't setup any initialization verbs for these yet...
1747 */
1748
1749static hda_nid_t alc880_w810_dac_nids[3] = {
1750 /* front, rear/surround, clfe */
1751 0x02, 0x03, 0x04
1752};
1753
1754/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001755static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756 { 6, NULL }
1757};
1758
1759/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001760static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1766 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1770 { } /* end */
1771};
1772
1773
1774/*
1775 * Z710V model
1776 *
1777 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001778 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1779 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001780 */
1781
1782static hda_nid_t alc880_z71v_dac_nids[1] = {
1783 0x02
1784};
1785#define ALC880_Z71V_HP_DAC 0x03
1786
1787/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001788static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789 { 2, NULL }
1790};
1791
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001792static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001796 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1801 { } /* end */
1802};
1803
1804
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805/*
1806 * ALC880 F1734 model
1807 *
1808 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1809 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1810 */
1811
1812static hda_nid_t alc880_f1734_dac_nids[1] = {
1813 0x03
1814};
1815#define ALC880_F1734_HP_DAC 0x02
1816
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001817static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001818 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001819 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001820 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1821 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001822 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1823 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001826 { } /* end */
1827};
1828
Takashi Iwai937b4162008-02-11 14:52:36 +01001829static struct hda_input_mux alc880_f1734_capture_source = {
1830 .num_items = 2,
1831 .items = {
1832 { "Mic", 0x1 },
1833 { "CD", 0x4 },
1834 },
1835};
1836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001837
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001838/*
1839 * ALC880 ASUS model
1840 *
1841 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1842 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1843 * Mic = 0x18, Line = 0x1a
1844 */
1845
1846#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1847#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1848
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001849static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001850 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001852 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001853 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001854 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1855 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001856 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1857 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001864 {
1865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1866 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001867 .info = alc_ch_mode_info,
1868 .get = alc_ch_mode_get,
1869 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001870 },
1871 { } /* end */
1872};
1873
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874/*
1875 * ALC880 ASUS W1V model
1876 *
1877 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1878 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1879 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1880 */
1881
1882/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001883static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001884 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1885 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001886 { } /* end */
1887};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001888
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001889/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001890static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001891 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1892 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1893 { } /* end */
1894};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895
Kailang Yangdf694da2005-12-05 19:42:22 +01001896/* TCL S700 */
1897static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1899 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1902 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001907 { } /* end */
1908};
1909
Kailang Yangccc656c2006-10-17 12:32:26 +02001910/* Uniwill */
1911static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1913 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1914 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1915 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1917 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1918 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1919 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1920 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1921 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1923 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1928 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1929 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1930 {
1931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1932 .name = "Channel Mode",
1933 .info = alc_ch_mode_info,
1934 .get = alc_ch_mode_get,
1935 .put = alc_ch_mode_put,
1936 },
1937 { } /* end */
1938};
1939
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001940static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1948 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1950 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1951 { } /* end */
1952};
1953
Kailang Yangccc656c2006-10-17 12:32:26 +02001954static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1956 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1957 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1958 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1961 { } /* end */
1962};
1963
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001965 * virtual master controls
1966 */
1967
1968/*
1969 * slave controls for virtual master
1970 */
1971static const char *alc_slave_vols[] = {
1972 "Front Playback Volume",
1973 "Surround Playback Volume",
1974 "Center Playback Volume",
1975 "LFE Playback Volume",
1976 "Side Playback Volume",
1977 "Headphone Playback Volume",
1978 "Speaker Playback Volume",
1979 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001980 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001981 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001982 NULL,
1983};
1984
1985static const char *alc_slave_sws[] = {
1986 "Front Playback Switch",
1987 "Surround Playback Switch",
1988 "Center Playback Switch",
1989 "LFE Playback Switch",
1990 "Side Playback Switch",
1991 "Headphone Playback Switch",
1992 "Speaker Playback Switch",
1993 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001994 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001995 NULL,
1996};
1997
1998/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002001
2002static void alc_free_kctls(struct hda_codec *codec);
2003
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004static int alc_build_controls(struct hda_codec *codec)
2005{
2006 struct alc_spec *spec = codec->spec;
2007 int err;
2008 int i;
2009
2010 for (i = 0; i < spec->num_mixers; i++) {
2011 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2012 if (err < 0)
2013 return err;
2014 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002015 if (spec->cap_mixer) {
2016 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2017 if (err < 0)
2018 return err;
2019 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002021 err = snd_hda_create_spdif_out_ctls(codec,
2022 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 if (err < 0)
2024 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002025 if (!spec->no_analog) {
2026 err = snd_hda_create_spdif_share_sw(codec,
2027 &spec->multiout);
2028 if (err < 0)
2029 return err;
2030 spec->multiout.share_spdif = 1;
2031 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032 }
2033 if (spec->dig_in_nid) {
2034 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2035 if (err < 0)
2036 return err;
2037 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002038
2039 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002040 if (!spec->no_analog &&
2041 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002042 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002043 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002044 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002045 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002046 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002047 if (err < 0)
2048 return err;
2049 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002050 if (!spec->no_analog &&
2051 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002052 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2053 NULL, alc_slave_sws);
2054 if (err < 0)
2055 return err;
2056 }
2057
Takashi Iwai603c4012008-07-30 15:01:44 +02002058 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 return 0;
2060}
2061
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002062
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063/*
2064 * initialize the codec volumes, etc
2065 */
2066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002067/*
2068 * generic initialization of ADC, input mixers and output mixers
2069 */
2070static struct hda_verb alc880_volume_init_verbs[] = {
2071 /*
2072 * Unmute ADC0-2 and set the default input to mic-in
2073 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002074 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002076 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002078 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002081 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2082 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002083 * Note: PASD motherboards uses the Line In 2 as the input for front
2084 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 /*
2096 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098 /* set vol=0 to output mixers */
2099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2102 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2103 /* set up input amps for analog loopback */
2104 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113
2114 { }
2115};
2116
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117/*
2118 * 3-stack pin configuration:
2119 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2120 */
2121static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2122 /*
2123 * preset connection lists of input pins
2124 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2125 */
2126 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2127 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2128 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2129
2130 /*
2131 * Set pin mode and muting
2132 */
2133 /* set front pin widgets 0x14 for output */
2134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2136 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2139 /* Mic2 (as headphone out) for HP output */
2140 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2142 /* Line In pin widget for input */
2143 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2144 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2145 /* Line2 (as front mic) pin widget for input and vref at 80% */
2146 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2147 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2148 /* CD pin widget for input */
2149 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2150
2151 { }
2152};
2153
2154/*
2155 * 5-stack pin configuration:
2156 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2157 * line-in/side = 0x1a, f-mic = 0x1b
2158 */
2159static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2160 /*
2161 * preset connection lists of input pins
2162 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2163 */
2164 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2165 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2166
2167 /*
2168 * Set pin mode and muting
2169 */
2170 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2174 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 /* unmute pins for output (no gain on this amp) */
2176 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2178 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2179 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2180
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2184 /* Mic2 (as headphone out) for HP output */
2185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187 /* Line In pin widget for input */
2188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2190 /* Line2 (as front mic) pin widget for input and vref at 80% */
2191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2193 /* CD pin widget for input */
2194 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195
2196 { }
2197};
2198
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199/*
2200 * W810 pin configuration:
2201 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2202 */
2203static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 /* hphone/speaker input selector: front DAC */
2205 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2206
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2211 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2212 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213
2214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217 { }
2218};
2219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220/*
2221 * Z71V pin configuration:
2222 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2223 */
2224static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002229
Takashi Iwai16ded522005-06-10 19:58:24 +02002230 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002234
2235 { }
2236};
2237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238/*
2239 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002240 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2241 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242 */
2243static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2244 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2245
Takashi Iwai16ded522005-06-10 19:58:24 +02002246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002247 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002250 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2254
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002261 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002264
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265 { }
2266};
Takashi Iwai16ded522005-06-10 19:58:24 +02002267
Kailang Yangccc656c2006-10-17 12:32:26 +02002268/*
2269 * Uniwill pin configuration:
2270 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2271 * line = 0x1a
2272 */
2273static struct hda_verb alc880_uniwill_init_verbs[] = {
2274 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2275
2276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2281 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2282 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2283 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2285 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2287 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2290
2291 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2293 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2295 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2297 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2298 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2299 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2300
2301 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2302 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2303
2304 { }
2305};
2306
2307/*
2308* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002309* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002310 */
2311static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2312 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2313
2314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2326
2327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2329 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2333
2334 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2335 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2336
2337 { }
2338};
2339
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002340static struct hda_verb alc880_beep_init_verbs[] = {
2341 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2342 { }
2343};
2344
Kailang Yangccc656c2006-10-17 12:32:26 +02002345/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002346static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002347{
2348 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002349 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002350
2351 present = snd_hda_codec_read(codec, 0x14, 0,
2352 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002353 bits = present ? HDA_AMP_MUTE : 0;
2354 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2355 HDA_AMP_MUTE, bits);
2356 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2357 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002358}
2359
2360/* auto-toggle front mic */
2361static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2362{
2363 unsigned int present;
2364 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002365
2366 present = snd_hda_codec_read(codec, 0x18, 0,
2367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002368 bits = present ? HDA_AMP_MUTE : 0;
2369 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002370}
2371
2372static void alc880_uniwill_automute(struct hda_codec *codec)
2373{
2374 alc880_uniwill_hp_automute(codec);
2375 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002376}
2377
2378static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2379 unsigned int res)
2380{
2381 /* Looks like the unsol event is incompatible with the standard
2382 * definition. 4bit tag is placed at 28 bit!
2383 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002384 switch (res >> 28) {
2385 case ALC880_HP_EVENT:
2386 alc880_uniwill_hp_automute(codec);
2387 break;
2388 case ALC880_MIC_EVENT:
2389 alc880_uniwill_mic_automute(codec);
2390 break;
2391 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002392}
2393
2394static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2395{
2396 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002397 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002398
2399 present = snd_hda_codec_read(codec, 0x14, 0,
2400 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002401 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002403}
2404
2405static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2406{
2407 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002408
Kailang Yangccc656c2006-10-17 12:32:26 +02002409 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002410 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2411 present &= HDA_AMP_VOLMASK;
2412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2413 HDA_AMP_VOLMASK, present);
2414 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2415 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002416}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002417
Kailang Yangccc656c2006-10-17 12:32:26 +02002418static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2419 unsigned int res)
2420{
2421 /* Looks like the unsol event is incompatible with the standard
2422 * definition. 4bit tag is placed at 28 bit!
2423 */
2424 if ((res >> 28) == ALC880_HP_EVENT)
2425 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002426 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002427 alc880_uniwill_p53_dcvol_automute(codec);
2428}
2429
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002430/*
2431 * F1734 pin configuration:
2432 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2433 */
2434static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2439 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2440
2441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2445
2446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2451 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002455
Takashi Iwai937b4162008-02-11 14:52:36 +01002456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2457 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2458
Takashi Iwai16ded522005-06-10 19:58:24 +02002459 { }
2460};
2461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002462/*
2463 * ASUS pin configuration:
2464 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2465 */
2466static struct hda_verb alc880_pin_asus_init_verbs[] = {
2467 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2468 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2469 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2471
2472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480
2481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 { }
2492};
2493
2494/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002495#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2496#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497
Kailang Yangdf694da2005-12-05 19:42:22 +01002498/* Clevo m520g init */
2499static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2500 /* headphone output */
2501 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2502 /* line-out */
2503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2505 /* Line-in */
2506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2508 /* CD */
2509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2510 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2511 /* Mic1 (rear panel) */
2512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 /* Mic2 (front panel) */
2515 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2517 /* headphone */
2518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2519 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 /* change to EAPD mode */
2521 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2522 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2523
2524 { }
2525};
2526
2527static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002528 /* change to EAPD mode */
2529 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2530 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2531
Kailang Yangdf694da2005-12-05 19:42:22 +01002532 /* Headphone output */
2533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2534 /* Front output*/
2535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2536 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2537
2538 /* Line In pin widget for input */
2539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2540 /* CD pin widget for input */
2541 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2542 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2544
2545 /* change to EAPD mode */
2546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2547 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2548
2549 { }
2550};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551
2552/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002553 * LG m1 express dual
2554 *
2555 * Pin assignment:
2556 * Rear Line-In/Out (blue): 0x14
2557 * Build-in Mic-In: 0x15
2558 * Speaker-out: 0x17
2559 * HP-Out (green): 0x1b
2560 * Mic-In/Out (red): 0x19
2561 * SPDIF-Out: 0x1e
2562 */
2563
2564/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2565static hda_nid_t alc880_lg_dac_nids[3] = {
2566 0x05, 0x02, 0x03
2567};
2568
2569/* seems analog CD is not working */
2570static struct hda_input_mux alc880_lg_capture_source = {
2571 .num_items = 3,
2572 .items = {
2573 { "Mic", 0x1 },
2574 { "Line", 0x5 },
2575 { "Internal Mic", 0x6 },
2576 },
2577};
2578
2579/* 2,4,6 channel modes */
2580static struct hda_verb alc880_lg_ch2_init[] = {
2581 /* set line-in and mic-in to input */
2582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2583 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2584 { }
2585};
2586
2587static struct hda_verb alc880_lg_ch4_init[] = {
2588 /* set line-in to out and mic-in to input */
2589 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2590 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2591 { }
2592};
2593
2594static struct hda_verb alc880_lg_ch6_init[] = {
2595 /* set line-in and mic-in to output */
2596 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2597 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2598 { }
2599};
2600
2601static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2602 { 2, alc880_lg_ch2_init },
2603 { 4, alc880_lg_ch4_init },
2604 { 6, alc880_lg_ch6_init },
2605};
2606
2607static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002608 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2609 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002610 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2611 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2614 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2615 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2620 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2621 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2622 {
2623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2624 .name = "Channel Mode",
2625 .info = alc_ch_mode_info,
2626 .get = alc_ch_mode_get,
2627 .put = alc_ch_mode_put,
2628 },
2629 { } /* end */
2630};
2631
2632static struct hda_verb alc880_lg_init_verbs[] = {
2633 /* set capture source to mic-in */
2634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2637 /* mute all amp mixer inputs */
2638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002641 /* line-in to input */
2642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 /* built-in mic */
2645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2647 /* speaker-out */
2648 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650 /* mic-in to input */
2651 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2654 /* HP-out */
2655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658 /* jack sense */
2659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2660 { }
2661};
2662
2663/* toggle speaker-output according to the hp-jack state */
2664static void alc880_lg_automute(struct hda_codec *codec)
2665{
2666 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002667 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002668
2669 present = snd_hda_codec_read(codec, 0x1b, 0,
2670 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002671 bits = present ? HDA_AMP_MUTE : 0;
2672 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2673 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002674}
2675
2676static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2677{
2678 /* Looks like the unsol event is incompatible with the standard
2679 * definition. 4bit tag is placed at 28 bit!
2680 */
2681 if ((res >> 28) == 0x01)
2682 alc880_lg_automute(codec);
2683}
2684
2685/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002686 * LG LW20
2687 *
2688 * Pin assignment:
2689 * Speaker-out: 0x14
2690 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002691 * Built-in Mic-In: 0x19
2692 * Line-In: 0x1b
2693 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002694 * SPDIF-Out: 0x1e
2695 */
2696
Takashi Iwaid6815182006-03-23 16:06:23 +01002697static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002698 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002699 .items = {
2700 { "Mic", 0x0 },
2701 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002702 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002703 },
2704};
2705
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002706#define alc880_lg_lw_modes alc880_threestack_modes
2707
Takashi Iwaid6815182006-03-23 16:06:23 +01002708static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002709 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2710 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2711 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2712 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2713 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2714 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2715 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2716 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2721 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2722 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002723 {
2724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2725 .name = "Channel Mode",
2726 .info = alc_ch_mode_info,
2727 .get = alc_ch_mode_get,
2728 .put = alc_ch_mode_put,
2729 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002730 { } /* end */
2731};
2732
2733static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002734 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2735 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2736 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2737
Takashi Iwaid6815182006-03-23 16:06:23 +01002738 /* set capture source to mic-in */
2739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002743 /* speaker-out */
2744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2746 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 /* mic-in to input */
2750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2752 /* built-in mic */
2753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 /* jack sense */
2756 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2757 { }
2758};
2759
2760/* toggle speaker-output according to the hp-jack state */
2761static void alc880_lg_lw_automute(struct hda_codec *codec)
2762{
2763 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002764 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002765
2766 present = snd_hda_codec_read(codec, 0x1b, 0,
2767 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002768 bits = present ? HDA_AMP_MUTE : 0;
2769 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2770 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002771}
2772
2773static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2774{
2775 /* Looks like the unsol event is incompatible with the standard
2776 * definition. 4bit tag is placed at 28 bit!
2777 */
2778 if ((res >> 28) == 0x01)
2779 alc880_lg_lw_automute(codec);
2780}
2781
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002782static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2783 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2784 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2787 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2788 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2789 { } /* end */
2790};
2791
2792static struct hda_input_mux alc880_medion_rim_capture_source = {
2793 .num_items = 2,
2794 .items = {
2795 { "Mic", 0x0 },
2796 { "Internal Mic", 0x1 },
2797 },
2798};
2799
2800static struct hda_verb alc880_medion_rim_init_verbs[] = {
2801 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2802
2803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2804 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2805
2806 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2807 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2808 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2809 /* Mic2 (as headphone out) for HP output */
2810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2811 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2812 /* Internal Speaker */
2813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2814 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2815
2816 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2817 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2818
2819 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2820 { }
2821};
2822
2823/* toggle speaker-output according to the hp-jack state */
2824static void alc880_medion_rim_automute(struct hda_codec *codec)
2825{
2826 unsigned int present;
2827 unsigned char bits;
2828
2829 present = snd_hda_codec_read(codec, 0x14, 0,
2830 AC_VERB_GET_PIN_SENSE, 0)
2831 & AC_PINSENSE_PRESENCE;
2832 bits = present ? HDA_AMP_MUTE : 0;
2833 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2834 HDA_AMP_MUTE, bits);
2835 if (present)
2836 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2837 else
2838 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2839}
2840
2841static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2842 unsigned int res)
2843{
2844 /* Looks like the unsol event is incompatible with the standard
2845 * definition. 4bit tag is placed at 28 bit!
2846 */
2847 if ((res >> 28) == ALC880_HP_EVENT)
2848 alc880_medion_rim_automute(codec);
2849}
2850
Takashi Iwaicb53c622007-08-10 17:21:45 +02002851#ifdef CONFIG_SND_HDA_POWER_SAVE
2852static struct hda_amp_list alc880_loopbacks[] = {
2853 { 0x0b, HDA_INPUT, 0 },
2854 { 0x0b, HDA_INPUT, 1 },
2855 { 0x0b, HDA_INPUT, 2 },
2856 { 0x0b, HDA_INPUT, 3 },
2857 { 0x0b, HDA_INPUT, 4 },
2858 { } /* end */
2859};
2860
2861static struct hda_amp_list alc880_lg_loopbacks[] = {
2862 { 0x0b, HDA_INPUT, 1 },
2863 { 0x0b, HDA_INPUT, 6 },
2864 { 0x0b, HDA_INPUT, 7 },
2865 { } /* end */
2866};
2867#endif
2868
Takashi Iwaid6815182006-03-23 16:06:23 +01002869/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002870 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002871 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002872
Linus Torvalds1da177e2005-04-16 15:20:36 -07002873static int alc_init(struct hda_codec *codec)
2874{
2875 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876 unsigned int i;
2877
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002878 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002879 if (codec->vendor_id == 0x10ec0888)
2880 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002881
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 for (i = 0; i < spec->num_init_verbs; i++)
2883 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002884
2885 if (spec->init_hook)
2886 spec->init_hook(codec);
2887
Linus Torvalds1da177e2005-04-16 15:20:36 -07002888 return 0;
2889}
2890
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002891static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2892{
2893 struct alc_spec *spec = codec->spec;
2894
2895 if (spec->unsol_event)
2896 spec->unsol_event(codec, res);
2897}
2898
Takashi Iwaicb53c622007-08-10 17:21:45 +02002899#ifdef CONFIG_SND_HDA_POWER_SAVE
2900static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2901{
2902 struct alc_spec *spec = codec->spec;
2903 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2904}
2905#endif
2906
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907/*
2908 * Analog playback callbacks
2909 */
2910static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2911 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002912 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002913{
2914 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002915 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2916 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917}
2918
2919static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2920 struct hda_codec *codec,
2921 unsigned int stream_tag,
2922 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002923 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002924{
2925 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002926 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2927 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928}
2929
2930static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2931 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002932 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933{
2934 struct alc_spec *spec = codec->spec;
2935 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2936}
2937
2938/*
2939 * Digital out
2940 */
2941static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2942 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002943 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944{
2945 struct alc_spec *spec = codec->spec;
2946 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2947}
2948
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002949static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2950 struct hda_codec *codec,
2951 unsigned int stream_tag,
2952 unsigned int format,
2953 struct snd_pcm_substream *substream)
2954{
2955 struct alc_spec *spec = codec->spec;
2956 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2957 stream_tag, format, substream);
2958}
2959
Linus Torvalds1da177e2005-04-16 15:20:36 -07002960static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2961 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002962 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963{
2964 struct alc_spec *spec = codec->spec;
2965 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2966}
2967
2968/*
2969 * Analog capture
2970 */
Takashi Iwai63300792008-01-24 15:31:36 +01002971static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 struct hda_codec *codec,
2973 unsigned int stream_tag,
2974 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002975 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976{
2977 struct alc_spec *spec = codec->spec;
2978
Takashi Iwai63300792008-01-24 15:31:36 +01002979 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980 stream_tag, 0, format);
2981 return 0;
2982}
2983
Takashi Iwai63300792008-01-24 15:31:36 +01002984static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002986 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002987{
2988 struct alc_spec *spec = codec->spec;
2989
Takashi Iwai888afa12008-03-18 09:57:50 +01002990 snd_hda_codec_cleanup_stream(codec,
2991 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002992 return 0;
2993}
2994
2995
2996/*
2997 */
2998static struct hda_pcm_stream alc880_pcm_analog_playback = {
2999 .substreams = 1,
3000 .channels_min = 2,
3001 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 .ops = {
3004 .open = alc880_playback_pcm_open,
3005 .prepare = alc880_playback_pcm_prepare,
3006 .cleanup = alc880_playback_pcm_cleanup
3007 },
3008};
3009
3010static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003011 .substreams = 1,
3012 .channels_min = 2,
3013 .channels_max = 2,
3014 /* NID is set in alc_build_pcms */
3015};
3016
3017static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3018 .substreams = 1,
3019 .channels_min = 2,
3020 .channels_max = 2,
3021 /* NID is set in alc_build_pcms */
3022};
3023
3024static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3025 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003026 .channels_min = 2,
3027 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003030 .prepare = alc880_alt_capture_pcm_prepare,
3031 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003032 },
3033};
3034
3035static struct hda_pcm_stream alc880_pcm_digital_playback = {
3036 .substreams = 1,
3037 .channels_min = 2,
3038 .channels_max = 2,
3039 /* NID is set in alc_build_pcms */
3040 .ops = {
3041 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003042 .close = alc880_dig_playback_pcm_close,
3043 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07003044 },
3045};
3046
3047static struct hda_pcm_stream alc880_pcm_digital_capture = {
3048 .substreams = 1,
3049 .channels_min = 2,
3050 .channels_max = 2,
3051 /* NID is set in alc_build_pcms */
3052};
3053
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003054/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003055static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003056 .substreams = 0,
3057 .channels_min = 0,
3058 .channels_max = 0,
3059};
3060
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061static int alc_build_pcms(struct hda_codec *codec)
3062{
3063 struct alc_spec *spec = codec->spec;
3064 struct hda_pcm *info = spec->pcm_rec;
3065 int i;
3066
3067 codec->num_pcms = 1;
3068 codec->pcm_info = info;
3069
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003070 if (spec->no_analog)
3071 goto skip_analog;
3072
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003074 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003075 if (snd_BUG_ON(!spec->multiout.dac_nids))
3076 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003077 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3078 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3079 }
3080 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003081 if (snd_BUG_ON(!spec->adc_nids))
3082 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003083 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3084 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3085 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086
Takashi Iwai4a471b72005-12-07 13:56:29 +01003087 if (spec->channel_mode) {
3088 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3089 for (i = 0; i < spec->num_channel_mode; i++) {
3090 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3091 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3092 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093 }
3094 }
3095
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003096 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003097 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003098 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003099 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003100 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003102 if (spec->dig_out_type)
3103 info->pcm_type = spec->dig_out_type;
3104 else
3105 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003106 if (spec->multiout.dig_out_nid &&
3107 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3109 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3110 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003111 if (spec->dig_in_nid &&
3112 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003113 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3114 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3115 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003116 /* FIXME: do we need this for all Realtek codec models? */
3117 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003118 }
3119
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003120 if (spec->no_analog)
3121 return 0;
3122
Takashi Iwaie08a0072006-09-07 17:52:14 +02003123 /* If the use of more than one ADC is requested for the current
3124 * model, configure a second analog capture-only PCM.
3125 */
3126 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003127 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3128 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003129 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003130 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003131 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003132 if (spec->alt_dac_nid) {
3133 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3134 *spec->stream_analog_alt_playback;
3135 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3136 spec->alt_dac_nid;
3137 } else {
3138 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3139 alc_pcm_null_stream;
3140 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3141 }
3142 if (spec->num_adc_nids > 1) {
3143 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3144 *spec->stream_analog_alt_capture;
3145 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3146 spec->adc_nids[1];
3147 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3148 spec->num_adc_nids - 1;
3149 } else {
3150 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3151 alc_pcm_null_stream;
3152 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003153 }
3154 }
3155
Linus Torvalds1da177e2005-04-16 15:20:36 -07003156 return 0;
3157}
3158
Takashi Iwai603c4012008-07-30 15:01:44 +02003159static void alc_free_kctls(struct hda_codec *codec)
3160{
3161 struct alc_spec *spec = codec->spec;
3162
3163 if (spec->kctls.list) {
3164 struct snd_kcontrol_new *kctl = spec->kctls.list;
3165 int i;
3166 for (i = 0; i < spec->kctls.used; i++)
3167 kfree(kctl[i].name);
3168 }
3169 snd_array_free(&spec->kctls);
3170}
3171
Linus Torvalds1da177e2005-04-16 15:20:36 -07003172static void alc_free(struct hda_codec *codec)
3173{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003176 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 return;
3178
Takashi Iwai603c4012008-07-30 15:01:44 +02003179 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003180 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02003181 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003182}
3183
Takashi Iwaie044c392008-10-27 16:56:24 +01003184#ifdef SND_HDA_NEEDS_RESUME
3185static void store_pin_configs(struct hda_codec *codec)
3186{
3187 struct alc_spec *spec = codec->spec;
3188 hda_nid_t nid, end_nid;
3189
3190 end_nid = codec->start_nid + codec->num_nodes;
3191 for (nid = codec->start_nid; nid < end_nid; nid++) {
3192 unsigned int wid_caps = get_wcaps(codec, nid);
3193 unsigned int wid_type =
3194 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3195 if (wid_type != AC_WID_PIN)
3196 continue;
3197 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3198 break;
3199 spec->pin_nids[spec->num_pins] = nid;
3200 spec->pin_cfgs[spec->num_pins] =
3201 snd_hda_codec_read(codec, nid, 0,
3202 AC_VERB_GET_CONFIG_DEFAULT, 0);
3203 spec->num_pins++;
3204 }
3205}
3206
3207static void resume_pin_configs(struct hda_codec *codec)
3208{
3209 struct alc_spec *spec = codec->spec;
3210 int i;
3211
3212 for (i = 0; i < spec->num_pins; i++) {
3213 hda_nid_t pin_nid = spec->pin_nids[i];
3214 unsigned int pin_config = spec->pin_cfgs[i];
3215 snd_hda_codec_write(codec, pin_nid, 0,
3216 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3217 pin_config & 0x000000ff);
3218 snd_hda_codec_write(codec, pin_nid, 0,
3219 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3220 (pin_config & 0x0000ff00) >> 8);
3221 snd_hda_codec_write(codec, pin_nid, 0,
3222 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3223 (pin_config & 0x00ff0000) >> 16);
3224 snd_hda_codec_write(codec, pin_nid, 0,
3225 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3226 pin_config >> 24);
3227 }
3228}
3229
3230static int alc_resume(struct hda_codec *codec)
3231{
3232 resume_pin_configs(codec);
3233 codec->patch_ops.init(codec);
3234 snd_hda_codec_resume_amp(codec);
3235 snd_hda_codec_resume_cache(codec);
3236 return 0;
3237}
3238#else
3239#define store_pin_configs(codec)
3240#endif
3241
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242/*
3243 */
3244static struct hda_codec_ops alc_patch_ops = {
3245 .build_controls = alc_build_controls,
3246 .build_pcms = alc_build_pcms,
3247 .init = alc_init,
3248 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003249 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003250#ifdef SND_HDA_NEEDS_RESUME
3251 .resume = alc_resume,
3252#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003253#ifdef CONFIG_SND_HDA_POWER_SAVE
3254 .check_power_status = alc_check_power_status,
3255#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003256};
3257
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003258
3259/*
3260 * Test configuration for debugging
3261 *
3262 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3263 * enum controls.
3264 */
3265#ifdef CONFIG_SND_DEBUG
3266static hda_nid_t alc880_test_dac_nids[4] = {
3267 0x02, 0x03, 0x04, 0x05
3268};
3269
3270static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003271 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003272 .items = {
3273 { "In-1", 0x0 },
3274 { "In-2", 0x1 },
3275 { "In-3", 0x2 },
3276 { "In-4", 0x3 },
3277 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003278 { "Front", 0x5 },
3279 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003280 },
3281};
3282
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003283static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003284 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003285 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003286 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003287 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003288};
3289
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003290static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3291 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003292{
3293 static char *texts[] = {
3294 "N/A", "Line Out", "HP Out",
3295 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3296 };
3297 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3298 uinfo->count = 1;
3299 uinfo->value.enumerated.items = 8;
3300 if (uinfo->value.enumerated.item >= 8)
3301 uinfo->value.enumerated.item = 7;
3302 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3303 return 0;
3304}
3305
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003306static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3307 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003308{
3309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3310 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3311 unsigned int pin_ctl, item = 0;
3312
3313 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3314 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3315 if (pin_ctl & AC_PINCTL_OUT_EN) {
3316 if (pin_ctl & AC_PINCTL_HP_EN)
3317 item = 2;
3318 else
3319 item = 1;
3320 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3321 switch (pin_ctl & AC_PINCTL_VREFEN) {
3322 case AC_PINCTL_VREF_HIZ: item = 3; break;
3323 case AC_PINCTL_VREF_50: item = 4; break;
3324 case AC_PINCTL_VREF_GRD: item = 5; break;
3325 case AC_PINCTL_VREF_80: item = 6; break;
3326 case AC_PINCTL_VREF_100: item = 7; break;
3327 }
3328 }
3329 ucontrol->value.enumerated.item[0] = item;
3330 return 0;
3331}
3332
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003333static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3334 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003335{
3336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3337 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3338 static unsigned int ctls[] = {
3339 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3340 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3341 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3342 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3343 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3344 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3345 };
3346 unsigned int old_ctl, new_ctl;
3347
3348 old_ctl = snd_hda_codec_read(codec, nid, 0,
3349 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3350 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3351 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003352 int val;
3353 snd_hda_codec_write_cache(codec, nid, 0,
3354 AC_VERB_SET_PIN_WIDGET_CONTROL,
3355 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003356 val = ucontrol->value.enumerated.item[0] >= 3 ?
3357 HDA_AMP_MUTE : 0;
3358 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3359 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003360 return 1;
3361 }
3362 return 0;
3363}
3364
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003365static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3366 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003367{
3368 static char *texts[] = {
3369 "Front", "Surround", "CLFE", "Side"
3370 };
3371 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3372 uinfo->count = 1;
3373 uinfo->value.enumerated.items = 4;
3374 if (uinfo->value.enumerated.item >= 4)
3375 uinfo->value.enumerated.item = 3;
3376 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3377 return 0;
3378}
3379
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003380static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3381 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003382{
3383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3384 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3385 unsigned int sel;
3386
3387 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3388 ucontrol->value.enumerated.item[0] = sel & 3;
3389 return 0;
3390}
3391
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003392static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3393 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003394{
3395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3396 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3397 unsigned int sel;
3398
3399 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3400 if (ucontrol->value.enumerated.item[0] != sel) {
3401 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003402 snd_hda_codec_write_cache(codec, nid, 0,
3403 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003404 return 1;
3405 }
3406 return 0;
3407}
3408
3409#define PIN_CTL_TEST(xname,nid) { \
3410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3411 .name = xname, \
3412 .info = alc_test_pin_ctl_info, \
3413 .get = alc_test_pin_ctl_get, \
3414 .put = alc_test_pin_ctl_put, \
3415 .private_value = nid \
3416 }
3417
3418#define PIN_SRC_TEST(xname,nid) { \
3419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3420 .name = xname, \
3421 .info = alc_test_pin_src_info, \
3422 .get = alc_test_pin_src_get, \
3423 .put = alc_test_pin_src_put, \
3424 .private_value = nid \
3425 }
3426
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003427static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3429 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3430 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3431 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3433 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3434 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3435 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003436 PIN_CTL_TEST("Front Pin Mode", 0x14),
3437 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3438 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3439 PIN_CTL_TEST("Side Pin Mode", 0x17),
3440 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3441 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3442 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3443 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3444 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3445 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3446 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3447 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3448 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3449 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3450 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3451 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3452 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3453 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3454 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3455 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003458 {
3459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3460 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003461 .info = alc_ch_mode_info,
3462 .get = alc_ch_mode_get,
3463 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003464 },
3465 { } /* end */
3466};
3467
3468static struct hda_verb alc880_test_init_verbs[] = {
3469 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003478 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003483 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3487 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003488 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003493 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3497 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3498 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003499 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3501 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003504 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003506 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003508 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003510 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003511 /* Analog input/passthru */
3512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003517 { }
3518};
3519#endif
3520
Linus Torvalds1da177e2005-04-16 15:20:36 -07003521/*
3522 */
3523
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003524static const char *alc880_models[ALC880_MODEL_LAST] = {
3525 [ALC880_3ST] = "3stack",
3526 [ALC880_TCL_S700] = "tcl",
3527 [ALC880_3ST_DIG] = "3stack-digout",
3528 [ALC880_CLEVO] = "clevo",
3529 [ALC880_5ST] = "5stack",
3530 [ALC880_5ST_DIG] = "5stack-digout",
3531 [ALC880_W810] = "w810",
3532 [ALC880_Z71V] = "z71v",
3533 [ALC880_6ST] = "6stack",
3534 [ALC880_6ST_DIG] = "6stack-digout",
3535 [ALC880_ASUS] = "asus",
3536 [ALC880_ASUS_W1V] = "asus-w1v",
3537 [ALC880_ASUS_DIG] = "asus-dig",
3538 [ALC880_ASUS_DIG2] = "asus-dig2",
3539 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003540 [ALC880_UNIWILL_P53] = "uniwill-p53",
3541 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003542 [ALC880_F1734] = "F1734",
3543 [ALC880_LG] = "lg",
3544 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003545 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003546#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003547 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003548#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003549 [ALC880_AUTO] = "auto",
3550};
3551
3552static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003553 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003554 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3555 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3556 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3557 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3558 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3559 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3560 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3561 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003562 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3563 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003564 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3565 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3566 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3567 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3568 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3569 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3570 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3571 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3572 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3573 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003574 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003575 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3576 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3577 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003578 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003579 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003580 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3581 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3583 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003584 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3585 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3586 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3587 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003588 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3589 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003590 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003591 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003592 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003593 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003594 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3595 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003596 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003597 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003598 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003599 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003600 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003601 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003602 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003603 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003604 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003605 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3606 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003608 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3609 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3610 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3611 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003612 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3613 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003614 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003615 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003616 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3617 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003618 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3619 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3620 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003621 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3622 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3623 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003624 {}
3625};
3626
Takashi Iwai16ded522005-06-10 19:58:24 +02003627/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003628 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003629 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003630static struct alc_config_preset alc880_presets[] = {
3631 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003633 .init_verbs = { alc880_volume_init_verbs,
3634 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003636 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003637 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3638 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003639 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003640 .input_mux = &alc880_capture_source,
3641 },
3642 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003643 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003644 .init_verbs = { alc880_volume_init_verbs,
3645 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003646 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003647 .dac_nids = alc880_dac_nids,
3648 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003649 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3650 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003651 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003652 .input_mux = &alc880_capture_source,
3653 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003654 [ALC880_TCL_S700] = {
3655 .mixers = { alc880_tcl_s700_mixer },
3656 .init_verbs = { alc880_volume_init_verbs,
3657 alc880_pin_tcl_S700_init_verbs,
3658 alc880_gpio2_init_verbs },
3659 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3660 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003661 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3662 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003663 .hp_nid = 0x03,
3664 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3665 .channel_mode = alc880_2_jack_modes,
3666 .input_mux = &alc880_capture_source,
3667 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003668 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003669 .mixers = { alc880_three_stack_mixer,
3670 alc880_five_stack_mixer},
3671 .init_verbs = { alc880_volume_init_verbs,
3672 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003673 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3674 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003675 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3676 .channel_mode = alc880_fivestack_modes,
3677 .input_mux = &alc880_capture_source,
3678 },
3679 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003680 .mixers = { alc880_three_stack_mixer,
3681 alc880_five_stack_mixer },
3682 .init_verbs = { alc880_volume_init_verbs,
3683 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003684 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3685 .dac_nids = alc880_dac_nids,
3686 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3688 .channel_mode = alc880_fivestack_modes,
3689 .input_mux = &alc880_capture_source,
3690 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003691 [ALC880_6ST] = {
3692 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693 .init_verbs = { alc880_volume_init_verbs,
3694 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003695 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3696 .dac_nids = alc880_6st_dac_nids,
3697 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3698 .channel_mode = alc880_sixstack_modes,
3699 .input_mux = &alc880_6stack_capture_source,
3700 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003701 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .init_verbs = { alc880_volume_init_verbs,
3704 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003705 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3706 .dac_nids = alc880_6st_dac_nids,
3707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3709 .channel_mode = alc880_sixstack_modes,
3710 .input_mux = &alc880_6stack_capture_source,
3711 },
3712 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003713 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003714 .init_verbs = { alc880_volume_init_verbs,
3715 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003716 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003717 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3718 .dac_nids = alc880_w810_dac_nids,
3719 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003720 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3721 .channel_mode = alc880_w810_modes,
3722 .input_mux = &alc880_capture_source,
3723 },
3724 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003726 .init_verbs = { alc880_volume_init_verbs,
3727 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3729 .dac_nids = alc880_z71v_dac_nids,
3730 .dig_out_nid = ALC880_DIGOUT_NID,
3731 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003732 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3733 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003734 .input_mux = &alc880_capture_source,
3735 },
3736 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003737 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738 .init_verbs = { alc880_volume_init_verbs,
3739 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3741 .dac_nids = alc880_f1734_dac_nids,
3742 .hp_nid = 0x02,
3743 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3744 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003745 .input_mux = &alc880_f1734_capture_source,
3746 .unsol_event = alc880_uniwill_p53_unsol_event,
3747 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003748 },
3749 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003750 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003751 .init_verbs = { alc880_volume_init_verbs,
3752 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 alc880_gpio1_init_verbs },
3754 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3755 .dac_nids = alc880_asus_dac_nids,
3756 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3757 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003758 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003759 .input_mux = &alc880_capture_source,
3760 },
3761 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003763 .init_verbs = { alc880_volume_init_verbs,
3764 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003765 alc880_gpio1_init_verbs },
3766 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3767 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003768 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003769 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3770 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003771 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003772 .input_mux = &alc880_capture_source,
3773 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003774 [ALC880_ASUS_DIG2] = {
3775 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003776 .init_verbs = { alc880_volume_init_verbs,
3777 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003778 alc880_gpio2_init_verbs }, /* use GPIO2 */
3779 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3780 .dac_nids = alc880_asus_dac_nids,
3781 .dig_out_nid = ALC880_DIGOUT_NID,
3782 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3783 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003784 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003785 .input_mux = &alc880_capture_source,
3786 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003787 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003789 .init_verbs = { alc880_volume_init_verbs,
3790 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 alc880_gpio1_init_verbs },
3792 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3793 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003794 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003795 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3796 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003797 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003798 .input_mux = &alc880_capture_source,
3799 },
3800 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003801 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003802 .init_verbs = { alc880_volume_init_verbs,
3803 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003804 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3805 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003806 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3808 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003809 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003810 .input_mux = &alc880_capture_source,
3811 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003812 [ALC880_UNIWILL] = {
3813 .mixers = { alc880_uniwill_mixer },
3814 .init_verbs = { alc880_volume_init_verbs,
3815 alc880_uniwill_init_verbs },
3816 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3817 .dac_nids = alc880_asus_dac_nids,
3818 .dig_out_nid = ALC880_DIGOUT_NID,
3819 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3820 .channel_mode = alc880_threestack_modes,
3821 .need_dac_fix = 1,
3822 .input_mux = &alc880_capture_source,
3823 .unsol_event = alc880_uniwill_unsol_event,
3824 .init_hook = alc880_uniwill_automute,
3825 },
3826 [ALC880_UNIWILL_P53] = {
3827 .mixers = { alc880_uniwill_p53_mixer },
3828 .init_verbs = { alc880_volume_init_verbs,
3829 alc880_uniwill_p53_init_verbs },
3830 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3831 .dac_nids = alc880_asus_dac_nids,
3832 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003833 .channel_mode = alc880_threestack_modes,
3834 .input_mux = &alc880_capture_source,
3835 .unsol_event = alc880_uniwill_p53_unsol_event,
3836 .init_hook = alc880_uniwill_p53_hp_automute,
3837 },
3838 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003839 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003840 alc880_pcbeep_mixer, },
3841 .init_verbs = { alc880_volume_init_verbs,
3842 alc880_uniwill_p53_init_verbs,
3843 alc880_beep_init_verbs },
3844 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3845 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003846 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003847 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3848 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003849 .input_mux = &alc880_capture_source,
3850 .unsol_event = alc880_uniwill_p53_unsol_event,
3851 .init_hook = alc880_uniwill_p53_hp_automute,
3852 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003853 [ALC880_CLEVO] = {
3854 .mixers = { alc880_three_stack_mixer },
3855 .init_verbs = { alc880_volume_init_verbs,
3856 alc880_pin_clevo_init_verbs },
3857 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3858 .dac_nids = alc880_dac_nids,
3859 .hp_nid = 0x03,
3860 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3861 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003862 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003863 .input_mux = &alc880_capture_source,
3864 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003865 [ALC880_LG] = {
3866 .mixers = { alc880_lg_mixer },
3867 .init_verbs = { alc880_volume_init_verbs,
3868 alc880_lg_init_verbs },
3869 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3870 .dac_nids = alc880_lg_dac_nids,
3871 .dig_out_nid = ALC880_DIGOUT_NID,
3872 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3873 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003874 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003875 .input_mux = &alc880_lg_capture_source,
3876 .unsol_event = alc880_lg_unsol_event,
3877 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879 .loopbacks = alc880_lg_loopbacks,
3880#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003881 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003882 [ALC880_LG_LW] = {
3883 .mixers = { alc880_lg_lw_mixer },
3884 .init_verbs = { alc880_volume_init_verbs,
3885 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003887 .dac_nids = alc880_dac_nids,
3888 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003889 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3890 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003891 .input_mux = &alc880_lg_lw_capture_source,
3892 .unsol_event = alc880_lg_lw_unsol_event,
3893 .init_hook = alc880_lg_lw_automute,
3894 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003895 [ALC880_MEDION_RIM] = {
3896 .mixers = { alc880_medion_rim_mixer },
3897 .init_verbs = { alc880_volume_init_verbs,
3898 alc880_medion_rim_init_verbs,
3899 alc_gpio2_init_verbs },
3900 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3901 .dac_nids = alc880_dac_nids,
3902 .dig_out_nid = ALC880_DIGOUT_NID,
3903 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3904 .channel_mode = alc880_2_jack_modes,
3905 .input_mux = &alc880_medion_rim_capture_source,
3906 .unsol_event = alc880_medion_rim_unsol_event,
3907 .init_hook = alc880_medion_rim_automute,
3908 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003909#ifdef CONFIG_SND_DEBUG
3910 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911 .mixers = { alc880_test_mixer },
3912 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003913 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3914 .dac_nids = alc880_test_dac_nids,
3915 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003916 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3917 .channel_mode = alc880_test_modes,
3918 .input_mux = &alc880_test_capture_source,
3919 },
3920#endif
3921};
3922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003923/*
3924 * Automatic parse of I/O pins from the BIOS configuration
3925 */
3926
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003927enum {
3928 ALC_CTL_WIDGET_VOL,
3929 ALC_CTL_WIDGET_MUTE,
3930 ALC_CTL_BIND_MUTE,
3931};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003932static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003933 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3934 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003935 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003936};
3937
3938/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003939static int add_control(struct alc_spec *spec, int type, const char *name,
3940 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003942 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003943
Takashi Iwai603c4012008-07-30 15:01:44 +02003944 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3945 knew = snd_array_new(&spec->kctls);
3946 if (!knew)
3947 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003948 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003949 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003950 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003951 return -ENOMEM;
3952 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003953 return 0;
3954}
3955
3956#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3957#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3958#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3959#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3960#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3961#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3962#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3963#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3964#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3965#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3966#define ALC880_PIN_CD_NID 0x1c
3967
3968/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003969static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3970 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003971{
3972 hda_nid_t nid;
3973 int assigned[4];
3974 int i, j;
3975
3976 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003977 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003978
3979 /* check the pins hardwired to audio widget */
3980 for (i = 0; i < cfg->line_outs; i++) {
3981 nid = cfg->line_out_pins[i];
3982 if (alc880_is_fixed_pin(nid)) {
3983 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003984 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 assigned[idx] = 1;
3986 }
3987 }
3988 /* left pins can be connect to any audio widget */
3989 for (i = 0; i < cfg->line_outs; i++) {
3990 nid = cfg->line_out_pins[i];
3991 if (alc880_is_fixed_pin(nid))
3992 continue;
3993 /* search for an empty channel */
3994 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003995 if (!assigned[j]) {
3996 spec->multiout.dac_nids[i] =
3997 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998 assigned[j] = 1;
3999 break;
4000 }
4001 }
4002 }
4003 spec->multiout.num_dacs = cfg->line_outs;
4004 return 0;
4005}
4006
4007/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004008static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4009 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010{
4011 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004012 static const char *chname[4] = {
4013 "Front", "Surround", NULL /*CLFE*/, "Side"
4014 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004015 hda_nid_t nid;
4016 int i, err;
4017
4018 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004019 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004020 continue;
4021 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4022 if (i == 2) {
4023 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004024 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4025 "Center Playback Volume",
4026 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4027 HDA_OUTPUT));
4028 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004030 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4031 "LFE Playback Volume",
4032 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4033 HDA_OUTPUT));
4034 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004035 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004036 err = add_control(spec, ALC_CTL_BIND_MUTE,
4037 "Center Playback Switch",
4038 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4039 HDA_INPUT));
4040 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004041 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004042 err = add_control(spec, ALC_CTL_BIND_MUTE,
4043 "LFE Playback Switch",
4044 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4045 HDA_INPUT));
4046 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004047 return err;
4048 } else {
4049 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004050 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4051 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4052 HDA_OUTPUT));
4053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004054 return err;
4055 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004056 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4057 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4058 HDA_INPUT));
4059 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004060 return err;
4061 }
4062 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 return 0;
4064}
4065
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004066/* add playback controls for speaker and HP outputs */
4067static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4068 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069{
4070 hda_nid_t nid;
4071 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004072 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004075 return 0;
4076
4077 if (alc880_is_fixed_pin(pin)) {
4078 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004079 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004080 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004082 else
4083 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004084 /* control HP volume/switch on the output mixer amp */
4085 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004086 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004087 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4088 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4089 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004091 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004092 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4093 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4094 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095 return err;
4096 } else if (alc880_is_multi_pin(pin)) {
4097 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004099 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4101 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4102 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 return err;
4104 }
4105 return 0;
4106}
4107
4108/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004109static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4110 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004111 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112{
4113 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004114 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115
4116 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004117 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4118 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4119 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 return err;
4121 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004122 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4123 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4124 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125 return err;
4126 return 0;
4127}
4128
4129/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004130static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4131 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135
4136 for (i = 0; i < AUTO_PIN_LAST; i++) {
4137 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004138 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004139 err = new_analog_input(spec, cfg->input_pins[i],
4140 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004141 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 if (err < 0)
4143 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 imux->items[imux->num_items].label =
4145 auto_pin_cfg_labels[i];
4146 imux->items[imux->num_items].index =
4147 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 imux->num_items++;
4149 }
4150 }
4151 return 0;
4152}
4153
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004154static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4155 unsigned int pin_type)
4156{
4157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4158 pin_type);
4159 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004160 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4161 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004162}
4163
Kailang Yangdf694da2005-12-05 19:42:22 +01004164static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4165 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166 int dac_idx)
4167{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004168 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169 /* need the manual connection? */
4170 if (alc880_is_multi_pin(nid)) {
4171 struct alc_spec *spec = codec->spec;
4172 int idx = alc880_multi_pin_idx(nid);
4173 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4174 AC_VERB_SET_CONNECT_SEL,
4175 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4176 }
4177}
4178
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004179static int get_pin_type(int line_out_type)
4180{
4181 if (line_out_type == AUTO_PIN_HP_OUT)
4182 return PIN_HP;
4183 else
4184 return PIN_OUT;
4185}
4186
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187static void alc880_auto_init_multi_out(struct hda_codec *codec)
4188{
4189 struct alc_spec *spec = codec->spec;
4190 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004191
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004192 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193 for (i = 0; i < spec->autocfg.line_outs; i++) {
4194 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004195 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4196 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004197 }
4198}
4199
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004200static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004201{
4202 struct alc_spec *spec = codec->spec;
4203 hda_nid_t pin;
4204
Takashi Iwai82bc9552006-03-21 11:24:42 +01004205 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004206 if (pin) /* connect to front */
4207 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004208 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 if (pin) /* connect to front */
4210 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4211}
4212
4213static void alc880_auto_init_analog_input(struct hda_codec *codec)
4214{
4215 struct alc_spec *spec = codec->spec;
4216 int i;
4217
4218 for (i = 0; i < AUTO_PIN_LAST; i++) {
4219 hda_nid_t nid = spec->autocfg.input_pins[i];
4220 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004221 snd_hda_codec_write(codec, nid, 0,
4222 AC_VERB_SET_PIN_WIDGET_CONTROL,
4223 i <= AUTO_PIN_FRONT_MIC ?
4224 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004225 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004226 snd_hda_codec_write(codec, nid, 0,
4227 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 AMP_OUT_MUTE);
4229 }
4230 }
4231}
4232
4233/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004234/* return 1 if successful, 0 if the proper config is not found,
4235 * or a negative error code
4236 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004237static int alc880_parse_auto_config(struct hda_codec *codec)
4238{
4239 struct alc_spec *spec = codec->spec;
4240 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004241 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004243 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4244 alc880_ignore);
4245 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004246 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004247 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004250 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4251 if (err < 0)
4252 return err;
4253 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4254 if (err < 0)
4255 return err;
4256 err = alc880_auto_create_extra_out(spec,
4257 spec->autocfg.speaker_pins[0],
4258 "Speaker");
4259 if (err < 0)
4260 return err;
4261 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4262 "Headphone");
4263 if (err < 0)
4264 return err;
4265 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4266 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 return err;
4268
4269 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4270
4271 if (spec->autocfg.dig_out_pin)
4272 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4273 if (spec->autocfg.dig_in_pin)
4274 spec->dig_in_nid = ALC880_DIGIN_NID;
4275
Takashi Iwai603c4012008-07-30 15:01:44 +02004276 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004277 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278
Takashi Iwaid88897e2008-10-31 15:01:37 +01004279 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004281 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 spec->input_mux = &spec->private_imux;
4283
Takashi Iwaie044c392008-10-27 16:56:24 +01004284 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285 return 1;
4286}
4287
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004288/* additional initialization for auto-configuration model */
4289static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004291 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004293 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004294 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004295 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004296 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297}
4298
4299/*
4300 * OK, here we have finally the patch for ALC880
4301 */
4302
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004303static void set_capture_mixer(struct alc_spec *spec)
4304{
4305 static struct snd_kcontrol_new *caps[3] = {
4306 alc_capture_mixer1,
4307 alc_capture_mixer2,
4308 alc_capture_mixer3,
4309 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004310 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004311 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4312}
4313
Linus Torvalds1da177e2005-04-16 15:20:36 -07004314static int patch_alc880(struct hda_codec *codec)
4315{
4316 struct alc_spec *spec;
4317 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004318 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004319
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004320 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004321 if (spec == NULL)
4322 return -ENOMEM;
4323
4324 codec->spec = spec;
4325
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004326 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4327 alc880_models,
4328 alc880_cfg_tbl);
4329 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004330 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4331 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333 }
4334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 if (board_config == ALC880_AUTO) {
4336 /* automatic parse from the BIOS config */
4337 err = alc880_parse_auto_config(codec);
4338 if (err < 0) {
4339 alc_free(codec);
4340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004341 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004342 printk(KERN_INFO
4343 "hda_codec: Cannot set up configuration "
4344 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004345 board_config = ALC880_3ST;
4346 }
4347 }
4348
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 if (board_config != ALC880_AUTO)
4350 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004351
4352 spec->stream_name_analog = "ALC880 Analog";
4353 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4354 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004355 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004356
4357 spec->stream_name_digital = "ALC880 Digital";
4358 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4359 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4360
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004361 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004363 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364 /* get type */
4365 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004366 if (wcap != AC_WID_AUD_IN) {
4367 spec->adc_nids = alc880_adc_nids_alt;
4368 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 } else {
4370 spec->adc_nids = alc880_adc_nids;
4371 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372 }
4373 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004374 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004375
Takashi Iwai2134ea42008-01-10 16:53:55 +01004376 spec->vmaster_nid = 0x0c;
4377
Linus Torvalds1da177e2005-04-16 15:20:36 -07004378 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004379 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004380 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004381#ifdef CONFIG_SND_HDA_POWER_SAVE
4382 if (!spec->loopback.amplist)
4383 spec->loopback.amplist = alc880_loopbacks;
4384#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004385 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004386
4387 return 0;
4388}
4389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004390
Linus Torvalds1da177e2005-04-16 15:20:36 -07004391/*
4392 * ALC260 support
4393 */
4394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004395static hda_nid_t alc260_dac_nids[1] = {
4396 /* front */
4397 0x02,
4398};
4399
4400static hda_nid_t alc260_adc_nids[1] = {
4401 /* ADC0 */
4402 0x04,
4403};
4404
Kailang Yangdf694da2005-12-05 19:42:22 +01004405static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406 /* ADC1 */
4407 0x05,
4408};
4409
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004410/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4411 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4412 */
4413static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004414 /* ADC0, ADC1 */
4415 0x04, 0x05
4416};
4417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418#define ALC260_DIGOUT_NID 0x03
4419#define ALC260_DIGIN_NID 0x06
4420
4421static struct hda_input_mux alc260_capture_source = {
4422 .num_items = 4,
4423 .items = {
4424 { "Mic", 0x0 },
4425 { "Front Mic", 0x1 },
4426 { "Line", 0x2 },
4427 { "CD", 0x4 },
4428 },
4429};
4430
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004431/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004432 * headphone jack and the internal CD lines since these are the only pins at
4433 * which audio can appear. For flexibility, also allow the option of
4434 * recording the mixer output on the second ADC (ADC0 doesn't have a
4435 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004436 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004437static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4438 {
4439 .num_items = 3,
4440 .items = {
4441 { "Mic/Line", 0x0 },
4442 { "CD", 0x4 },
4443 { "Headphone", 0x2 },
4444 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004445 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004446 {
4447 .num_items = 4,
4448 .items = {
4449 { "Mic/Line", 0x0 },
4450 { "CD", 0x4 },
4451 { "Headphone", 0x2 },
4452 { "Mixer", 0x5 },
4453 },
4454 },
4455
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004456};
4457
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004458/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4459 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004460 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004461static struct hda_input_mux alc260_acer_capture_sources[2] = {
4462 {
4463 .num_items = 4,
4464 .items = {
4465 { "Mic", 0x0 },
4466 { "Line", 0x2 },
4467 { "CD", 0x4 },
4468 { "Headphone", 0x5 },
4469 },
4470 },
4471 {
4472 .num_items = 5,
4473 .items = {
4474 { "Mic", 0x0 },
4475 { "Line", 0x2 },
4476 { "CD", 0x4 },
4477 { "Headphone", 0x6 },
4478 { "Mixer", 0x5 },
4479 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004480 },
4481};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004482/*
4483 * This is just place-holder, so there's something for alc_build_pcms to look
4484 * at when it calculates the maximum number of channels. ALC260 has no mixer
4485 * element which allows changing the channel mode, so the verb list is
4486 * never used.
4487 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004488static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004489 { 2, NULL },
4490};
4491
Kailang Yangdf694da2005-12-05 19:42:22 +01004492
4493/* Mixer combinations
4494 *
4495 * basic: base_output + input + pc_beep + capture
4496 * HP: base_output + input + capture_alt
4497 * HP_3013: hp_3013 + input + capture
4498 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004499 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 */
4501
4502static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004503 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004504 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004505 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4506 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4507 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4508 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4509 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004510};
Kailang Yangdf694da2005-12-05 19:42:22 +01004511
4512static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004513 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4514 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4515 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4516 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4518 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4519 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004521 { } /* end */
4522};
4523
Kailang Yangdf694da2005-12-05 19:42:22 +01004524static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4525 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4526 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4527 { } /* end */
4528};
4529
Takashi Iwaibec15c32008-01-28 18:16:30 +01004530/* update HP, line and mono out pins according to the master switch */
4531static void alc260_hp_master_update(struct hda_codec *codec,
4532 hda_nid_t hp, hda_nid_t line,
4533 hda_nid_t mono)
4534{
4535 struct alc_spec *spec = codec->spec;
4536 unsigned int val = spec->master_sw ? PIN_HP : 0;
4537 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004538 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004539 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004540 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004541 val);
4542 /* mono (speaker) depending on the HP jack sense */
4543 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004544 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004545 val);
4546}
4547
4548static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4549 struct snd_ctl_elem_value *ucontrol)
4550{
4551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4552 struct alc_spec *spec = codec->spec;
4553 *ucontrol->value.integer.value = spec->master_sw;
4554 return 0;
4555}
4556
4557static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4558 struct snd_ctl_elem_value *ucontrol)
4559{
4560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4561 struct alc_spec *spec = codec->spec;
4562 int val = !!*ucontrol->value.integer.value;
4563 hda_nid_t hp, line, mono;
4564
4565 if (val == spec->master_sw)
4566 return 0;
4567 spec->master_sw = val;
4568 hp = (kcontrol->private_value >> 16) & 0xff;
4569 line = (kcontrol->private_value >> 8) & 0xff;
4570 mono = kcontrol->private_value & 0xff;
4571 alc260_hp_master_update(codec, hp, line, mono);
4572 return 1;
4573}
4574
4575static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4576 {
4577 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4578 .name = "Master Playback Switch",
4579 .info = snd_ctl_boolean_mono_info,
4580 .get = alc260_hp_master_sw_get,
4581 .put = alc260_hp_master_sw_put,
4582 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4583 },
4584 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4585 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4586 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4587 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4588 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4589 HDA_OUTPUT),
4590 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4591 { } /* end */
4592};
4593
4594static struct hda_verb alc260_hp_unsol_verbs[] = {
4595 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4596 {},
4597};
4598
4599static void alc260_hp_automute(struct hda_codec *codec)
4600{
4601 struct alc_spec *spec = codec->spec;
4602 unsigned int present;
4603
4604 present = snd_hda_codec_read(codec, 0x10, 0,
4605 AC_VERB_GET_PIN_SENSE, 0);
4606 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4607 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4608}
4609
4610static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4611{
4612 if ((res >> 26) == ALC880_HP_EVENT)
4613 alc260_hp_automute(codec);
4614}
4615
Kailang Yangdf694da2005-12-05 19:42:22 +01004616static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004617 {
4618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4619 .name = "Master Playback Switch",
4620 .info = snd_ctl_boolean_mono_info,
4621 .get = alc260_hp_master_sw_get,
4622 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004623 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004624 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004625 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4626 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4627 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4628 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4629 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004631 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4632 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004633 { } /* end */
4634};
4635
Kailang Yang3f878302008-08-26 13:02:23 +02004636static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4637 .ops = &snd_hda_bind_vol,
4638 .values = {
4639 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4640 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4641 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4642 0
4643 },
4644};
4645
4646static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4647 .ops = &snd_hda_bind_sw,
4648 .values = {
4649 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4650 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4651 0
4652 },
4653};
4654
4655static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4656 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4657 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4658 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4660 { } /* end */
4661};
4662
Takashi Iwaibec15c32008-01-28 18:16:30 +01004663static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4664 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4665 {},
4666};
4667
4668static void alc260_hp_3013_automute(struct hda_codec *codec)
4669{
4670 struct alc_spec *spec = codec->spec;
4671 unsigned int present;
4672
4673 present = snd_hda_codec_read(codec, 0x15, 0,
4674 AC_VERB_GET_PIN_SENSE, 0);
4675 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004676 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004677}
4678
4679static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4680 unsigned int res)
4681{
4682 if ((res >> 26) == ALC880_HP_EVENT)
4683 alc260_hp_3013_automute(codec);
4684}
4685
Kailang Yang3f878302008-08-26 13:02:23 +02004686static void alc260_hp_3012_automute(struct hda_codec *codec)
4687{
4688 unsigned int present, bits;
4689
4690 present = snd_hda_codec_read(codec, 0x10, 0,
4691 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4692
4693 bits = present ? 0 : PIN_OUT;
4694 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4695 bits);
4696 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4697 bits);
4698 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4699 bits);
4700}
4701
4702static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4703 unsigned int res)
4704{
4705 if ((res >> 26) == ALC880_HP_EVENT)
4706 alc260_hp_3012_automute(codec);
4707}
4708
4709/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004710 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4711 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004712static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004714 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004715 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004716 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4717 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4718 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4719 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004720 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004721 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4722 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004723 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4724 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004725 { } /* end */
4726};
4727
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004728/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4729 * versions of the ALC260 don't act on requests to enable mic bias from NID
4730 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4731 * datasheet doesn't mention this restriction. At this stage it's not clear
4732 * whether this behaviour is intentional or is a hardware bug in chip
4733 * revisions available in early 2006. Therefore for now allow the
4734 * "Headphone Jack Mode" control to span all choices, but if it turns out
4735 * that the lack of mic bias for this NID is intentional we could change the
4736 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4737 *
4738 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4739 * don't appear to make the mic bias available from the "line" jack, even
4740 * though the NID used for this jack (0x14) can supply it. The theory is
4741 * that perhaps Acer have included blocking capacitors between the ALC260
4742 * and the output jack. If this turns out to be the case for all such
4743 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4744 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004745 *
4746 * The C20x Tablet series have a mono internal speaker which is controlled
4747 * via the chip's Mono sum widget and pin complex, so include the necessary
4748 * controls for such models. On models without a "mono speaker" the control
4749 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004750 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004751static struct snd_kcontrol_new alc260_acer_mixer[] = {
4752 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4753 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004754 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004755 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004756 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004757 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004758 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004759 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4760 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4762 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4763 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4764 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4765 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4766 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4767 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4768 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4769 { } /* end */
4770};
4771
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004772/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4773 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4774 */
4775static struct snd_kcontrol_new alc260_will_mixer[] = {
4776 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4779 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4780 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4781 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4782 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4783 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4784 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4785 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4786 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4787 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4788 { } /* end */
4789};
4790
4791/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4792 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4793 */
4794static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4795 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4796 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4798 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4799 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4800 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4801 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4802 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4803 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4804 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4805 { } /* end */
4806};
4807
Kailang Yangdf694da2005-12-05 19:42:22 +01004808/*
4809 * initialization verbs
4810 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004811static struct hda_verb alc260_init_verbs[] = {
4812 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004817 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004818 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004819 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004820 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004822 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004823 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004824 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004825 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004826 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004827 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004828 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004829 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4830 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004832 /* set connection select to line in (default select for this ADC) */
4833 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 /* mute capture amp left and right */
4835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4836 /* set connection select to line in (default select for this ADC) */
4837 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004838 /* set vol=0 Line-Out mixer amp left and right */
4839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4840 /* unmute pin widget amp left and right (no gain on this amp) */
4841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4842 /* set vol=0 HP mixer amp left and right */
4843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4844 /* unmute pin widget amp left and right (no gain on this amp) */
4845 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4846 /* set vol=0 Mono mixer amp left and right */
4847 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4848 /* unmute pin widget amp left and right (no gain on this amp) */
4849 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4850 /* unmute LINE-2 out pin */
4851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004852 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4853 * Line In 2 = 0x03
4854 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004855 /* mute analog inputs */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004861 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004862 /* mute Front out path */
4863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4864 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4865 /* mute Headphone out path */
4866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4868 /* mute Mono out path */
4869 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004871 { }
4872};
4873
Takashi Iwai474167d2006-05-17 17:17:43 +02004874#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004875static struct hda_verb alc260_hp_init_verbs[] = {
4876 /* Headphone and output */
4877 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4878 /* mono output */
4879 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4880 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4882 /* Mic2 (front panel) pin widget for input and vref at 80% */
4883 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4884 /* Line In pin widget for input */
4885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4886 /* Line-2 pin widget for output */
4887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4888 /* CD pin widget for input */
4889 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4890 /* unmute amp left and right */
4891 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4892 /* set connection select to line in (default select for this ADC) */
4893 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4894 /* unmute Line-Out mixer amp left and right (volume = 0) */
4895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4896 /* mute pin widget amp left and right (no gain on this amp) */
4897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4898 /* unmute HP mixer amp left and right (volume = 0) */
4899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4900 /* mute pin widget amp left and right (no gain on this amp) */
4901 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004902 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4903 * Line In 2 = 0x03
4904 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004905 /* mute analog inputs */
4906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004911 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4912 /* Unmute Front out path */
4913 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4915 /* Unmute Headphone out path */
4916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4917 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4918 /* Unmute Mono out path */
4919 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4920 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4921 { }
4922};
Takashi Iwai474167d2006-05-17 17:17:43 +02004923#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004924
4925static struct hda_verb alc260_hp_3013_init_verbs[] = {
4926 /* Line out and output */
4927 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4928 /* mono output */
4929 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4930 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4931 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4932 /* Mic2 (front panel) pin widget for input and vref at 80% */
4933 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4934 /* Line In pin widget for input */
4935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4936 /* Headphone pin widget for output */
4937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4938 /* CD pin widget for input */
4939 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4940 /* unmute amp left and right */
4941 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4942 /* set connection select to line in (default select for this ADC) */
4943 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4944 /* unmute Line-Out mixer amp left and right (volume = 0) */
4945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4946 /* mute pin widget amp left and right (no gain on this amp) */
4947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4948 /* unmute HP mixer amp left and right (volume = 0) */
4949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4950 /* mute pin widget amp left and right (no gain on this amp) */
4951 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004952 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4953 * Line In 2 = 0x03
4954 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004955 /* mute analog inputs */
4956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004961 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4962 /* Unmute Front out path */
4963 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4964 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4965 /* Unmute Headphone out path */
4966 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4968 /* Unmute Mono out path */
4969 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4970 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4971 { }
4972};
4973
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004974/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004975 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4976 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004977 */
4978static struct hda_verb alc260_fujitsu_init_verbs[] = {
4979 /* Disable all GPIOs */
4980 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4981 /* Internal speaker is connected to headphone pin */
4982 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4983 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004985 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4986 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4987 /* Ensure all other unused pins are disabled and muted. */
4988 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004990 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004991 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004992 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004993 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004996
Jonathan Woithef7ace402006-02-28 11:46:14 +01004997 /* Disable digital (SPDIF) pins */
4998 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4999 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005000
Kailang Yangea1fb292008-08-26 12:58:38 +02005001 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005002 * when acting as an output.
5003 */
5004 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5005
5006 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5013 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005016
Jonathan Woithef7ace402006-02-28 11:46:14 +01005017 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5018 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5019 /* Unmute Line1 pin widget output buffer since it starts as an output.
5020 * If the pin mode is changed by the user the pin mode control will
5021 * take care of enabling the pin's input/output buffers as needed.
5022 * Therefore there's no need to enable the input buffer at this
5023 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005024 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005026 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005027 * mixer ctrl)
5028 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005029 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005030
Jonathan Woithef7ace402006-02-28 11:46:14 +01005031 /* Mute capture amp left and right */
5032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005033 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005034 * in (on mic1 pin)
5035 */
5036 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005037
Jonathan Woithef7ace402006-02-28 11:46:14 +01005038 /* Do the same for the second ADC: mute capture input amp and
5039 * set ADC connection to line in (on mic1 pin)
5040 */
5041 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5042 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005043
Jonathan Woithef7ace402006-02-28 11:46:14 +01005044 /* Mute all inputs to mixer widget (even unconnected ones) */
5045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005053
5054 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005055};
5056
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005057/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5058 * similar laptops (adapted from Fujitsu init verbs).
5059 */
5060static struct hda_verb alc260_acer_init_verbs[] = {
5061 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5062 * the headphone jack. Turn this on and rely on the standard mute
5063 * methods whenever the user wants to turn these outputs off.
5064 */
5065 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5066 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5067 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5068 /* Internal speaker/Headphone jack is connected to Line-out pin */
5069 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5070 /* Internal microphone/Mic jack is connected to Mic1 pin */
5071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5072 /* Line In jack is connected to Line1 pin */
5073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005074 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5075 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005076 /* Ensure all other unused pins are disabled and muted. */
5077 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5078 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005079 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5080 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5083 /* Disable digital (SPDIF) pins */
5084 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5085 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5086
Kailang Yangea1fb292008-08-26 12:58:38 +02005087 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005088 * bus when acting as outputs.
5089 */
5090 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5091 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5092
5093 /* Start with output sum widgets muted and their output gains at min */
5094 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5096 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5100 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5101 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5102 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5103
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005104 /* Unmute Line-out pin widget amp left and right
5105 * (no equiv mixer ctrl)
5106 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005107 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005108 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5109 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005110 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5111 * inputs. If the pin mode is changed by the user the pin mode control
5112 * will take care of enabling the pin's input/output buffers as needed.
5113 * Therefore there's no need to enable the input buffer at this
5114 * stage.
5115 */
5116 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5118
5119 /* Mute capture amp left and right */
5120 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5121 /* Set ADC connection select to match default mixer setting - mic
5122 * (on mic1 pin)
5123 */
5124 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5125
5126 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005127 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005128 */
5129 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005130 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005131
5132 /* Mute all inputs to mixer widget (even unconnected ones) */
5133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5141
5142 { }
5143};
5144
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005145static struct hda_verb alc260_will_verbs[] = {
5146 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5147 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5148 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5149 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5150 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5151 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5152 {}
5153};
5154
5155static struct hda_verb alc260_replacer_672v_verbs[] = {
5156 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5157 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5158 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5159
5160 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5161 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5162 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5163
5164 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5165 {}
5166};
5167
5168/* toggle speaker-output according to the hp-jack state */
5169static void alc260_replacer_672v_automute(struct hda_codec *codec)
5170{
5171 unsigned int present;
5172
5173 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5174 present = snd_hda_codec_read(codec, 0x0f, 0,
5175 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5176 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005177 snd_hda_codec_write_cache(codec, 0x01, 0,
5178 AC_VERB_SET_GPIO_DATA, 1);
5179 snd_hda_codec_write_cache(codec, 0x0f, 0,
5180 AC_VERB_SET_PIN_WIDGET_CONTROL,
5181 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005182 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005183 snd_hda_codec_write_cache(codec, 0x01, 0,
5184 AC_VERB_SET_GPIO_DATA, 0);
5185 snd_hda_codec_write_cache(codec, 0x0f, 0,
5186 AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005188 }
5189}
5190
5191static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5192 unsigned int res)
5193{
5194 if ((res >> 26) == ALC880_HP_EVENT)
5195 alc260_replacer_672v_automute(codec);
5196}
5197
Kailang Yang3f878302008-08-26 13:02:23 +02005198static struct hda_verb alc260_hp_dc7600_verbs[] = {
5199 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5201 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5202 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5203 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5205 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5206 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5207 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5209 {}
5210};
5211
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005212/* Test configuration for debugging, modelled after the ALC880 test
5213 * configuration.
5214 */
5215#ifdef CONFIG_SND_DEBUG
5216static hda_nid_t alc260_test_dac_nids[1] = {
5217 0x02,
5218};
5219static hda_nid_t alc260_test_adc_nids[2] = {
5220 0x04, 0x05,
5221};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005222/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005223 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005224 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005225 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005226static struct hda_input_mux alc260_test_capture_sources[2] = {
5227 {
5228 .num_items = 7,
5229 .items = {
5230 { "MIC1 pin", 0x0 },
5231 { "MIC2 pin", 0x1 },
5232 { "LINE1 pin", 0x2 },
5233 { "LINE2 pin", 0x3 },
5234 { "CD pin", 0x4 },
5235 { "LINE-OUT pin", 0x5 },
5236 { "HP-OUT pin", 0x6 },
5237 },
5238 },
5239 {
5240 .num_items = 8,
5241 .items = {
5242 { "MIC1 pin", 0x0 },
5243 { "MIC2 pin", 0x1 },
5244 { "LINE1 pin", 0x2 },
5245 { "LINE2 pin", 0x3 },
5246 { "CD pin", 0x4 },
5247 { "Mixer", 0x5 },
5248 { "LINE-OUT pin", 0x6 },
5249 { "HP-OUT pin", 0x7 },
5250 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005251 },
5252};
5253static struct snd_kcontrol_new alc260_test_mixer[] = {
5254 /* Output driver widgets */
5255 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5256 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5257 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5258 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5259 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5260 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5261
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005262 /* Modes for retasking pin widgets
5263 * Note: the ALC260 doesn't seem to act on requests to enable mic
5264 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5265 * mention this restriction. At this stage it's not clear whether
5266 * this behaviour is intentional or is a hardware bug in chip
5267 * revisions available at least up until early 2006. Therefore for
5268 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5269 * choices, but if it turns out that the lack of mic bias for these
5270 * NIDs is intentional we could change their modes from
5271 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5272 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005273 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5274 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5275 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5276 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5277 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5278 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5279
5280 /* Loopback mixer controls */
5281 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5282 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5283 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5284 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5285 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5286 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5287 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5288 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5289 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5290 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5292 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5293 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5294 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5295 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5296 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005297
5298 /* Controls for GPIO pins, assuming they are configured as outputs */
5299 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5300 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5301 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5302 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5303
Jonathan Woithe92621f12006-02-28 11:47:47 +01005304 /* Switches to allow the digital IO pins to be enabled. The datasheet
5305 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005306 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005307 */
5308 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5309 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5310
Jonathan Woithef8225f62008-01-08 12:16:54 +01005311 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5312 * this output to turn on an external amplifier.
5313 */
5314 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5315 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5316
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005317 { } /* end */
5318};
5319static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005320 /* Enable all GPIOs as outputs with an initial value of 0 */
5321 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5322 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5323 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5324
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005325 /* Enable retasking pins as output, initially without power amp */
5326 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5327 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5328 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5329 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5330 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5331 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5332
Jonathan Woithe92621f12006-02-28 11:47:47 +01005333 /* Disable digital (SPDIF) pins initially, but users can enable
5334 * them via a mixer switch. In the case of SPDIF-out, this initverb
5335 * payload also sets the generation to 0, output to be in "consumer"
5336 * PCM format, copyright asserted, no pre-emphasis and no validity
5337 * control.
5338 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005339 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5340 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5341
Kailang Yangea1fb292008-08-26 12:58:38 +02005342 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005343 * OUT1 sum bus when acting as an output.
5344 */
5345 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5346 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5347 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5348 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5349
5350 /* Start with output sum widgets muted and their output gains at min */
5351 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5354 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5357 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5358 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5360
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005361 /* Unmute retasking pin widget output buffers since the default
5362 * state appears to be output. As the pin mode is changed by the
5363 * user the pin mode control will take care of enabling the pin's
5364 * input/output buffers as needed.
5365 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005366 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5369 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5370 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5371 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5372 /* Also unmute the mono-out pin widget */
5373 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5374
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005375 /* Mute capture amp left and right */
5376 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005377 /* Set ADC connection select to match default mixer setting (mic1
5378 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005379 */
5380 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5381
5382 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005383 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005384 */
5385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5386 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5387
5388 /* Mute all inputs to mixer widget (even unconnected ones) */
5389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5397
5398 { }
5399};
5400#endif
5401
Takashi Iwai63300792008-01-24 15:31:36 +01005402#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5403#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005405#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5406#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5407
Kailang Yangdf694da2005-12-05 19:42:22 +01005408/*
5409 * for BIOS auto-configuration
5410 */
5411
5412static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005413 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005414{
5415 hda_nid_t nid_vol;
5416 unsigned long vol_val, sw_val;
5417 char name[32];
5418 int err;
5419
5420 if (nid >= 0x0f && nid < 0x11) {
5421 nid_vol = nid - 0x7;
5422 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5423 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5424 } else if (nid == 0x11) {
5425 nid_vol = nid - 0x7;
5426 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5427 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5428 } else if (nid >= 0x12 && nid <= 0x15) {
5429 nid_vol = 0x08;
5430 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5431 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5432 } else
5433 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005434
Takashi Iwai863b4512008-10-21 17:01:47 +02005435 if (!(*vol_bits & (1 << nid_vol))) {
5436 /* first control for the volume widget */
5437 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5438 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5439 if (err < 0)
5440 return err;
5441 *vol_bits |= (1 << nid_vol);
5442 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005443 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005444 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5445 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005446 return err;
5447 return 1;
5448}
5449
5450/* add playback controls from the parsed DAC table */
5451static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5452 const struct auto_pin_cfg *cfg)
5453{
5454 hda_nid_t nid;
5455 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005456 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005457
5458 spec->multiout.num_dacs = 1;
5459 spec->multiout.dac_nids = spec->private_dac_nids;
5460 spec->multiout.dac_nids[0] = 0x02;
5461
5462 nid = cfg->line_out_pins[0];
5463 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005464 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005465 if (err < 0)
5466 return err;
5467 }
5468
Takashi Iwai82bc9552006-03-21 11:24:42 +01005469 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005470 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005471 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005472 if (err < 0)
5473 return err;
5474 }
5475
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005476 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005477 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005478 err = alc260_add_playback_controls(spec, nid, "Headphone",
5479 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005480 if (err < 0)
5481 return err;
5482 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005483 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005484}
5485
5486/* create playback/capture controls for input pins */
5487static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5488 const struct auto_pin_cfg *cfg)
5489{
Kailang Yangdf694da2005-12-05 19:42:22 +01005490 struct hda_input_mux *imux = &spec->private_imux;
5491 int i, err, idx;
5492
5493 for (i = 0; i < AUTO_PIN_LAST; i++) {
5494 if (cfg->input_pins[i] >= 0x12) {
5495 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005496 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005497 auto_pin_cfg_labels[i], idx,
5498 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005499 if (err < 0)
5500 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005501 imux->items[imux->num_items].label =
5502 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005503 imux->items[imux->num_items].index = idx;
5504 imux->num_items++;
5505 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005506 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005507 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005508 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005509 auto_pin_cfg_labels[i], idx,
5510 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005511 if (err < 0)
5512 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005513 imux->items[imux->num_items].label =
5514 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005515 imux->items[imux->num_items].index = idx;
5516 imux->num_items++;
5517 }
5518 }
5519 return 0;
5520}
5521
5522static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5523 hda_nid_t nid, int pin_type,
5524 int sel_idx)
5525{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005526 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005527 /* need the manual connection? */
5528 if (nid >= 0x12) {
5529 int idx = nid - 0x12;
5530 snd_hda_codec_write(codec, idx + 0x0b, 0,
5531 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005532 }
5533}
5534
5535static void alc260_auto_init_multi_out(struct hda_codec *codec)
5536{
5537 struct alc_spec *spec = codec->spec;
5538 hda_nid_t nid;
5539
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005540 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005541 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005542 if (nid) {
5543 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5544 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5545 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005546
Takashi Iwai82bc9552006-03-21 11:24:42 +01005547 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005548 if (nid)
5549 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5550
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005551 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005552 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005553 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005554}
Kailang Yangdf694da2005-12-05 19:42:22 +01005555
5556#define ALC260_PIN_CD_NID 0x16
5557static void alc260_auto_init_analog_input(struct hda_codec *codec)
5558{
5559 struct alc_spec *spec = codec->spec;
5560 int i;
5561
5562 for (i = 0; i < AUTO_PIN_LAST; i++) {
5563 hda_nid_t nid = spec->autocfg.input_pins[i];
5564 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 snd_hda_codec_write(codec, nid, 0,
5566 AC_VERB_SET_PIN_WIDGET_CONTROL,
5567 i <= AUTO_PIN_FRONT_MIC ?
5568 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005570 snd_hda_codec_write(codec, nid, 0,
5571 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005572 AMP_OUT_MUTE);
5573 }
5574 }
5575}
5576
5577/*
5578 * generic initialization of ADC, input mixers and output mixers
5579 */
5580static struct hda_verb alc260_volume_init_verbs[] = {
5581 /*
5582 * Unmute ADC0-1 and set the default input to mic-in
5583 */
5584 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5585 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5586 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5587 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005588
Kailang Yangdf694da2005-12-05 19:42:22 +01005589 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5590 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005591 * Note: PASD motherboards uses the Line In 2 as the input for
5592 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005593 */
5594 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005595 /* mute analog inputs */
5596 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005601
5602 /*
5603 * Set up output mixers (0x08 - 0x0a)
5604 */
5605 /* set vol=0 to output mixers */
5606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5608 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5609 /* set up input amps for analog loopback */
5610 /* Amp Indices: DAC = 0, mixer = 1 */
5611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005617
Kailang Yangdf694da2005-12-05 19:42:22 +01005618 { }
5619};
5620
5621static int alc260_parse_auto_config(struct hda_codec *codec)
5622{
5623 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005624 int err;
5625 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5626
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005627 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5628 alc260_ignore);
5629 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005630 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005631 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5632 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005633 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005634 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005635 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005636 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5637 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005638 return err;
5639
5640 spec->multiout.max_channels = 2;
5641
5642 if (spec->autocfg.dig_out_pin)
5643 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005644 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005645 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005646
Takashi Iwaid88897e2008-10-31 15:01:37 +01005647 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005648
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005649 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005650 spec->input_mux = &spec->private_imux;
5651
Takashi Iwaie044c392008-10-27 16:56:24 +01005652 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005653 return 1;
5654}
5655
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005656/* additional initialization for auto-configuration model */
5657static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005658{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005659 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 alc260_auto_init_multi_out(codec);
5661 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005662 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005663 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005664}
5665
Takashi Iwaicb53c622007-08-10 17:21:45 +02005666#ifdef CONFIG_SND_HDA_POWER_SAVE
5667static struct hda_amp_list alc260_loopbacks[] = {
5668 { 0x07, HDA_INPUT, 0 },
5669 { 0x07, HDA_INPUT, 1 },
5670 { 0x07, HDA_INPUT, 2 },
5671 { 0x07, HDA_INPUT, 3 },
5672 { 0x07, HDA_INPUT, 4 },
5673 { } /* end */
5674};
5675#endif
5676
Kailang Yangdf694da2005-12-05 19:42:22 +01005677/*
5678 * ALC260 configurations
5679 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005680static const char *alc260_models[ALC260_MODEL_LAST] = {
5681 [ALC260_BASIC] = "basic",
5682 [ALC260_HP] = "hp",
5683 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005684 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005685 [ALC260_FUJITSU_S702X] = "fujitsu",
5686 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005687 [ALC260_WILL] = "will",
5688 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005689#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005690 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005691#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005692 [ALC260_AUTO] = "auto",
5693};
5694
5695static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005696 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005697 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005698 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005699 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005700 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005701 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005702 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005703 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5704 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5705 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5706 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5707 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5708 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5709 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5710 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5711 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005712 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005713 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005714 {}
5715};
5716
Kailang Yangdf694da2005-12-05 19:42:22 +01005717static struct alc_config_preset alc260_presets[] = {
5718 [ALC260_BASIC] = {
5719 .mixers = { alc260_base_output_mixer,
5720 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005721 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 .init_verbs = { alc260_init_verbs },
5723 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5724 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005725 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005726 .adc_nids = alc260_adc_nids,
5727 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5728 .channel_mode = alc260_modes,
5729 .input_mux = &alc260_capture_source,
5730 },
5731 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005732 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005733 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005734 .init_verbs = { alc260_init_verbs,
5735 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005736 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5737 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005738 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5739 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005740 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5741 .channel_mode = alc260_modes,
5742 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005743 .unsol_event = alc260_hp_unsol_event,
5744 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005745 },
Kailang Yang3f878302008-08-26 13:02:23 +02005746 [ALC260_HP_DC7600] = {
5747 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005748 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005749 .init_verbs = { alc260_init_verbs,
5750 alc260_hp_dc7600_verbs },
5751 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5752 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005753 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5754 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005755 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5756 .channel_mode = alc260_modes,
5757 .input_mux = &alc260_capture_source,
5758 .unsol_event = alc260_hp_3012_unsol_event,
5759 .init_hook = alc260_hp_3012_automute,
5760 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005761 [ALC260_HP_3013] = {
5762 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005763 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005764 .init_verbs = { alc260_hp_3013_init_verbs,
5765 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005766 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5767 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005768 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5769 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005770 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5771 .channel_mode = alc260_modes,
5772 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005773 .unsol_event = alc260_hp_3013_unsol_event,
5774 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005775 },
5776 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005777 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005778 .init_verbs = { alc260_fujitsu_init_verbs },
5779 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5780 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005781 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5782 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005783 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5784 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005785 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5786 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005787 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005788 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005789 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005790 .init_verbs = { alc260_acer_init_verbs },
5791 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5792 .dac_nids = alc260_dac_nids,
5793 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5794 .adc_nids = alc260_dual_adc_nids,
5795 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5796 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005797 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5798 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005799 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005800 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005801 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005802 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5803 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5804 .dac_nids = alc260_dac_nids,
5805 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5806 .adc_nids = alc260_adc_nids,
5807 .dig_out_nid = ALC260_DIGOUT_NID,
5808 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5809 .channel_mode = alc260_modes,
5810 .input_mux = &alc260_capture_source,
5811 },
5812 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005813 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005814 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5815 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5816 .dac_nids = alc260_dac_nids,
5817 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5818 .adc_nids = alc260_adc_nids,
5819 .dig_out_nid = ALC260_DIGOUT_NID,
5820 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5821 .channel_mode = alc260_modes,
5822 .input_mux = &alc260_capture_source,
5823 .unsol_event = alc260_replacer_672v_unsol_event,
5824 .init_hook = alc260_replacer_672v_automute,
5825 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005826#ifdef CONFIG_SND_DEBUG
5827 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005828 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005829 .init_verbs = { alc260_test_init_verbs },
5830 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5831 .dac_nids = alc260_test_dac_nids,
5832 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5833 .adc_nids = alc260_test_adc_nids,
5834 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5835 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005836 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5837 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005838 },
5839#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005840};
5841
Linus Torvalds1da177e2005-04-16 15:20:36 -07005842static int patch_alc260(struct hda_codec *codec)
5843{
5844 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005845 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005846
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005847 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005848 if (spec == NULL)
5849 return -ENOMEM;
5850
5851 codec->spec = spec;
5852
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005853 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5854 alc260_models,
5855 alc260_cfg_tbl);
5856 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005857 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5858 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005859 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005860 }
5861
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 if (board_config == ALC260_AUTO) {
5863 /* automatic parse from the BIOS config */
5864 err = alc260_parse_auto_config(codec);
5865 if (err < 0) {
5866 alc_free(codec);
5867 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005868 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005869 printk(KERN_INFO
5870 "hda_codec: Cannot set up configuration "
5871 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005872 board_config = ALC260_BASIC;
5873 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005874 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005875
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 if (board_config != ALC260_AUTO)
5877 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878
5879 spec->stream_name_analog = "ALC260 Analog";
5880 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5881 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5882
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005883 spec->stream_name_digital = "ALC260 Digital";
5884 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5885 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5886
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005887 if (!spec->adc_nids && spec->input_mux) {
5888 /* check whether NID 0x04 is valid */
5889 unsigned int wcap = get_wcaps(codec, 0x04);
5890 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5891 /* get type */
5892 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5893 spec->adc_nids = alc260_adc_nids_alt;
5894 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5895 } else {
5896 spec->adc_nids = alc260_adc_nids;
5897 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5898 }
5899 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005900 set_capture_mixer(spec);
5901
Takashi Iwai2134ea42008-01-10 16:53:55 +01005902 spec->vmaster_nid = 0x08;
5903
Linus Torvalds1da177e2005-04-16 15:20:36 -07005904 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005905 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005906 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005907#ifdef CONFIG_SND_HDA_POWER_SAVE
5908 if (!spec->loopback.amplist)
5909 spec->loopback.amplist = alc260_loopbacks;
5910#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005911 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005912
5913 return 0;
5914}
5915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005916
Linus Torvalds1da177e2005-04-16 15:20:36 -07005917/*
5918 * ALC882 support
5919 *
5920 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5921 * configuration. Each pin widget can choose any input DACs and a mixer.
5922 * Each ADC is connected from a mixer of all inputs. This makes possible
5923 * 6-channel independent captures.
5924 *
5925 * In addition, an independent DAC for the multi-playback (not used in this
5926 * driver yet).
5927 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005928#define ALC882_DIGOUT_NID 0x06
5929#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005930
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005931static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005932 { 8, NULL }
5933};
5934
5935static hda_nid_t alc882_dac_nids[4] = {
5936 /* front, rear, clfe, rear_surr */
5937 0x02, 0x03, 0x04, 0x05
5938};
5939
Kailang Yangdf694da2005-12-05 19:42:22 +01005940/* identical with ALC880 */
5941#define alc882_adc_nids alc880_adc_nids
5942#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005943
Takashi Iwaie1406342008-02-11 18:32:32 +01005944static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5945static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5946
Linus Torvalds1da177e2005-04-16 15:20:36 -07005947/* input MUX */
5948/* FIXME: should be a matrix-type input source selection */
5949
5950static struct hda_input_mux alc882_capture_source = {
5951 .num_items = 4,
5952 .items = {
5953 { "Mic", 0x0 },
5954 { "Front Mic", 0x1 },
5955 { "Line", 0x2 },
5956 { "CD", 0x4 },
5957 },
5958};
Kailang Yangdf694da2005-12-05 19:42:22 +01005959/*
Kailang Yang272a5272007-05-14 11:00:38 +02005960 * 2ch mode
5961 */
5962static struct hda_verb alc882_3ST_ch2_init[] = {
5963 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5964 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5965 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5966 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5967 { } /* end */
5968};
5969
5970/*
5971 * 6ch mode
5972 */
5973static struct hda_verb alc882_3ST_ch6_init[] = {
5974 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5975 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5976 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5977 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5978 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5979 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5980 { } /* end */
5981};
5982
5983static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5984 { 2, alc882_3ST_ch2_init },
5985 { 6, alc882_3ST_ch6_init },
5986};
5987
5988/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005989 * 6ch mode
5990 */
5991static struct hda_verb alc882_sixstack_ch6_init[] = {
5992 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5993 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5994 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5995 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5996 { } /* end */
5997};
5998
5999/*
6000 * 8ch mode
6001 */
6002static struct hda_verb alc882_sixstack_ch8_init[] = {
6003 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6004 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6005 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6006 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6007 { } /* end */
6008};
6009
6010static struct hda_channel_mode alc882_sixstack_modes[2] = {
6011 { 6, alc882_sixstack_ch6_init },
6012 { 8, alc882_sixstack_ch8_init },
6013};
6014
Takashi Iwai87350ad2007-08-16 18:19:38 +02006015/*
6016 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6017 */
6018
6019/*
6020 * 2ch mode
6021 */
6022static struct hda_verb alc885_mbp_ch2_init[] = {
6023 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6024 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6025 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6026 { } /* end */
6027};
6028
6029/*
6030 * 6ch mode
6031 */
6032static struct hda_verb alc885_mbp_ch6_init[] = {
6033 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6034 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6035 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6036 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6037 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6038 { } /* end */
6039};
6040
6041static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6042 { 2, alc885_mbp_ch2_init },
6043 { 6, alc885_mbp_ch6_init },
6044};
6045
6046
Linus Torvalds1da177e2005-04-16 15:20:36 -07006047/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6048 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6049 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01006050static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006053 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006054 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006055 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6056 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006057 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6058 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006059 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006060 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6063 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6065 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006070 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6072 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6073 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006074 { } /* end */
6075};
6076
Takashi Iwai87350ad2007-08-16 18:19:38 +02006077static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6079 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6080 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6081 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6083 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6085 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006086 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6088 { } /* end */
6089};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006090static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
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_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6100 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6101 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6102 { } /* end */
6103};
6104
Kailang Yang272a5272007-05-14 11:00:38 +02006105static struct snd_kcontrol_new alc882_targa_mixer[] = {
6106 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6107 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006118 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006119 { } /* end */
6120};
6121
6122/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6123 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6124 */
6125static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6126 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6127 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6129 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 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("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6135 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006139 { } /* end */
6140};
6141
Takashi Iwai914759b2007-09-06 14:52:04 +02006142static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6144 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6146 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6147 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6153 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6154 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6155 { } /* end */
6156};
6157
Kailang Yangdf694da2005-12-05 19:42:22 +01006158static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6159 {
6160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6161 .name = "Channel Mode",
6162 .info = alc_ch_mode_info,
6163 .get = alc_ch_mode_get,
6164 .put = alc_ch_mode_put,
6165 },
6166 { } /* end */
6167};
6168
Linus Torvalds1da177e2005-04-16 15:20:36 -07006169static struct hda_verb alc882_init_verbs[] = {
6170 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006174 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6177 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006178 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006186
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006187 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006191 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006195 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006199 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006200 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006201 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006202 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006203 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6206 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6209 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006210 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006211 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6212 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6214 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6215 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006216 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006217 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006218
6219 /* FIXME: use matrix-type input source selection */
6220 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6221 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6224 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6225 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6229 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6230 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006231 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6233 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6236 /* ADC1: mute amp left and right */
6237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006238 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006239 /* ADC2: mute amp left and right */
6240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006242 /* ADC3: mute amp left and right */
6243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006244 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006245
6246 { }
6247};
6248
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006249static struct hda_verb alc882_eapd_verbs[] = {
6250 /* change to EAPD mode */
6251 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006252 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006253 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006254};
6255
Tobin Davis9102cd12006-12-15 10:02:12 +01006256/* Mac Pro test */
6257static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6263 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6264 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6265 { } /* end */
6266};
6267
6268static struct hda_verb alc882_macpro_init_verbs[] = {
6269 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6273 /* Front Pin: output 0 (0x0c) */
6274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6277 /* Front Mic pin: input vref at 80% */
6278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6280 /* Speaker: output */
6281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6283 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6284 /* Headphone output (output 0 - 0x0c) */
6285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6287 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6288
6289 /* FIXME: use matrix-type input source selection */
6290 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6291 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6296 /* Input mixer2 */
6297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6301 /* Input mixer3 */
6302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6306 /* ADC1: mute amp left and right */
6307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6308 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6309 /* ADC2: mute amp left and right */
6310 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6311 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6312 /* ADC3: mute amp left and right */
6313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6315
6316 { }
6317};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006318
Takashi Iwai87350ad2007-08-16 18:19:38 +02006319/* Macbook Pro rev3 */
6320static struct hda_verb alc885_mbp3_init_verbs[] = {
6321 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6325 /* Rear mixer */
6326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6329 /* Front Pin: output 0 (0x0c) */
6330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6332 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6333 /* HP Pin: output 0 (0x0d) */
6334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6338 /* Mic (rear) pin: input vref at 80% */
6339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6341 /* Front Mic pin: input vref at 80% */
6342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6343 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6344 /* Line In pin: use output 1 when in LineOut mode */
6345 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6347 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6348
6349 /* FIXME: use matrix-type input source selection */
6350 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6351 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6356 /* Input mixer2 */
6357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6361 /* Input mixer3 */
6362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6366 /* ADC1: mute amp left and right */
6367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6368 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6369 /* ADC2: mute amp left and right */
6370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6371 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6372 /* ADC3: mute amp left and right */
6373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6374 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6375
6376 { }
6377};
6378
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006379/* iMac 24 mixer. */
6380static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6381 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6382 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6383 { } /* end */
6384};
6385
6386/* iMac 24 init verbs. */
6387static struct hda_verb alc885_imac24_init_verbs[] = {
6388 /* Internal speakers: output 0 (0x0c) */
6389 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6390 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6391 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6392 /* Internal speakers: output 0 (0x0c) */
6393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6394 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6396 /* Headphone: output 0 (0x0c) */
6397 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6398 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6399 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6400 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6401 /* Front Mic: input vref at 80% */
6402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6404 { }
6405};
6406
6407/* Toggle speaker-output according to the hp-jack state */
6408static void alc885_imac24_automute(struct hda_codec *codec)
6409{
6410 unsigned int present;
6411
6412 present = snd_hda_codec_read(codec, 0x14, 0,
6413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006414 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6415 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6416 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6417 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006418}
6419
6420/* Processes unsolicited events. */
6421static void alc885_imac24_unsol_event(struct hda_codec *codec,
6422 unsigned int res)
6423{
6424 /* Headphone insertion or removal. */
6425 if ((res >> 26) == ALC880_HP_EVENT)
6426 alc885_imac24_automute(codec);
6427}
6428
Takashi Iwai87350ad2007-08-16 18:19:38 +02006429static void alc885_mbp3_automute(struct hda_codec *codec)
6430{
6431 unsigned int present;
6432
6433 present = snd_hda_codec_read(codec, 0x15, 0,
6434 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6435 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6436 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6437 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6438 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6439
6440}
6441static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6442 unsigned int res)
6443{
6444 /* Headphone insertion or removal. */
6445 if ((res >> 26) == ALC880_HP_EVENT)
6446 alc885_mbp3_automute(codec);
6447}
6448
6449
Kailang Yang272a5272007-05-14 11:00:38 +02006450static struct hda_verb alc882_targa_verbs[] = {
6451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6453
6454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006456
Kailang Yang272a5272007-05-14 11:00:38 +02006457 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6458 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6459 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6460
6461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6462 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6463 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6464 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6465 { } /* end */
6466};
6467
6468/* toggle speaker-output according to the hp-jack state */
6469static void alc882_targa_automute(struct hda_codec *codec)
6470{
6471 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006472
Kailang Yang272a5272007-05-14 11:00:38 +02006473 present = snd_hda_codec_read(codec, 0x14, 0,
6474 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006475 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6476 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006477 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6478 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006479}
6480
6481static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6482{
6483 /* Looks like the unsol event is incompatible with the standard
6484 * definition. 4bit tag is placed at 26 bit!
6485 */
6486 if (((res >> 26) == ALC880_HP_EVENT)) {
6487 alc882_targa_automute(codec);
6488 }
6489}
6490
6491static struct hda_verb alc882_asus_a7j_verbs[] = {
6492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6494
6495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6497 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006498
Kailang Yang272a5272007-05-14 11:00:38 +02006499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6500 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6501 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6502
6503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6506 { } /* end */
6507};
6508
Takashi Iwai914759b2007-09-06 14:52:04 +02006509static struct hda_verb alc882_asus_a7m_verbs[] = {
6510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6512
6513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006516
Takashi Iwai914759b2007-09-06 14:52:04 +02006517 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6518 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6519 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6520
6521 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6522 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6523 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6524 { } /* end */
6525};
6526
Tobin Davis9102cd12006-12-15 10:02:12 +01006527static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6528{
6529 unsigned int gpiostate, gpiomask, gpiodir;
6530
6531 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6532 AC_VERB_GET_GPIO_DATA, 0);
6533
6534 if (!muted)
6535 gpiostate |= (1 << pin);
6536 else
6537 gpiostate &= ~(1 << pin);
6538
6539 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6540 AC_VERB_GET_GPIO_MASK, 0);
6541 gpiomask |= (1 << pin);
6542
6543 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6544 AC_VERB_GET_GPIO_DIRECTION, 0);
6545 gpiodir |= (1 << pin);
6546
6547
6548 snd_hda_codec_write(codec, codec->afg, 0,
6549 AC_VERB_SET_GPIO_MASK, gpiomask);
6550 snd_hda_codec_write(codec, codec->afg, 0,
6551 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6552
6553 msleep(1);
6554
6555 snd_hda_codec_write(codec, codec->afg, 0,
6556 AC_VERB_SET_GPIO_DATA, gpiostate);
6557}
6558
Takashi Iwai7debbe52007-08-16 15:01:03 +02006559/* set up GPIO at initialization */
6560static void alc885_macpro_init_hook(struct hda_codec *codec)
6561{
6562 alc882_gpio_mute(codec, 0, 0);
6563 alc882_gpio_mute(codec, 1, 0);
6564}
6565
6566/* set up GPIO and update auto-muting at initialization */
6567static void alc885_imac24_init_hook(struct hda_codec *codec)
6568{
6569 alc885_macpro_init_hook(codec);
6570 alc885_imac24_automute(codec);
6571}
6572
Kailang Yangdf694da2005-12-05 19:42:22 +01006573/*
6574 * generic initialization of ADC, input mixers and output mixers
6575 */
6576static struct hda_verb alc882_auto_init_verbs[] = {
6577 /*
6578 * Unmute ADC0-2 and set the default input to mic-in
6579 */
6580 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6582 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6584 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6585 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6586
Takashi Iwaicb53c622007-08-10 17:21:45 +02006587 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006589 * Note: PASD motherboards uses the Line In 2 as the input for
6590 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006591 */
6592 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6596 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006598
6599 /*
6600 * Set up output mixers (0x0c - 0x0f)
6601 */
6602 /* set vol=0 to output mixers */
6603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6607 /* set up input amps for analog loopback */
6608 /* Amp Indices: DAC = 0, mixer = 1 */
6609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6611 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6613 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6614 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6615 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6616 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6617 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6619
6620 /* FIXME: use matrix-type input source selection */
6621 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6622 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6624 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6625 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6627 /* Input mixer2 */
6628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6632 /* Input mixer3 */
6633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6634 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6637
6638 { }
6639};
6640
Takashi Iwaicb53c622007-08-10 17:21:45 +02006641#ifdef CONFIG_SND_HDA_POWER_SAVE
6642#define alc882_loopbacks alc880_loopbacks
6643#endif
6644
Kailang Yangdf694da2005-12-05 19:42:22 +01006645/* pcm configuration: identiacal with ALC880 */
6646#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6647#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6648#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6649#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6650
6651/*
6652 * configuration and preset
6653 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006654static const char *alc882_models[ALC882_MODEL_LAST] = {
6655 [ALC882_3ST_DIG] = "3stack-dig",
6656 [ALC882_6ST_DIG] = "6stack-dig",
6657 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006658 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006659 [ALC882_TARGA] = "targa",
6660 [ALC882_ASUS_A7J] = "asus-a7j",
6661 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006662 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006663 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006664 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006665 [ALC882_AUTO] = "auto",
6666};
6667
6668static struct snd_pci_quirk alc882_cfg_tbl[] = {
6669 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006670 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006671 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006672 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006673 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006674 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006675 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006676 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006677 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006678 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6679 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6680 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006681 {}
6682};
6683
6684static struct alc_config_preset alc882_presets[] = {
6685 [ALC882_3ST_DIG] = {
6686 .mixers = { alc882_base_mixer },
6687 .init_verbs = { alc882_init_verbs },
6688 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6689 .dac_nids = alc882_dac_nids,
6690 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006691 .dig_in_nid = ALC882_DIGIN_NID,
6692 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6693 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006694 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006695 .input_mux = &alc882_capture_source,
6696 },
6697 [ALC882_6ST_DIG] = {
6698 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6699 .init_verbs = { alc882_init_verbs },
6700 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6701 .dac_nids = alc882_dac_nids,
6702 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006703 .dig_in_nid = ALC882_DIGIN_NID,
6704 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6705 .channel_mode = alc882_sixstack_modes,
6706 .input_mux = &alc882_capture_source,
6707 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006708 [ALC882_ARIMA] = {
6709 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6710 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6711 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6712 .dac_nids = alc882_dac_nids,
6713 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6714 .channel_mode = alc882_sixstack_modes,
6715 .input_mux = &alc882_capture_source,
6716 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006717 [ALC882_W2JC] = {
6718 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6719 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6720 alc880_gpio1_init_verbs },
6721 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6722 .dac_nids = alc882_dac_nids,
6723 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6724 .channel_mode = alc880_threestack_modes,
6725 .need_dac_fix = 1,
6726 .input_mux = &alc882_capture_source,
6727 .dig_out_nid = ALC882_DIGOUT_NID,
6728 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006729 [ALC885_MBP3] = {
6730 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6731 .init_verbs = { alc885_mbp3_init_verbs,
6732 alc880_gpio1_init_verbs },
6733 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6734 .dac_nids = alc882_dac_nids,
6735 .channel_mode = alc885_mbp_6ch_modes,
6736 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6737 .input_mux = &alc882_capture_source,
6738 .dig_out_nid = ALC882_DIGOUT_NID,
6739 .dig_in_nid = ALC882_DIGIN_NID,
6740 .unsol_event = alc885_mbp3_unsol_event,
6741 .init_hook = alc885_mbp3_automute,
6742 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006743 [ALC885_MACPRO] = {
6744 .mixers = { alc882_macpro_mixer },
6745 .init_verbs = { alc882_macpro_init_verbs },
6746 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6747 .dac_nids = alc882_dac_nids,
6748 .dig_out_nid = ALC882_DIGOUT_NID,
6749 .dig_in_nid = ALC882_DIGIN_NID,
6750 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6751 .channel_mode = alc882_ch_modes,
6752 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006753 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006754 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006755 [ALC885_IMAC24] = {
6756 .mixers = { alc885_imac24_mixer },
6757 .init_verbs = { alc885_imac24_init_verbs },
6758 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6759 .dac_nids = alc882_dac_nids,
6760 .dig_out_nid = ALC882_DIGOUT_NID,
6761 .dig_in_nid = ALC882_DIGIN_NID,
6762 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6763 .channel_mode = alc882_ch_modes,
6764 .input_mux = &alc882_capture_source,
6765 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006766 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006767 },
Kailang Yang272a5272007-05-14 11:00:38 +02006768 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006769 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006770 .init_verbs = { alc882_init_verbs, alc882_targa_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,
6781 .unsol_event = alc882_targa_unsol_event,
6782 .init_hook = alc882_targa_automute,
6783 },
6784 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006785 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006786 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6787 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6788 .dac_nids = alc882_dac_nids,
6789 .dig_out_nid = ALC882_DIGOUT_NID,
6790 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6791 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006792 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006793 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6794 .channel_mode = alc882_3ST_6ch_modes,
6795 .need_dac_fix = 1,
6796 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006797 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006798 [ALC882_ASUS_A7M] = {
6799 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6800 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6801 alc880_gpio1_init_verbs,
6802 alc882_asus_a7m_verbs },
6803 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6804 .dac_nids = alc882_dac_nids,
6805 .dig_out_nid = ALC882_DIGOUT_NID,
6806 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6807 .channel_mode = alc880_threestack_modes,
6808 .need_dac_fix = 1,
6809 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006810 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006811};
6812
6813
6814/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006815 * Pin config fixes
6816 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006817enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006818 PINFIX_ABIT_AW9D_MAX
6819};
6820
6821static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6822 { 0x15, 0x01080104 }, /* side */
6823 { 0x16, 0x01011012 }, /* rear */
6824 { 0x17, 0x01016011 }, /* clfe */
6825 { }
6826};
6827
6828static const struct alc_pincfg *alc882_pin_fixes[] = {
6829 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6830};
6831
6832static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6833 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6834 {}
6835};
6836
6837/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 * BIOS auto configuration
6839 */
6840static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6841 hda_nid_t nid, int pin_type,
6842 int dac_idx)
6843{
6844 /* set as output */
6845 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006846 int idx;
6847
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006848 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6850 idx = 4;
6851 else
6852 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006853 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6854
6855}
6856
6857static void alc882_auto_init_multi_out(struct hda_codec *codec)
6858{
6859 struct alc_spec *spec = codec->spec;
6860 int i;
6861
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006862 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006863 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006864 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006865 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006866 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006867 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006868 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 }
6870}
6871
6872static void alc882_auto_init_hp_out(struct hda_codec *codec)
6873{
6874 struct alc_spec *spec = codec->spec;
6875 hda_nid_t pin;
6876
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006877 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006878 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006879 /* use dac 0 */
6880 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006881 pin = spec->autocfg.speaker_pins[0];
6882 if (pin)
6883 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006884}
6885
6886#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6887#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6888
6889static void alc882_auto_init_analog_input(struct hda_codec *codec)
6890{
6891 struct alc_spec *spec = codec->spec;
6892 int i;
6893
6894 for (i = 0; i < AUTO_PIN_LAST; i++) {
6895 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006896 unsigned int vref;
6897 if (!nid)
6898 continue;
6899 vref = PIN_IN;
6900 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006901 unsigned int pincap;
6902 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6903 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006904 AC_PINCAP_VREF_80)
6905 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006906 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006907 snd_hda_codec_write(codec, nid, 0,
6908 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6909 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6910 snd_hda_codec_write(codec, nid, 0,
6911 AC_VERB_SET_AMP_GAIN_MUTE,
6912 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 }
6914}
6915
Takashi Iwaif511b012008-08-15 16:46:42 +02006916static void alc882_auto_init_input_src(struct hda_codec *codec)
6917{
6918 struct alc_spec *spec = codec->spec;
6919 const struct hda_input_mux *imux = spec->input_mux;
6920 int c;
6921
6922 for (c = 0; c < spec->num_adc_nids; c++) {
6923 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6924 hda_nid_t nid = spec->capsrc_nids[c];
6925 int conns, mute, idx, item;
6926
6927 conns = snd_hda_get_connections(codec, nid, conn_list,
6928 ARRAY_SIZE(conn_list));
6929 if (conns < 0)
6930 continue;
6931 for (idx = 0; idx < conns; idx++) {
6932 /* if the current connection is the selected one,
6933 * unmute it as default - otherwise mute it
6934 */
6935 mute = AMP_IN_MUTE(idx);
6936 for (item = 0; item < imux->num_items; item++) {
6937 if (imux->items[item].index == idx) {
6938 if (spec->cur_mux[c] == item)
6939 mute = AMP_IN_UNMUTE(idx);
6940 break;
6941 }
6942 }
6943 snd_hda_codec_write(codec, nid, 0,
6944 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6945 }
6946 }
6947}
6948
Takashi Iwai776e1842007-08-29 15:07:11 +02006949/* add mic boosts if needed */
6950static int alc_auto_add_mic_boost(struct hda_codec *codec)
6951{
6952 struct alc_spec *spec = codec->spec;
6953 int err;
6954 hda_nid_t nid;
6955
6956 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006957 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006958 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6959 "Mic Boost",
6960 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6961 if (err < 0)
6962 return err;
6963 }
6964 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006965 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006966 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6967 "Front Mic Boost",
6968 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6969 if (err < 0)
6970 return err;
6971 }
6972 return 0;
6973}
6974
Kailang Yangdf694da2005-12-05 19:42:22 +01006975/* almost identical with ALC880 parser... */
6976static int alc882_parse_auto_config(struct hda_codec *codec)
6977{
6978 struct alc_spec *spec = codec->spec;
6979 int err = alc880_parse_auto_config(codec);
6980
6981 if (err < 0)
6982 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006983 else if (!err)
6984 return 0; /* no config found */
6985
6986 err = alc_auto_add_mic_boost(codec);
6987 if (err < 0)
6988 return err;
6989
6990 /* hack - override the init verbs */
6991 spec->init_verbs[0] = alc882_auto_init_verbs;
6992
6993 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006994}
6995
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006996/* additional initialization for auto-configuration model */
6997static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006998{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006999 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 alc882_auto_init_multi_out(codec);
7001 alc882_auto_init_hp_out(codec);
7002 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007003 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007004 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007005 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007006}
7007
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007008static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7009
Linus Torvalds1da177e2005-04-16 15:20:36 -07007010static int patch_alc882(struct hda_codec *codec)
7011{
7012 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007013 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007015 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007016 if (spec == NULL)
7017 return -ENOMEM;
7018
Linus Torvalds1da177e2005-04-16 15:20:36 -07007019 codec->spec = spec;
7020
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007021 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7022 alc882_models,
7023 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007024
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007026 /* Pick up systems that don't supply PCI SSID */
7027 switch (codec->subsystem_id) {
7028 case 0x106b0c00: /* Mac Pro */
7029 board_config = ALC885_MACPRO;
7030 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007031 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007032 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007033 board_config = ALC885_IMAC24;
7034 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007035 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007036 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007037 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007038 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007039 board_config = ALC885_MBP3;
7040 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007041 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007042 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007043 if (codec->revision_id == 0x100101 ||
7044 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007045 alc_free(codec);
7046 return patch_alc883(codec);
7047 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007048 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7049 "trying auto-probe from BIOS...\n");
7050 board_config = ALC882_AUTO;
7051 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007052 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007053
Takashi Iwaif95474e2007-07-10 00:47:43 +02007054 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7055
Kailang Yangdf694da2005-12-05 19:42:22 +01007056 if (board_config == ALC882_AUTO) {
7057 /* automatic parse from the BIOS config */
7058 err = alc882_parse_auto_config(codec);
7059 if (err < 0) {
7060 alc_free(codec);
7061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007062 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007063 printk(KERN_INFO
7064 "hda_codec: Cannot set up configuration "
7065 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 board_config = ALC882_3ST_DIG;
7067 }
7068 }
7069
7070 if (board_config != ALC882_AUTO)
7071 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072
Kailang Yang2f893282008-05-27 12:14:47 +02007073 if (codec->vendor_id == 0x10ec0885) {
7074 spec->stream_name_analog = "ALC885 Analog";
7075 spec->stream_name_digital = "ALC885 Digital";
7076 } else {
7077 spec->stream_name_analog = "ALC882 Analog";
7078 spec->stream_name_digital = "ALC882 Digital";
7079 }
7080
Kailang Yangdf694da2005-12-05 19:42:22 +01007081 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7082 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007083 /* FIXME: setup DAC5 */
7084 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7085 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007086
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7088 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007089
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007090 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007091 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007092 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007093 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007094 /* get type */
7095 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007096 if (wcap != AC_WID_AUD_IN) {
7097 spec->adc_nids = alc882_adc_nids_alt;
7098 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007099 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007100 } else {
7101 spec->adc_nids = alc882_adc_nids;
7102 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007103 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 }
7105 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007106 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007107
Takashi Iwai2134ea42008-01-10 16:53:55 +01007108 spec->vmaster_nid = 0x0c;
7109
Linus Torvalds1da177e2005-04-16 15:20:36 -07007110 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007111 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007112 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007113#ifdef CONFIG_SND_HDA_POWER_SAVE
7114 if (!spec->loopback.amplist)
7115 spec->loopback.amplist = alc882_loopbacks;
7116#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007117 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007118
7119 return 0;
7120}
7121
7122/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007123 * ALC883 support
7124 *
7125 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7126 * configuration. Each pin widget can choose any input DACs and a mixer.
7127 * Each ADC is connected from a mixer of all inputs. This makes possible
7128 * 6-channel independent captures.
7129 *
7130 * In addition, an independent DAC for the multi-playback (not used in this
7131 * driver yet).
7132 */
7133#define ALC883_DIGOUT_NID 0x06
7134#define ALC883_DIGIN_NID 0x0a
7135
Wu Fengguang3ab90932008-11-17 09:51:09 +01007136#define ALC1200_DIGOUT_NID 0x10
7137
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007138static hda_nid_t alc883_dac_nids[4] = {
7139 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007140 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007141};
7142
7143static hda_nid_t alc883_adc_nids[2] = {
7144 /* ADC1-2 */
7145 0x08, 0x09,
7146};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007147
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007148static hda_nid_t alc883_adc_nids_alt[1] = {
7149 /* ADC1 */
7150 0x08,
7151};
7152
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007153static hda_nid_t alc883_adc_nids_rev[2] = {
7154 /* ADC2-1 */
7155 0x09, 0x08
7156};
7157
Takashi Iwaie1406342008-02-11 18:32:32 +01007158static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7159
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007160static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7161
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007162/* input MUX */
7163/* FIXME: should be a matrix-type input source selection */
7164
7165static struct hda_input_mux alc883_capture_source = {
7166 .num_items = 4,
7167 .items = {
7168 { "Mic", 0x0 },
7169 { "Front Mic", 0x1 },
7170 { "Line", 0x2 },
7171 { "CD", 0x4 },
7172 },
7173};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007174
Jiang zhe17bba1b2008-06-04 12:11:07 +02007175static struct hda_input_mux alc883_3stack_6ch_intel = {
7176 .num_items = 4,
7177 .items = {
7178 { "Mic", 0x1 },
7179 { "Front Mic", 0x0 },
7180 { "Line", 0x2 },
7181 { "CD", 0x4 },
7182 },
7183};
7184
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007185static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7186 .num_items = 2,
7187 .items = {
7188 { "Mic", 0x1 },
7189 { "Line", 0x2 },
7190 },
7191};
7192
Kailang Yang272a5272007-05-14 11:00:38 +02007193static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7194 .num_items = 4,
7195 .items = {
7196 { "Mic", 0x0 },
7197 { "iMic", 0x1 },
7198 { "Line", 0x2 },
7199 { "CD", 0x4 },
7200 },
7201};
7202
Jiang zhefb97dc62008-03-06 11:07:11 +01007203static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7204 .num_items = 2,
7205 .items = {
7206 { "Mic", 0x0 },
7207 { "Int Mic", 0x1 },
7208 },
7209};
7210
Kailang Yange2757d52008-08-26 13:17:46 +02007211static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7212 .num_items = 3,
7213 .items = {
7214 { "Mic", 0x0 },
7215 { "Front Mic", 0x1 },
7216 { "Line", 0x4 },
7217 },
7218};
7219
7220static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7221 .num_items = 2,
7222 .items = {
7223 { "Mic", 0x0 },
7224 { "Line", 0x2 },
7225 },
7226};
7227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007228/*
7229 * 2ch mode
7230 */
7231static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7232 { 2, NULL }
7233};
7234
7235/*
7236 * 2ch mode
7237 */
7238static struct hda_verb alc883_3ST_ch2_init[] = {
7239 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7240 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7241 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7242 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7243 { } /* end */
7244};
7245
7246/*
Tobin Davisb2011312007-09-17 12:45:11 +02007247 * 4ch mode
7248 */
7249static struct hda_verb alc883_3ST_ch4_init[] = {
7250 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7251 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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
7258/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007259 * 6ch mode
7260 */
7261static struct hda_verb alc883_3ST_ch6_init[] = {
7262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7264 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7265 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7266 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7267 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7268 { } /* end */
7269};
7270
Tobin Davisb2011312007-09-17 12:45:11 +02007271static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007272 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007273 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007274 { 6, alc883_3ST_ch6_init },
7275};
7276
7277/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007278 * 2ch mode
7279 */
7280static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7281 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7282 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7283 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7284 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7285 { } /* end */
7286};
7287
7288/*
7289 * 4ch mode
7290 */
7291static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7292 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7293 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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
7300/*
7301 * 6ch mode
7302 */
7303static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7304 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7305 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7306 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7307 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7308 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7309 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7310 { } /* end */
7311};
7312
7313static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7314 { 2, alc883_3ST_ch2_intel_init },
7315 { 4, alc883_3ST_ch4_intel_init },
7316 { 6, alc883_3ST_ch6_intel_init },
7317};
7318
7319/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320 * 6ch mode
7321 */
7322static struct hda_verb alc883_sixstack_ch6_init[] = {
7323 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7324 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7325 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7326 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7327 { } /* end */
7328};
7329
7330/*
7331 * 8ch mode
7332 */
7333static struct hda_verb alc883_sixstack_ch8_init[] = {
7334 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7335 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7336 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7337 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7338 { } /* end */
7339};
7340
7341static struct hda_channel_mode alc883_sixstack_modes[2] = {
7342 { 6, alc883_sixstack_ch6_init },
7343 { 8, alc883_sixstack_ch8_init },
7344};
7345
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007346static struct hda_verb alc883_medion_eapd_verbs[] = {
7347 /* eanable EAPD on medion laptop */
7348 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7349 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7350 { }
7351};
7352
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007353/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7354 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7355 */
7356
7357static struct snd_kcontrol_new alc883_base_mixer[] = {
7358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7359 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7361 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7363 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7364 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7365 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7366 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7367 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7376 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007377 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7379 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7380 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007381 { } /* end */
7382};
7383
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007384static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7386 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7387 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7388 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7389 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7390 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7395 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7396 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7397 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007398 { } /* end */
7399};
7400
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007401static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7403 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7404 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7405 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7409 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7410 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7411 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007412 { } /* end */
7413};
7414
Jiang zhefb97dc62008-03-06 11:07:11 +01007415static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7416 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7417 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7419 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7422 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7423 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7425 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007426 { } /* end */
7427};
7428
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007429static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7431 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007438 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007441 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7443 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7444 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007445 { } /* end */
7446};
7447
7448static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7449 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7450 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7451 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7452 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7453 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7454 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7455 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7456 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7457 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007463 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007464 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007466 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7468 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7469 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007470 { } /* end */
7471};
7472
Jiang zhe17bba1b2008-06-04 12:11:07 +02007473static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7474 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7475 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7477 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7478 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7479 HDA_OUTPUT),
7480 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7481 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7482 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7484 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7485 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7488 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7489 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7491 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7493 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7494 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7495 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007496 { } /* end */
7497};
7498
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007499static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007501 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007502 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007503 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007504 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7505 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007506 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7507 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7509 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7510 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7511 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7512 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007514 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7516 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007517 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007518 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7519 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7520 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007521 { } /* end */
7522};
7523
Kailang Yangccc656c2006-10-17 12:32:26 +02007524static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7525 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7528 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7529 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7530 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7531 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7532 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7533 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7534 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7535 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007541 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007542};
Kailang Yangccc656c2006-10-17 12:32:26 +02007543
7544static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7547 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7548 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7549 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007551 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007553 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7554 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7555 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007556 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007557};
Kailang Yangccc656c2006-10-17 12:32:26 +02007558
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007559static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7560 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7561 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007562 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7563 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7566 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007568 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007569};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007570
Kailang Yang272a5272007-05-14 11:00:38 +02007571static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 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("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7580 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007581 { } /* end */
7582};
7583
7584static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7585 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7587 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7592 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7593 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007594 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007595};
Kailang Yang272a5272007-05-14 11:00:38 +02007596
Tobin Davis2880a862007-08-07 11:50:26 +02007597static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007598 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7599 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7604 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007606 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007607};
Tobin Davis2880a862007-08-07 11:50:26 +02007608
Kailang Yange2757d52008-08-26 13:17:46 +02007609static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7611 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7613 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7614 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7615 0x0d, 1, 0x0, HDA_OUTPUT),
7616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7619 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7620 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7622 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7623 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7624 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7631 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7632 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007633 { } /* end */
7634};
7635
7636static struct hda_bind_ctls alc883_bind_cap_vol = {
7637 .ops = &snd_hda_bind_vol,
7638 .values = {
7639 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7640 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7641 0
7642 },
7643};
7644
7645static struct hda_bind_ctls alc883_bind_cap_switch = {
7646 .ops = &snd_hda_bind_sw,
7647 .values = {
7648 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7649 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7650 0
7651 },
7652};
7653
7654static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7655 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7656 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007663 { } /* end */
7664};
7665
7666static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007667 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7668 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7669 {
7670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7671 /* .name = "Capture Source", */
7672 .name = "Input Source",
7673 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007674 .info = alc_mux_enum_info,
7675 .get = alc_mux_enum_get,
7676 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007677 },
7678 { } /* end */
7679};
7680
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007681static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7682 {
7683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7684 .name = "Channel Mode",
7685 .info = alc_ch_mode_info,
7686 .get = alc_ch_mode_get,
7687 .put = alc_ch_mode_put,
7688 },
7689 { } /* end */
7690};
7691
7692static struct hda_verb alc883_init_verbs[] = {
7693 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007695 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7696 /* ADC2: mute amp left and right */
7697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7699 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7703 /* Rear mixer */
7704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7707 /* CLFE mixer */
7708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7711 /* Side mixer */
7712 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7713 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7715
Takashi Iwaicb53c622007-08-10 17:21:45 +02007716 /* mute analog input loopbacks */
7717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007722
7723 /* Front Pin: output 0 (0x0c) */
7724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7726 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7727 /* Rear Pin: output 1 (0x0d) */
7728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7730 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7731 /* CLFE Pin: output 2 (0x0e) */
7732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7734 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7735 /* Side Pin: output 3 (0x0f) */
7736 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7738 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7739 /* Mic (rear) pin: input vref at 80% */
7740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7742 /* Front Mic pin: input vref at 80% */
7743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7745 /* Line In pin: input */
7746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7747 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7748 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7750 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7751 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7752 /* CD pin widget for input */
7753 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7754
7755 /* FIXME: use matrix-type input source selection */
7756 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7757 /* Input mixer2 */
7758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007762 /* Input mixer3 */
7763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007767 { }
7768};
7769
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007770/* toggle speaker-output according to the hp-jack state */
7771static void alc883_mitac_hp_automute(struct hda_codec *codec)
7772{
7773 unsigned int present;
7774
7775 present = snd_hda_codec_read(codec, 0x15, 0,
7776 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7777 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7778 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7779 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7780 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7781}
7782
7783/* auto-toggle front mic */
7784/*
7785static void alc883_mitac_mic_automute(struct hda_codec *codec)
7786{
7787 unsigned int present;
7788 unsigned char bits;
7789
7790 present = snd_hda_codec_read(codec, 0x18, 0,
7791 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7792 bits = present ? HDA_AMP_MUTE : 0;
7793 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7794}
7795*/
7796
7797static void alc883_mitac_automute(struct hda_codec *codec)
7798{
7799 alc883_mitac_hp_automute(codec);
7800 /* alc883_mitac_mic_automute(codec); */
7801}
7802
7803static void alc883_mitac_unsol_event(struct hda_codec *codec,
7804 unsigned int res)
7805{
7806 switch (res >> 26) {
7807 case ALC880_HP_EVENT:
7808 alc883_mitac_hp_automute(codec);
7809 break;
7810 case ALC880_MIC_EVENT:
7811 /* alc883_mitac_mic_automute(codec); */
7812 break;
7813 }
7814}
7815
7816static struct hda_verb alc883_mitac_verbs[] = {
7817 /* HP */
7818 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7820 /* Subwoofer */
7821 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7822 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7823
7824 /* enable unsolicited event */
7825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7826 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7827
7828 { } /* end */
7829};
7830
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007831static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007832 /* HP */
7833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7835 /* Int speaker */
7836 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7838
7839 /* enable unsolicited event */
7840 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007841 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007842
7843 { } /* end */
7844};
7845
Jiang zhefb97dc62008-03-06 11:07:11 +01007846static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7847 /* HP */
7848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7850 /* Subwoofer */
7851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7853
7854 /* enable unsolicited event */
7855 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7856
7857 { } /* end */
7858};
7859
Kailang Yangccc656c2006-10-17 12:32:26 +02007860static struct hda_verb alc883_tagra_verbs[] = {
7861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7863
7864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7865 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007866
Kailang Yangccc656c2006-10-17 12:32:26 +02007867 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7868 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7869 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7870
7871 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007872 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7873 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7874 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007875
7876 { } /* end */
7877};
7878
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007879static struct hda_verb alc883_lenovo_101e_verbs[] = {
7880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7882 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7883 { } /* end */
7884};
7885
Kailang Yang272a5272007-05-14 11:00:38 +02007886static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7887 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7889 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7891 { } /* end */
7892};
7893
7894static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7899 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7900 { } /* end */
7901};
7902
Kailang Yang189609a2007-08-20 11:31:23 +02007903static struct hda_verb alc883_haier_w66_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
7907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7908
7909 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7911 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7913 { } /* end */
7914};
7915
Kailang Yange2757d52008-08-26 13:17:46 +02007916static struct hda_verb alc888_lenovo_sky_verbs[] = {
7917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7923 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7924 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7925 { } /* end */
7926};
7927
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007928static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007929 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007930 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7931 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007932 { }
7933};
7934
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007935static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007936 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7937 { }
7938};
7939
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007940static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007941 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7942 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7943 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7944 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7945 { }
7946};
7947
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007948static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7951 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7952 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7953 { }
7954};
7955
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007956static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7957 { 2, alc888_3st_hp_2ch_init },
7958 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007959};
7960
Kailang Yang272a5272007-05-14 11:00:38 +02007961/* toggle front-jack and RCA according to the hp-jack state */
7962static void alc888_lenovo_ms7195_front_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, 0x1b, 0,
7967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007968 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7970 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7971 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007972}
7973
7974/* toggle RCA according to the front-jack state */
7975static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7976{
7977 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007978
Kailang Yang272a5272007-05-14 11:00:38 +02007979 present = snd_hda_codec_read(codec, 0x14, 0,
7980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007981 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7982 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007983}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007984
Kailang Yang272a5272007-05-14 11:00:38 +02007985static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7986 unsigned int res)
7987{
7988 if ((res >> 26) == ALC880_HP_EVENT)
7989 alc888_lenovo_ms7195_front_automute(codec);
7990 if ((res >> 26) == ALC880_FRONT_EVENT)
7991 alc888_lenovo_ms7195_rca_automute(codec);
7992}
7993
7994static struct hda_verb alc883_medion_md2_verbs[] = {
7995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7997
7998 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7999
8000 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8001 { } /* end */
8002};
8003
8004/* toggle speaker-output according to the hp-jack state */
8005static void alc883_medion_md2_automute(struct hda_codec *codec)
8006{
8007 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008008
Kailang Yang272a5272007-05-14 11:00:38 +02008009 present = snd_hda_codec_read(codec, 0x14, 0,
8010 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008011 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8012 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008013}
8014
8015static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8016 unsigned int res)
8017{
8018 if ((res >> 26) == ALC880_HP_EVENT)
8019 alc883_medion_md2_automute(codec);
8020}
8021
Kailang Yangccc656c2006-10-17 12:32:26 +02008022/* toggle speaker-output according to the hp-jack state */
8023static void alc883_tagra_automute(struct hda_codec *codec)
8024{
8025 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008026 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008027
8028 present = snd_hda_codec_read(codec, 0x14, 0,
8029 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008030 bits = present ? HDA_AMP_MUTE : 0;
8031 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8032 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008033 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8034 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008035}
8036
8037static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8038{
8039 if ((res >> 26) == ALC880_HP_EVENT)
8040 alc883_tagra_automute(codec);
8041}
8042
Jiang zhe368c7a92008-03-04 11:20:33 +01008043/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008044static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008045{
8046 unsigned int present;
8047 unsigned char bits;
8048
8049 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8050 & AC_PINSENSE_PRESENCE;
8051 bits = present ? HDA_AMP_MUTE : 0;
8052 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8053 HDA_AMP_MUTE, bits);
8054}
8055
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008056static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8057{
8058 unsigned int present;
8059
8060 present = snd_hda_codec_read(codec, 0x18, 0,
8061 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8062 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8063 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8064}
8065
8066static void alc883_clevo_m720_automute(struct hda_codec *codec)
8067{
8068 alc883_clevo_m720_hp_automute(codec);
8069 alc883_clevo_m720_mic_automute(codec);
8070}
8071
8072static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008073 unsigned int res)
8074{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008075 switch (res >> 26) {
8076 case ALC880_HP_EVENT:
8077 alc883_clevo_m720_hp_automute(codec);
8078 break;
8079 case ALC880_MIC_EVENT:
8080 alc883_clevo_m720_mic_automute(codec);
8081 break;
8082 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008083}
8084
Jiang zhefb97dc62008-03-06 11:07:11 +01008085/* toggle speaker-output according to the hp-jack state */
8086static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8087{
8088 unsigned int present;
8089 unsigned char bits;
8090
8091 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8092 & AC_PINSENSE_PRESENCE;
8093 bits = present ? HDA_AMP_MUTE : 0;
8094 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8095 HDA_AMP_MUTE, bits);
8096}
8097
8098static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8099 unsigned int res)
8100{
8101 if ((res >> 26) == ALC880_HP_EVENT)
8102 alc883_2ch_fujitsu_pi2515_automute(codec);
8103}
8104
Kailang Yang189609a2007-08-20 11:31:23 +02008105static void alc883_haier_w66_automute(struct hda_codec *codec)
8106{
8107 unsigned int present;
8108 unsigned char bits;
8109
8110 present = snd_hda_codec_read(codec, 0x1b, 0,
8111 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8112 bits = present ? 0x80 : 0;
8113 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8114 0x80, bits);
8115}
8116
8117static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8118 unsigned int res)
8119{
8120 if ((res >> 26) == ALC880_HP_EVENT)
8121 alc883_haier_w66_automute(codec);
8122}
8123
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008124static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8125{
8126 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008127 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008128
8129 present = snd_hda_codec_read(codec, 0x14, 0,
8130 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008131 bits = present ? HDA_AMP_MUTE : 0;
8132 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8133 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008134}
8135
8136static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8137{
8138 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008139 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008140
8141 present = snd_hda_codec_read(codec, 0x1b, 0,
8142 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008143 bits = present ? HDA_AMP_MUTE : 0;
8144 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8145 HDA_AMP_MUTE, bits);
8146 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8147 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008148}
8149
8150static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8151 unsigned int res)
8152{
8153 if ((res >> 26) == ALC880_HP_EVENT)
8154 alc883_lenovo_101e_all_automute(codec);
8155 if ((res >> 26) == ALC880_FRONT_EVENT)
8156 alc883_lenovo_101e_ispeaker_automute(codec);
8157}
8158
Takashi Iwai676a9b52007-08-16 15:23:35 +02008159/* toggle speaker-output according to the hp-jack state */
8160static void alc883_acer_aspire_automute(struct hda_codec *codec)
8161{
8162 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008163
Takashi Iwai676a9b52007-08-16 15:23:35 +02008164 present = snd_hda_codec_read(codec, 0x14, 0,
8165 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8166 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8167 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8168 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8169 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8170}
8171
8172static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8173 unsigned int res)
8174{
8175 if ((res >> 26) == ALC880_HP_EVENT)
8176 alc883_acer_aspire_automute(codec);
8177}
8178
Kailang Yangd1a991a2007-08-15 16:21:59 +02008179static struct hda_verb alc883_acer_eapd_verbs[] = {
8180 /* HP Pin: output 0 (0x0c) */
8181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8183 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008185 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008187 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008188 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8189 /* eanable EAPD on medion laptop */
8190 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8191 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008192 /* enable unsolicited event */
8193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008194 { }
8195};
8196
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008197static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8198{
8199 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008200
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008201 present = snd_hda_codec_read(codec, 0x1b, 0,
8202 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8203 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8204 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8205 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8206 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8207 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8208 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8209 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8210 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8211}
8212
8213static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8214 unsigned int res)
8215{
8216 switch (res >> 26) {
8217 case ALC880_HP_EVENT:
8218 printk("hp_event\n");
8219 alc888_6st_dell_front_automute(codec);
8220 break;
8221 }
8222}
8223
Kailang Yange2757d52008-08-26 13:17:46 +02008224static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8225{
8226 unsigned int mute;
8227 unsigned int present;
8228
8229 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8230 present = snd_hda_codec_read(codec, 0x1b, 0,
8231 AC_VERB_GET_PIN_SENSE, 0);
8232 present = (present & 0x80000000) != 0;
8233 if (present) {
8234 /* mute internal speaker */
8235 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8236 HDA_AMP_MUTE, HDA_AMP_MUTE);
8237 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8238 HDA_AMP_MUTE, HDA_AMP_MUTE);
8239 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8240 HDA_AMP_MUTE, HDA_AMP_MUTE);
8241 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8242 HDA_AMP_MUTE, HDA_AMP_MUTE);
8243 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8244 HDA_AMP_MUTE, HDA_AMP_MUTE);
8245 } else {
8246 /* unmute internal speaker if necessary */
8247 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8249 HDA_AMP_MUTE, mute);
8250 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8251 HDA_AMP_MUTE, mute);
8252 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8253 HDA_AMP_MUTE, mute);
8254 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8255 HDA_AMP_MUTE, mute);
8256 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8257 HDA_AMP_MUTE, mute);
8258 }
8259}
8260
8261static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8262 unsigned int res)
8263{
8264 if ((res >> 26) == ALC880_HP_EVENT)
8265 alc888_lenovo_sky_front_automute(codec);
8266}
8267
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008268/*
8269 * generic initialization of ADC, input mixers and output mixers
8270 */
8271static struct hda_verb alc883_auto_init_verbs[] = {
8272 /*
8273 * Unmute ADC0-2 and set the default input to mic-in
8274 */
8275 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8277 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8278 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8279
Takashi Iwaicb53c622007-08-10 17:21:45 +02008280 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008281 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008282 * Note: PASD motherboards uses the Line In 2 as the input for
8283 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008284 */
8285 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008291
8292 /*
8293 * Set up output mixers (0x0c - 0x0f)
8294 */
8295 /* set vol=0 to output mixers */
8296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8300 /* set up input amps for analog loopback */
8301 /* Amp Indices: DAC = 0, mixer = 1 */
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8310 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8311 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8312
8313 /* FIXME: use matrix-type input source selection */
8314 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8315 /* Input mixer1 */
8316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008319 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8321 /* Input mixer2 */
8322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008325 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008327
8328 { }
8329};
8330
Kailang Yange2757d52008-08-26 13:17:46 +02008331static struct hda_verb alc888_asus_m90v_verbs[] = {
8332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8335 /* enable unsolicited event */
8336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8337 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8338 { } /* end */
8339};
8340
8341static void alc883_nb_mic_automute(struct hda_codec *codec)
8342{
8343 unsigned int present;
8344
8345 present = snd_hda_codec_read(codec, 0x18, 0,
8346 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8347 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8348 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8349 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8350 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8351}
8352
8353static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8354{
8355 unsigned int present;
8356 unsigned char bits;
8357
8358 present = snd_hda_codec_read(codec, 0x1b, 0,
8359 AC_VERB_GET_PIN_SENSE, 0)
8360 & AC_PINSENSE_PRESENCE;
8361 bits = present ? 0 : PIN_OUT;
8362 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8363 bits);
8364 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8365 bits);
8366 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8367 bits);
8368}
8369
8370static void alc883_mode2_unsol_event(struct hda_codec *codec,
8371 unsigned int res)
8372{
8373 switch (res >> 26) {
8374 case ALC880_HP_EVENT:
8375 alc883_M90V_speaker_automute(codec);
8376 break;
8377 case ALC880_MIC_EVENT:
8378 alc883_nb_mic_automute(codec);
8379 break;
8380 }
8381}
8382
8383static void alc883_mode2_inithook(struct hda_codec *codec)
8384{
8385 alc883_M90V_speaker_automute(codec);
8386 alc883_nb_mic_automute(codec);
8387}
8388
8389static struct hda_verb alc888_asus_eee1601_verbs[] = {
8390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8391 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8395 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8396 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8397 /* enable unsolicited event */
8398 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8399 { } /* end */
8400};
8401
8402static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8403{
8404 unsigned int present;
8405 unsigned char bits;
8406
8407 present = snd_hda_codec_read(codec, 0x14, 0,
8408 AC_VERB_GET_PIN_SENSE, 0)
8409 & AC_PINSENSE_PRESENCE;
8410 bits = present ? 0 : PIN_OUT;
8411 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8412 bits);
8413}
8414
8415static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8416 unsigned int res)
8417{
8418 switch (res >> 26) {
8419 case ALC880_HP_EVENT:
8420 alc883_eee1601_speaker_automute(codec);
8421 break;
8422 }
8423}
8424
8425static void alc883_eee1601_inithook(struct hda_codec *codec)
8426{
8427 alc883_eee1601_speaker_automute(codec);
8428}
8429
Takashi Iwaicb53c622007-08-10 17:21:45 +02008430#ifdef CONFIG_SND_HDA_POWER_SAVE
8431#define alc883_loopbacks alc880_loopbacks
8432#endif
8433
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008434/* pcm configuration: identiacal with ALC880 */
8435#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8436#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008437#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008438#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8439#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8440
8441/*
8442 * configuration and preset
8443 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008444static const char *alc883_models[ALC883_MODEL_LAST] = {
8445 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8446 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8447 [ALC883_3ST_6ch] = "3stack-6ch",
8448 [ALC883_6ST_DIG] = "6stack-dig",
8449 [ALC883_TARGA_DIG] = "targa-dig",
8450 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008451 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008452 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008453 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008454 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008455 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008456 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008457 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008458 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8459 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008460 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008461 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008462 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008463 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008464 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008465 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008466 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008467 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008468 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008469 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008470 [ALC883_AUTO] = "auto",
8471};
8472
8473static struct snd_pci_quirk alc883_cfg_tbl[] = {
8474 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008475 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008476 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008477 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8478 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008479 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008480 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8481 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008482 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8483 ALC888_ACER_ASPIRE_4930G),
8484 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8485 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008486 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008487 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008488 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008489 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8490 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008491 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008492 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008493 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008494 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008495 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008496 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008497 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008498 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008499 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008500 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8501 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008502 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008503 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008504 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008505 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8506 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8507 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008508 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008509 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008510 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008511 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8512 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8513 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8514 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8515 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8516 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8517 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8518 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8519 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008520 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8521 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008522 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008523 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008524 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008525 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008526 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008527 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008528 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008529 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8530 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008531 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008532 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008533 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008534 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008535 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8536 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008537 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008538 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008539 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8540 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008541 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008542 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008543 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008544 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008545 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008546 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8547 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008548 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008549 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008550 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008551 {}
8552};
8553
8554static struct alc_config_preset alc883_presets[] = {
8555 [ALC883_3ST_2ch_DIG] = {
8556 .mixers = { alc883_3ST_2ch_mixer },
8557 .init_verbs = { alc883_init_verbs },
8558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8559 .dac_nids = alc883_dac_nids,
8560 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008561 .dig_in_nid = ALC883_DIGIN_NID,
8562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8563 .channel_mode = alc883_3ST_2ch_modes,
8564 .input_mux = &alc883_capture_source,
8565 },
8566 [ALC883_3ST_6ch_DIG] = {
8567 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8568 .init_verbs = { alc883_init_verbs },
8569 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8570 .dac_nids = alc883_dac_nids,
8571 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008572 .dig_in_nid = ALC883_DIGIN_NID,
8573 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8574 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008575 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008576 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008577 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008578 [ALC883_3ST_6ch] = {
8579 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8580 .init_verbs = { alc883_init_verbs },
8581 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8582 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008583 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8584 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008585 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008586 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008587 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008588 [ALC883_3ST_6ch_INTEL] = {
8589 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8590 .init_verbs = { alc883_init_verbs },
8591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8592 .dac_nids = alc883_dac_nids,
8593 .dig_out_nid = ALC883_DIGOUT_NID,
8594 .dig_in_nid = ALC883_DIGIN_NID,
8595 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8596 .channel_mode = alc883_3ST_6ch_intel_modes,
8597 .need_dac_fix = 1,
8598 .input_mux = &alc883_3stack_6ch_intel,
8599 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008600 [ALC883_6ST_DIG] = {
8601 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8602 .init_verbs = { alc883_init_verbs },
8603 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8604 .dac_nids = alc883_dac_nids,
8605 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008606 .dig_in_nid = ALC883_DIGIN_NID,
8607 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8608 .channel_mode = alc883_sixstack_modes,
8609 .input_mux = &alc883_capture_source,
8610 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008611 [ALC883_TARGA_DIG] = {
8612 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8613 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8614 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8615 .dac_nids = alc883_dac_nids,
8616 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8618 .channel_mode = alc883_3ST_6ch_modes,
8619 .need_dac_fix = 1,
8620 .input_mux = &alc883_capture_source,
8621 .unsol_event = alc883_tagra_unsol_event,
8622 .init_hook = alc883_tagra_automute,
8623 },
8624 [ALC883_TARGA_2ch_DIG] = {
8625 .mixers = { alc883_tagra_2ch_mixer},
8626 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8628 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008629 .adc_nids = alc883_adc_nids_alt,
8630 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008631 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008632 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8633 .channel_mode = alc883_3ST_2ch_modes,
8634 .input_mux = &alc883_capture_source,
8635 .unsol_event = alc883_tagra_unsol_event,
8636 .init_hook = alc883_tagra_automute,
8637 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008638 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008639 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008640 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8641 * and the headphone jack. Turn this on and rely on the
8642 * standard mute methods whenever the user wants to turn
8643 * these outputs off.
8644 */
8645 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8646 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8647 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8649 .channel_mode = alc883_3ST_2ch_modes,
8650 .input_mux = &alc883_capture_source,
8651 },
Tobin Davis2880a862007-08-07 11:50:26 +02008652 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008653 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008654 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8656 .dac_nids = alc883_dac_nids,
8657 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8659 .channel_mode = alc883_3ST_2ch_modes,
8660 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008661 .unsol_event = alc883_acer_aspire_unsol_event,
8662 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008663 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008664 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008665 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008666 alc883_chmode_mixer },
8667 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8668 alc888_acer_aspire_4930g_verbs },
8669 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8670 .dac_nids = alc883_dac_nids,
8671 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8672 .adc_nids = alc883_adc_nids_rev,
8673 .capsrc_nids = alc883_capsrc_nids_rev,
8674 .dig_out_nid = ALC883_DIGOUT_NID,
8675 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8676 .channel_mode = alc883_3ST_6ch_modes,
8677 .need_dac_fix = 1,
8678 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008679 ARRAY_SIZE(alc888_2_capture_sources),
8680 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008681 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8682 .init_hook = alc888_acer_aspire_4930g_automute,
8683 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008684 [ALC883_MEDION] = {
8685 .mixers = { alc883_fivestack_mixer,
8686 alc883_chmode_mixer },
8687 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008688 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008689 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8690 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008691 .adc_nids = alc883_adc_nids_alt,
8692 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008693 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8694 .channel_mode = alc883_sixstack_modes,
8695 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008696 },
Kailang Yang272a5272007-05-14 11:00:38 +02008697 [ALC883_MEDION_MD2] = {
8698 .mixers = { alc883_medion_md2_mixer},
8699 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8701 .dac_nids = alc883_dac_nids,
8702 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008703 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8704 .channel_mode = alc883_3ST_2ch_modes,
8705 .input_mux = &alc883_capture_source,
8706 .unsol_event = alc883_medion_md2_unsol_event,
8707 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008708 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008709 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008710 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008711 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8712 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8713 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8715 .channel_mode = alc883_3ST_2ch_modes,
8716 .input_mux = &alc883_capture_source,
8717 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008718 [ALC883_CLEVO_M720] = {
8719 .mixers = { alc883_clevo_m720_mixer },
8720 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008721 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8722 .dac_nids = alc883_dac_nids,
8723 .dig_out_nid = ALC883_DIGOUT_NID,
8724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8725 .channel_mode = alc883_3ST_2ch_modes,
8726 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008727 .unsol_event = alc883_clevo_m720_unsol_event,
8728 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008729 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008730 [ALC883_LENOVO_101E_2ch] = {
8731 .mixers = { alc883_lenovo_101e_2ch_mixer},
8732 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8733 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8734 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008735 .adc_nids = alc883_adc_nids_alt,
8736 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008737 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8738 .channel_mode = alc883_3ST_2ch_modes,
8739 .input_mux = &alc883_lenovo_101e_capture_source,
8740 .unsol_event = alc883_lenovo_101e_unsol_event,
8741 .init_hook = alc883_lenovo_101e_all_automute,
8742 },
Kailang Yang272a5272007-05-14 11:00:38 +02008743 [ALC883_LENOVO_NB0763] = {
8744 .mixers = { alc883_lenovo_nb0763_mixer },
8745 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8747 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008748 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8749 .channel_mode = alc883_3ST_2ch_modes,
8750 .need_dac_fix = 1,
8751 .input_mux = &alc883_lenovo_nb0763_capture_source,
8752 .unsol_event = alc883_medion_md2_unsol_event,
8753 .init_hook = alc883_medion_md2_automute,
8754 },
8755 [ALC888_LENOVO_MS7195_DIG] = {
8756 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8757 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8758 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8759 .dac_nids = alc883_dac_nids,
8760 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008761 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8762 .channel_mode = alc883_3ST_6ch_modes,
8763 .need_dac_fix = 1,
8764 .input_mux = &alc883_capture_source,
8765 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8766 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008767 },
8768 [ALC883_HAIER_W66] = {
8769 .mixers = { alc883_tagra_2ch_mixer},
8770 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8771 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8772 .dac_nids = alc883_dac_nids,
8773 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008774 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8775 .channel_mode = alc883_3ST_2ch_modes,
8776 .input_mux = &alc883_capture_source,
8777 .unsol_event = alc883_haier_w66_unsol_event,
8778 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008779 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008780 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008781 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008782 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008783 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8784 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008785 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8786 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008787 .need_dac_fix = 1,
8788 .input_mux = &alc883_capture_source,
8789 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008790 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008791 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008792 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8793 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8794 .dac_nids = alc883_dac_nids,
8795 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008796 .dig_in_nid = ALC883_DIGIN_NID,
8797 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8798 .channel_mode = alc883_sixstack_modes,
8799 .input_mux = &alc883_capture_source,
8800 .unsol_event = alc888_6st_dell_unsol_event,
8801 .init_hook = alc888_6st_dell_front_automute,
8802 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008803 [ALC883_MITAC] = {
8804 .mixers = { alc883_mitac_mixer },
8805 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8807 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008808 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8809 .channel_mode = alc883_3ST_2ch_modes,
8810 .input_mux = &alc883_capture_source,
8811 .unsol_event = alc883_mitac_unsol_event,
8812 .init_hook = alc883_mitac_automute,
8813 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008814 [ALC883_FUJITSU_PI2515] = {
8815 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8816 .init_verbs = { alc883_init_verbs,
8817 alc883_2ch_fujitsu_pi2515_verbs},
8818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8819 .dac_nids = alc883_dac_nids,
8820 .dig_out_nid = ALC883_DIGOUT_NID,
8821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8822 .channel_mode = alc883_3ST_2ch_modes,
8823 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8824 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8825 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8826 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008827 [ALC888_FUJITSU_XA3530] = {
8828 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8829 .init_verbs = { alc883_init_verbs,
8830 alc888_fujitsu_xa3530_verbs },
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
8833 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8834 .adc_nids = alc883_adc_nids_rev,
8835 .capsrc_nids = alc883_capsrc_nids_rev,
8836 .dig_out_nid = ALC883_DIGOUT_NID,
8837 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8838 .channel_mode = alc888_4ST_8ch_intel_modes,
8839 .num_mux_defs =
8840 ARRAY_SIZE(alc888_2_capture_sources),
8841 .input_mux = alc888_2_capture_sources,
8842 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8843 .init_hook = alc888_fujitsu_xa3530_automute,
8844 },
Kailang Yange2757d52008-08-26 13:17:46 +02008845 [ALC888_LENOVO_SKY] = {
8846 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8847 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8848 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8849 .dac_nids = alc883_dac_nids,
8850 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008851 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8852 .channel_mode = alc883_sixstack_modes,
8853 .need_dac_fix = 1,
8854 .input_mux = &alc883_lenovo_sky_capture_source,
8855 .unsol_event = alc883_lenovo_sky_unsol_event,
8856 .init_hook = alc888_lenovo_sky_front_automute,
8857 },
8858 [ALC888_ASUS_M90V] = {
8859 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8860 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8861 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8862 .dac_nids = alc883_dac_nids,
8863 .dig_out_nid = ALC883_DIGOUT_NID,
8864 .dig_in_nid = ALC883_DIGIN_NID,
8865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8866 .channel_mode = alc883_3ST_6ch_modes,
8867 .need_dac_fix = 1,
8868 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8869 .unsol_event = alc883_mode2_unsol_event,
8870 .init_hook = alc883_mode2_inithook,
8871 },
8872 [ALC888_ASUS_EEE1601] = {
8873 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008874 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008875 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8877 .dac_nids = alc883_dac_nids,
8878 .dig_out_nid = ALC883_DIGOUT_NID,
8879 .dig_in_nid = ALC883_DIGIN_NID,
8880 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8881 .channel_mode = alc883_3ST_2ch_modes,
8882 .need_dac_fix = 1,
8883 .input_mux = &alc883_asus_eee1601_capture_source,
8884 .unsol_event = alc883_eee1601_unsol_event,
8885 .init_hook = alc883_eee1601_inithook,
8886 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008887 [ALC1200_ASUS_P5Q] = {
8888 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8889 .init_verbs = { alc883_init_verbs },
8890 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8891 .dac_nids = alc883_dac_nids,
8892 .dig_out_nid = ALC1200_DIGOUT_NID,
8893 .dig_in_nid = ALC883_DIGIN_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8895 .channel_mode = alc883_sixstack_modes,
8896 .input_mux = &alc883_capture_source,
8897 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008898};
8899
8900
8901/*
8902 * BIOS auto configuration
8903 */
8904static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8905 hda_nid_t nid, int pin_type,
8906 int dac_idx)
8907{
8908 /* set as output */
8909 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008910 int idx;
8911
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008912 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008913 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8914 idx = 4;
8915 else
8916 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008917 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8918
8919}
8920
8921static void alc883_auto_init_multi_out(struct hda_codec *codec)
8922{
8923 struct alc_spec *spec = codec->spec;
8924 int i;
8925
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008926 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008927 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008928 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008929 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008930 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008931 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008932 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008933 }
8934}
8935
8936static void alc883_auto_init_hp_out(struct hda_codec *codec)
8937{
8938 struct alc_spec *spec = codec->spec;
8939 hda_nid_t pin;
8940
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008941 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008942 if (pin) /* connect to front */
8943 /* use dac 0 */
8944 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008945 pin = spec->autocfg.speaker_pins[0];
8946 if (pin)
8947 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008948}
8949
8950#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8951#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8952
8953static void alc883_auto_init_analog_input(struct hda_codec *codec)
8954{
8955 struct alc_spec *spec = codec->spec;
8956 int i;
8957
8958 for (i = 0; i < AUTO_PIN_LAST; i++) {
8959 hda_nid_t nid = spec->autocfg.input_pins[i];
8960 if (alc883_is_input_pin(nid)) {
8961 snd_hda_codec_write(codec, nid, 0,
8962 AC_VERB_SET_PIN_WIDGET_CONTROL,
8963 (i <= AUTO_PIN_FRONT_MIC ?
8964 PIN_VREF80 : PIN_IN));
8965 if (nid != ALC883_PIN_CD_NID)
8966 snd_hda_codec_write(codec, nid, 0,
8967 AC_VERB_SET_AMP_GAIN_MUTE,
8968 AMP_OUT_MUTE);
8969 }
8970 }
8971}
8972
Takashi Iwaif511b012008-08-15 16:46:42 +02008973#define alc883_auto_init_input_src alc882_auto_init_input_src
8974
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008975/* almost identical with ALC880 parser... */
8976static int alc883_parse_auto_config(struct hda_codec *codec)
8977{
8978 struct alc_spec *spec = codec->spec;
8979 int err = alc880_parse_auto_config(codec);
8980
8981 if (err < 0)
8982 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008983 else if (!err)
8984 return 0; /* no config found */
8985
8986 err = alc_auto_add_mic_boost(codec);
8987 if (err < 0)
8988 return err;
8989
8990 /* hack - override the init verbs */
8991 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008992
8993 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008994}
8995
8996/* additional initialization for auto-configuration model */
8997static void alc883_auto_init(struct hda_codec *codec)
8998{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008999 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 alc883_auto_init_multi_out(codec);
9001 alc883_auto_init_hp_out(codec);
9002 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009003 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009004 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009005 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009006}
9007
9008static int patch_alc883(struct hda_codec *codec)
9009{
9010 struct alc_spec *spec;
9011 int err, board_config;
9012
9013 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9014 if (spec == NULL)
9015 return -ENOMEM;
9016
9017 codec->spec = spec;
9018
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009019 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9020
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009021 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9022 alc883_models,
9023 alc883_cfg_tbl);
9024 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009025 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9026 "trying auto-probe from BIOS...\n");
9027 board_config = ALC883_AUTO;
9028 }
9029
9030 if (board_config == ALC883_AUTO) {
9031 /* automatic parse from the BIOS config */
9032 err = alc883_parse_auto_config(codec);
9033 if (err < 0) {
9034 alc_free(codec);
9035 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009036 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009037 printk(KERN_INFO
9038 "hda_codec: Cannot set up configuration "
9039 "from BIOS. Using base mode...\n");
9040 board_config = ALC883_3ST_2ch_DIG;
9041 }
9042 }
9043
9044 if (board_config != ALC883_AUTO)
9045 setup_preset(spec, &alc883_presets[board_config]);
9046
Kailang Yang2f893282008-05-27 12:14:47 +02009047 switch (codec->vendor_id) {
9048 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009049 if (codec->revision_id == 0x100101) {
9050 spec->stream_name_analog = "ALC1200 Analog";
9051 spec->stream_name_digital = "ALC1200 Digital";
9052 } else {
9053 spec->stream_name_analog = "ALC888 Analog";
9054 spec->stream_name_digital = "ALC888 Digital";
9055 }
Kailang Yang2f893282008-05-27 12:14:47 +02009056 break;
9057 case 0x10ec0889:
9058 spec->stream_name_analog = "ALC889 Analog";
9059 spec->stream_name_digital = "ALC889 Digital";
9060 break;
9061 default:
9062 spec->stream_name_analog = "ALC883 Analog";
9063 spec->stream_name_digital = "ALC883 Digital";
9064 break;
9065 }
9066
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009067 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9068 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009069 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009070
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009071 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9072 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9073
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009074 if (!spec->num_adc_nids) {
9075 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9076 spec->adc_nids = alc883_adc_nids;
9077 }
9078 if (!spec->capsrc_nids)
9079 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009080 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009081 if (!spec->cap_mixer)
9082 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009083
Takashi Iwai2134ea42008-01-10 16:53:55 +01009084 spec->vmaster_nid = 0x0c;
9085
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009086 codec->patch_ops = alc_patch_ops;
9087 if (board_config == ALC883_AUTO)
9088 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009089
Takashi Iwaicb53c622007-08-10 17:21:45 +02009090#ifdef CONFIG_SND_HDA_POWER_SAVE
9091 if (!spec->loopback.amplist)
9092 spec->loopback.amplist = alc883_loopbacks;
9093#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009094 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009095
9096 return 0;
9097}
9098
9099/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009100 * ALC262 support
9101 */
9102
9103#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9104#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9105
9106#define alc262_dac_nids alc260_dac_nids
9107#define alc262_adc_nids alc882_adc_nids
9108#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009109#define alc262_capsrc_nids alc882_capsrc_nids
9110#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009111
9112#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009113#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009114
Kailang Yang4e555fe2008-08-26 13:05:55 +02009115static hda_nid_t alc262_dmic_adc_nids[1] = {
9116 /* ADC0 */
9117 0x09
9118};
9119
9120static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9121
Kailang Yangdf694da2005-12-05 19:42:22 +01009122static struct snd_kcontrol_new alc262_base_mixer[] = {
9123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9124 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009134 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009135 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009136 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01009137 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9139 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9140 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009141 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009142};
9143
Kailang Yangccc656c2006-10-17 12:32:26 +02009144static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9146 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9155 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009157 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01009158 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02009159 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9161 { } /* end */
9162};
9163
Takashi Iwaice875f02008-01-28 18:17:43 +01009164/* update HP, line and mono-out pins according to the master switch */
9165static void alc262_hp_master_update(struct hda_codec *codec)
9166{
9167 struct alc_spec *spec = codec->spec;
9168 int val = spec->master_sw;
9169
9170 /* HP & line-out */
9171 snd_hda_codec_write_cache(codec, 0x1b, 0,
9172 AC_VERB_SET_PIN_WIDGET_CONTROL,
9173 val ? PIN_HP : 0);
9174 snd_hda_codec_write_cache(codec, 0x15, 0,
9175 AC_VERB_SET_PIN_WIDGET_CONTROL,
9176 val ? PIN_HP : 0);
9177 /* mono (speaker) depending on the HP jack sense */
9178 val = val && !spec->jack_present;
9179 snd_hda_codec_write_cache(codec, 0x16, 0,
9180 AC_VERB_SET_PIN_WIDGET_CONTROL,
9181 val ? PIN_OUT : 0);
9182}
9183
9184static void alc262_hp_bpc_automute(struct hda_codec *codec)
9185{
9186 struct alc_spec *spec = codec->spec;
9187 unsigned int presence;
9188 presence = snd_hda_codec_read(codec, 0x1b, 0,
9189 AC_VERB_GET_PIN_SENSE, 0);
9190 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9191 alc262_hp_master_update(codec);
9192}
9193
9194static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9195{
9196 if ((res >> 26) != ALC880_HP_EVENT)
9197 return;
9198 alc262_hp_bpc_automute(codec);
9199}
9200
9201static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9202{
9203 struct alc_spec *spec = codec->spec;
9204 unsigned int presence;
9205 presence = snd_hda_codec_read(codec, 0x15, 0,
9206 AC_VERB_GET_PIN_SENSE, 0);
9207 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9208 alc262_hp_master_update(codec);
9209}
9210
9211static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9212 unsigned int res)
9213{
9214 if ((res >> 26) != ALC880_HP_EVENT)
9215 return;
9216 alc262_hp_wildwest_automute(codec);
9217}
9218
9219static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9220 struct snd_ctl_elem_value *ucontrol)
9221{
9222 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9223 struct alc_spec *spec = codec->spec;
9224 *ucontrol->value.integer.value = spec->master_sw;
9225 return 0;
9226}
9227
9228static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9229 struct snd_ctl_elem_value *ucontrol)
9230{
9231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9232 struct alc_spec *spec = codec->spec;
9233 int val = !!*ucontrol->value.integer.value;
9234
9235 if (val == spec->master_sw)
9236 return 0;
9237 spec->master_sw = val;
9238 alc262_hp_master_update(codec);
9239 return 1;
9240}
9241
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009242static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009243 {
9244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9245 .name = "Master Playback Switch",
9246 .info = snd_ctl_boolean_mono_info,
9247 .get = alc262_hp_master_sw_get,
9248 .put = alc262_hp_master_sw_put,
9249 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9251 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009253 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9254 HDA_OUTPUT),
9255 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9256 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9267 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9268 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9269 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9270 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9271 { } /* end */
9272};
9273
Kailang Yangcd7509a2007-01-26 18:33:17 +01009274static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009275 {
9276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9277 .name = "Master Playback Switch",
9278 .info = snd_ctl_boolean_mono_info,
9279 .get = alc262_hp_master_sw_get,
9280 .put = alc262_hp_master_sw_put,
9281 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9283 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9284 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9285 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009286 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9287 HDA_OUTPUT),
9288 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9289 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009292 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9294 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9297 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9298 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9299 { } /* end */
9300};
9301
9302static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9303 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9304 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009305 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009306 { } /* end */
9307};
9308
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009309/* mute/unmute internal speaker according to the hp jack and mute state */
9310static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9311{
9312 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009313
9314 if (force || !spec->sense_updated) {
9315 unsigned int present;
9316 present = snd_hda_codec_read(codec, 0x15, 0,
9317 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009318 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009319 spec->sense_updated = 1;
9320 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9322 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009323}
9324
9325static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9326 unsigned int res)
9327{
9328 if ((res >> 26) != ALC880_HP_EVENT)
9329 return;
9330 alc262_hp_t5735_automute(codec, 1);
9331}
9332
9333static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9334{
9335 alc262_hp_t5735_automute(codec, 1);
9336}
9337
9338static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009339 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9340 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009341 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9345 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9346 { } /* end */
9347};
9348
9349static struct hda_verb alc262_hp_t5735_verbs[] = {
9350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9352
9353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9354 { }
9355};
9356
Kailang Yang8c427222008-01-10 13:03:59 +01009357static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009358 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009360 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9361 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009362 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9363 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9364 { } /* end */
9365};
9366
9367static struct hda_verb alc262_hp_rp5700_verbs[] = {
9368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9370 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9373 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9378 {}
9379};
9380
9381static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9382 .num_items = 1,
9383 .items = {
9384 { "Line", 0x1 },
9385 },
9386};
9387
Takashi Iwai0724ea22007-08-23 00:31:43 +02009388/* bind hp and internal speaker mute (with plug check) */
9389static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9390 struct snd_ctl_elem_value *ucontrol)
9391{
9392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9393 long *valp = ucontrol->value.integer.value;
9394 int change;
9395
9396 /* change hp mute */
9397 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9398 HDA_AMP_MUTE,
9399 valp[0] ? 0 : HDA_AMP_MUTE);
9400 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9401 HDA_AMP_MUTE,
9402 valp[1] ? 0 : HDA_AMP_MUTE);
9403 if (change) {
9404 /* change speaker according to HP jack state */
9405 struct alc_spec *spec = codec->spec;
9406 unsigned int mute;
9407 if (spec->jack_present)
9408 mute = HDA_AMP_MUTE;
9409 else
9410 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9411 HDA_OUTPUT, 0);
9412 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9413 HDA_AMP_MUTE, mute);
9414 }
9415 return change;
9416}
Takashi Iwai5b319542007-07-26 11:49:22 +02009417
Kailang Yang272a5272007-05-14 11:00:38 +02009418static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009419 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9420 {
9421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9422 .name = "Master Playback Switch",
9423 .info = snd_hda_mixer_amp_switch_info,
9424 .get = snd_hda_mixer_amp_switch_get,
9425 .put = alc262_sony_master_sw_put,
9426 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9427 },
Kailang Yang272a5272007-05-14 11:00:38 +02009428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9430 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9431 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9432 { } /* end */
9433};
9434
Kailang Yang83c34212007-07-05 11:43:05 +02009435static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9436 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9437 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9441 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9442 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9443 { } /* end */
9444};
Kailang Yang272a5272007-05-14 11:00:38 +02009445
Kailang Yangdf694da2005-12-05 19:42:22 +01009446#define alc262_capture_mixer alc882_capture_mixer
9447#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9448
9449/*
9450 * generic initialization of ADC, input mixers and output mixers
9451 */
9452static struct hda_verb alc262_init_verbs[] = {
9453 /*
9454 * Unmute ADC0-2 and set the default input to mic-in
9455 */
9456 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9458 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9460 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9462
Takashi Iwaicb53c622007-08-10 17:21:45 +02009463 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009464 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009465 * Note: PASD motherboards uses the Line In 2 as the input for
9466 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009467 */
9468 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009474
9475 /*
9476 * Set up output mixers (0x0c - 0x0e)
9477 */
9478 /* set vol=0 to output mixers */
9479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9482 /* set up input amps for analog loopback */
9483 /* Amp Indices: DAC = 0, mixer = 1 */
9484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9488 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9490
9491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9493 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9495 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9496 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9497
9498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009503
Kailang Yangdf694da2005-12-05 19:42:22 +01009504 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009506
Kailang Yangdf694da2005-12-05 19:42:22 +01009507 /* FIXME: use matrix-type input source selection */
9508 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9509 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9511 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9514 /* Input mixer2 */
9515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9519 /* Input mixer3 */
9520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009524
9525 { }
9526};
9527
Kailang Yang4e555fe2008-08-26 13:05:55 +02009528static struct hda_verb alc262_eapd_verbs[] = {
9529 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9530 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9531 { }
9532};
9533
Kailang Yangccc656c2006-10-17 12:32:26 +02009534static struct hda_verb alc262_hippo_unsol_verbs[] = {
9535 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9537 {}
9538};
9539
9540static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9542 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9543 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9544
9545 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9547 {}
9548};
9549
Kailang Yang272a5272007-05-14 11:00:38 +02009550static struct hda_verb alc262_sony_unsol_verbs[] = {
9551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9554
9555 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009557 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009558};
9559
Kailang Yang4e555fe2008-08-26 13:05:55 +02009560static struct hda_input_mux alc262_dmic_capture_source = {
9561 .num_items = 2,
9562 .items = {
9563 { "Int DMic", 0x9 },
9564 { "Mic", 0x0 },
9565 },
9566};
9567
9568static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9570 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009574 { } /* end */
9575};
9576
9577static struct hda_verb alc262_toshiba_s06_verbs[] = {
9578 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9582 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9583 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9584 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9585 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9586 {}
9587};
9588
9589static void alc262_dmic_automute(struct hda_codec *codec)
9590{
9591 unsigned int present;
9592
9593 present = snd_hda_codec_read(codec, 0x18, 0,
9594 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9595 snd_hda_codec_write(codec, 0x22, 0,
9596 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9597}
9598
9599/* toggle speaker-output according to the hp-jack state */
9600static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9601{
9602 unsigned int present;
9603 unsigned char bits;
9604
9605 present = snd_hda_codec_read(codec, 0x15, 0,
9606 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9607 bits = present ? 0 : PIN_OUT;
9608 snd_hda_codec_write(codec, 0x14, 0,
9609 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9610}
9611
9612
9613
9614/* unsolicited event for HP jack sensing */
9615static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9616 unsigned int res)
9617{
9618 if ((res >> 26) == ALC880_HP_EVENT)
9619 alc262_toshiba_s06_speaker_automute(codec);
9620 if ((res >> 26) == ALC880_MIC_EVENT)
9621 alc262_dmic_automute(codec);
9622
9623}
9624
9625static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9626{
9627 alc262_toshiba_s06_speaker_automute(codec);
9628 alc262_dmic_automute(codec);
9629}
9630
Kailang Yangccc656c2006-10-17 12:32:26 +02009631/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009632static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009633{
9634 struct alc_spec *spec = codec->spec;
9635 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009636 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009637
Takashi Iwai5b319542007-07-26 11:49:22 +02009638 /* need to execute and sync at first */
9639 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9640 present = snd_hda_codec_read(codec, 0x15, 0,
9641 AC_VERB_GET_PIN_SENSE, 0);
9642 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009643 if (spec->jack_present) {
9644 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009645 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9646 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009647 } else {
9648 /* unmute internal speaker if necessary */
9649 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009650 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9651 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009652 }
9653}
9654
9655/* unsolicited event for HP jack sensing */
9656static void alc262_hippo_unsol_event(struct hda_codec *codec,
9657 unsigned int res)
9658{
9659 if ((res >> 26) != ALC880_HP_EVENT)
9660 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009661 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009662}
9663
Takashi Iwai5b319542007-07-26 11:49:22 +02009664static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009665{
Kailang Yangccc656c2006-10-17 12:32:26 +02009666 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009667 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009668
Takashi Iwai5b319542007-07-26 11:49:22 +02009669 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9670 present = snd_hda_codec_read(codec, 0x1b, 0,
9671 AC_VERB_GET_PIN_SENSE, 0);
9672 present = (present & 0x80000000) != 0;
9673 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009674 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009675 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9676 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009677 } else {
9678 /* unmute internal speaker if necessary */
9679 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009680 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9681 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009682 }
9683}
9684
9685/* unsolicited event for HP jack sensing */
9686static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9687 unsigned int res)
9688{
9689 if ((res >> 26) != ALC880_HP_EVENT)
9690 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009691 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009692}
9693
Takashi Iwai834be882006-03-01 14:16:17 +01009694/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009695 * nec model
9696 * 0x15 = headphone
9697 * 0x16 = internal speaker
9698 * 0x18 = external mic
9699 */
9700
9701static struct snd_kcontrol_new alc262_nec_mixer[] = {
9702 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9703 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9704
9705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9708
9709 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9711 { } /* end */
9712};
9713
9714static struct hda_verb alc262_nec_verbs[] = {
9715 /* Unmute Speaker */
9716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9717
9718 /* Headphone */
9719 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9721
9722 /* External mic to headphone */
9723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9724 /* External mic to speaker */
9725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9726 {}
9727};
9728
9729/*
Takashi Iwai834be882006-03-01 14:16:17 +01009730 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009731 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9732 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009733 */
9734
9735#define ALC_HP_EVENT 0x37
9736
9737static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9738 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009740 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009742 {}
9743};
9744
Jiang zhe0e31daf2008-03-20 12:12:39 +01009745static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9746 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9747 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9748 {}
9749};
9750
Takashi Iwai834be882006-03-01 14:16:17 +01009751static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009752 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009753 .items = {
9754 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009755 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009756 { "CD", 0x4 },
9757 },
9758};
9759
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009760static struct hda_input_mux alc262_HP_capture_source = {
9761 .num_items = 5,
9762 .items = {
9763 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009764 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009765 { "Line", 0x2 },
9766 { "CD", 0x4 },
9767 { "AUX IN", 0x6 },
9768 },
9769};
9770
zhejiangaccbe492007-08-31 12:36:05 +02009771static struct hda_input_mux alc262_HP_D7000_capture_source = {
9772 .num_items = 4,
9773 .items = {
9774 { "Mic", 0x0 },
9775 { "Front Mic", 0x2 },
9776 { "Line", 0x1 },
9777 { "CD", 0x4 },
9778 },
9779};
9780
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009781/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009782static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9783{
9784 struct alc_spec *spec = codec->spec;
9785 unsigned int mute;
9786
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009787 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009788 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009789 /* need to execute and sync at first */
9790 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009791 /* check laptop HP jack */
9792 present = snd_hda_codec_read(codec, 0x14, 0,
9793 AC_VERB_GET_PIN_SENSE, 0);
9794 /* need to execute and sync at first */
9795 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9796 /* check docking HP jack */
9797 present |= snd_hda_codec_read(codec, 0x1b, 0,
9798 AC_VERB_GET_PIN_SENSE, 0);
9799 if (present & AC_PINSENSE_PRESENCE)
9800 spec->jack_present = 1;
9801 else
9802 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009803 spec->sense_updated = 1;
9804 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009805 /* unmute internal speaker only if both HPs are unplugged and
9806 * master switch is on
9807 */
9808 if (spec->jack_present)
9809 mute = HDA_AMP_MUTE;
9810 else
Takashi Iwai834be882006-03-01 14:16:17 +01009811 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009812 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9813 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009814}
9815
9816/* unsolicited event for HP jack sensing */
9817static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9818 unsigned int res)
9819{
9820 if ((res >> 26) != ALC_HP_EVENT)
9821 return;
9822 alc262_fujitsu_automute(codec, 1);
9823}
9824
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009825static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9826{
9827 alc262_fujitsu_automute(codec, 1);
9828}
9829
Takashi Iwai834be882006-03-01 14:16:17 +01009830/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009831static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9832 .ops = &snd_hda_bind_vol,
9833 .values = {
9834 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9835 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9836 0
9837 },
9838};
Takashi Iwai834be882006-03-01 14:16:17 +01009839
Jiang zhe0e31daf2008-03-20 12:12:39 +01009840/* mute/unmute internal speaker according to the hp jack and mute state */
9841static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9842{
9843 struct alc_spec *spec = codec->spec;
9844 unsigned int mute;
9845
9846 if (force || !spec->sense_updated) {
9847 unsigned int present_int_hp;
9848 /* need to execute and sync at first */
9849 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9850 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9851 AC_VERB_GET_PIN_SENSE, 0);
9852 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9853 spec->sense_updated = 1;
9854 }
9855 if (spec->jack_present) {
9856 /* mute internal speaker */
9857 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9858 HDA_AMP_MUTE, HDA_AMP_MUTE);
9859 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9860 HDA_AMP_MUTE, HDA_AMP_MUTE);
9861 } else {
9862 /* unmute internal speaker if necessary */
9863 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9864 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9865 HDA_AMP_MUTE, mute);
9866 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9867 HDA_AMP_MUTE, mute);
9868 }
9869}
9870
9871/* unsolicited event for HP jack sensing */
9872static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9873 unsigned int res)
9874{
9875 if ((res >> 26) != ALC_HP_EVENT)
9876 return;
9877 alc262_lenovo_3000_automute(codec, 1);
9878}
9879
Takashi Iwai834be882006-03-01 14:16:17 +01009880/* bind hp and internal speaker mute (with plug check) */
9881static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9882 struct snd_ctl_elem_value *ucontrol)
9883{
9884 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9885 long *valp = ucontrol->value.integer.value;
9886 int change;
9887
Tony Vroon5d9fab22008-03-14 17:09:18 +01009888 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9889 HDA_AMP_MUTE,
9890 valp ? 0 : HDA_AMP_MUTE);
9891 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9892 HDA_AMP_MUTE,
9893 valp ? 0 : HDA_AMP_MUTE);
9894
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009895 if (change)
9896 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009897 return change;
9898}
9899
9900static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009901 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009902 {
9903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9904 .name = "Master Playback Switch",
9905 .info = snd_hda_mixer_amp_switch_info,
9906 .get = snd_hda_mixer_amp_switch_get,
9907 .put = alc262_fujitsu_master_sw_put,
9908 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9909 },
9910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009912 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9913 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009914 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009917 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9918 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9919 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009920 { } /* end */
9921};
9922
Jiang zhe0e31daf2008-03-20 12:12:39 +01009923/* bind hp and internal speaker mute (with plug check) */
9924static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9925 struct snd_ctl_elem_value *ucontrol)
9926{
9927 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9928 long *valp = ucontrol->value.integer.value;
9929 int change;
9930
9931 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9932 HDA_AMP_MUTE,
9933 valp ? 0 : HDA_AMP_MUTE);
9934
9935 if (change)
9936 alc262_lenovo_3000_automute(codec, 0);
9937 return change;
9938}
9939
9940static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9941 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9942 {
9943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9944 .name = "Master Playback Switch",
9945 .info = snd_hda_mixer_amp_switch_info,
9946 .get = snd_hda_mixer_amp_switch_get,
9947 .put = alc262_lenovo_3000_master_sw_put,
9948 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9949 },
9950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9955 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9956 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9957 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9958 { } /* end */
9959};
9960
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009961static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9962 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9963 {
9964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9965 .name = "Master Playback Switch",
9966 .info = snd_hda_mixer_amp_switch_info,
9967 .get = snd_hda_mixer_amp_switch_get,
9968 .put = alc262_sony_master_sw_put,
9969 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9970 },
9971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9976 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9977 { } /* end */
9978};
9979
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009980/* additional init verbs for Benq laptops */
9981static struct hda_verb alc262_EAPD_verbs[] = {
9982 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9983 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9984 {}
9985};
9986
Kailang Yang83c34212007-07-05 11:43:05 +02009987static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9988 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9989 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9990
9991 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9992 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9993 {}
9994};
9995
Tobin Davisf651b502007-10-26 12:40:47 +02009996/* Samsung Q1 Ultra Vista model setup */
9997static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009998 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9999 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10002 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010003 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010004 { } /* end */
10005};
10006
10007static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010008 /* output mixer */
10009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10011 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10012 /* speaker */
10013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10016 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10017 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010018 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10023 /* internal mic */
10024 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10026 /* ADC, choose mic */
10027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10035 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10036 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010037 {}
10038};
10039
Tobin Davisf651b502007-10-26 12:40:47 +020010040/* mute/unmute internal speaker according to the hp jack and mute state */
10041static void alc262_ultra_automute(struct hda_codec *codec)
10042{
10043 struct alc_spec *spec = codec->spec;
10044 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010045
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010046 mute = 0;
10047 /* auto-mute only when HP is used as HP */
10048 if (!spec->cur_mux[0]) {
10049 unsigned int present;
10050 /* need to execute and sync at first */
10051 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10052 present = snd_hda_codec_read(codec, 0x15, 0,
10053 AC_VERB_GET_PIN_SENSE, 0);
10054 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10055 if (spec->jack_present)
10056 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010057 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010058 /* mute/unmute internal speaker */
10059 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10060 HDA_AMP_MUTE, mute);
10061 /* mute/unmute HP */
10062 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10063 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010064}
10065
10066/* unsolicited event for HP jack sensing */
10067static void alc262_ultra_unsol_event(struct hda_codec *codec,
10068 unsigned int res)
10069{
10070 if ((res >> 26) != ALC880_HP_EVENT)
10071 return;
10072 alc262_ultra_automute(codec);
10073}
10074
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010075static struct hda_input_mux alc262_ultra_capture_source = {
10076 .num_items = 2,
10077 .items = {
10078 { "Mic", 0x1 },
10079 { "Headphone", 0x7 },
10080 },
10081};
10082
10083static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10084 struct snd_ctl_elem_value *ucontrol)
10085{
10086 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10087 struct alc_spec *spec = codec->spec;
10088 int ret;
10089
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010090 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010091 if (!ret)
10092 return 0;
10093 /* reprogram the HP pin as mic or HP according to the input source */
10094 snd_hda_codec_write_cache(codec, 0x15, 0,
10095 AC_VERB_SET_PIN_WIDGET_CONTROL,
10096 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10097 alc262_ultra_automute(codec); /* mute/unmute HP */
10098 return ret;
10099}
10100
10101static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10102 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10103 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10104 {
10105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10106 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010107 .info = alc_mux_enum_info,
10108 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010109 .put = alc262_ultra_mux_enum_put,
10110 },
10111 { } /* end */
10112};
10113
Kailang Yangdf694da2005-12-05 19:42:22 +010010114/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010115static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10116 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010117{
10118 hda_nid_t nid;
10119 int err;
10120
10121 spec->multiout.num_dacs = 1; /* only use one dac */
10122 spec->multiout.dac_nids = spec->private_dac_nids;
10123 spec->multiout.dac_nids[0] = 2;
10124
10125 nid = cfg->line_out_pins[0];
10126 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010127 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10128 "Front Playback Volume",
10129 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10130 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010131 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010132 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10133 "Front Playback Switch",
10134 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10135 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010136 return err;
10137 }
10138
Takashi Iwai82bc9552006-03-21 11:24:42 +010010139 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010140 if (nid) {
10141 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010142 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10143 "Speaker Playback Volume",
10144 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10145 HDA_OUTPUT));
10146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010147 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010148 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10149 "Speaker Playback Switch",
10150 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10151 HDA_OUTPUT));
10152 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010153 return err;
10154 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010155 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10156 "Speaker Playback Switch",
10157 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10158 HDA_OUTPUT));
10159 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010160 return err;
10161 }
10162 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010163 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010164 if (nid) {
10165 /* spec->multiout.hp_nid = 2; */
10166 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010167 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10168 "Headphone Playback Volume",
10169 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10170 HDA_OUTPUT));
10171 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010172 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010173 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10174 "Headphone Playback Switch",
10175 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10176 HDA_OUTPUT));
10177 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010178 return err;
10179 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010180 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10181 "Headphone Playback Switch",
10182 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10183 HDA_OUTPUT));
10184 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010185 return err;
10186 }
10187 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010188 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010189}
10190
10191/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010192#define alc262_auto_create_analog_input_ctls \
10193 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010194
10195/*
10196 * generic initialization of ADC, input mixers and output mixers
10197 */
10198static struct hda_verb alc262_volume_init_verbs[] = {
10199 /*
10200 * Unmute ADC0-2 and set the default input to mic-in
10201 */
10202 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10204 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10206 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10208
Takashi Iwaicb53c622007-08-10 17:21:45 +020010209 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010210 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010211 * Note: PASD motherboards uses the Line In 2 as the input for
10212 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010213 */
10214 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010220
10221 /*
10222 * Set up output mixers (0x0c - 0x0f)
10223 */
10224 /* set vol=0 to output mixers */
10225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010228
Kailang Yangdf694da2005-12-05 19:42:22 +010010229 /* set up input amps for analog loopback */
10230 /* Amp Indices: DAC = 0, mixer = 1 */
10231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10237
10238 /* FIXME: use matrix-type input source selection */
10239 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10240 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10245 /* Input mixer2 */
10246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10250 /* Input mixer3 */
10251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10255
10256 { }
10257};
10258
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010259static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10260 /*
10261 * Unmute ADC0-2 and set the default input to mic-in
10262 */
10263 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10265 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10267 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10269
Takashi Iwaicb53c622007-08-10 17:21:45 +020010270 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010271 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010272 * Note: PASD motherboards uses the Line In 2 as the input for
10273 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010274 */
10275 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010283
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010284 /*
10285 * Set up output mixers (0x0c - 0x0e)
10286 */
10287 /* set vol=0 to output mixers */
10288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10290 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10291
10292 /* set up input amps for analog loopback */
10293 /* Amp Indices: DAC = 0, mixer = 1 */
10294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10300
Takashi Iwaice875f02008-01-28 18:17:43 +010010301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10304
10305 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10307
10308 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10310
10311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10315 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10316
10317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10319 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10321 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10322 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10323
10324
10325 /* FIXME: use matrix-type input source selection */
10326 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10327 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10332 /* Input mixer2 */
10333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10337 /* Input mixer3 */
10338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10342
Takashi Iwaice875f02008-01-28 18:17:43 +010010343 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10344
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010345 { }
10346};
10347
Kailang Yangcd7509a2007-01-26 18:33:17 +010010348static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10349 /*
10350 * Unmute ADC0-2 and set the default input to mic-in
10351 */
10352 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10354 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10356 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10358
Takashi Iwaicb53c622007-08-10 17:21:45 +020010359 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010360 * mixer widget
10361 * Note: PASD motherboards uses the Line In 2 as the input for front
10362 * panel mic (mic 2)
10363 */
10364 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010373 /*
10374 * Set up output mixers (0x0c - 0x0e)
10375 */
10376 /* set vol=0 to output mixers */
10377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10380
10381 /* set up input amps for analog loopback */
10382 /* Amp Indices: DAC = 0, mixer = 1 */
10383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10389
10390
10391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10393 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10395 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10397 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10398
10399 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10401
10402 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10403 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10404
10405 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10407 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10409 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10410 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10411
10412 /* FIXME: use matrix-type input source selection */
10413 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10414 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10420 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10422 /* Input mixer2 */
10423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10428 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10430 /* Input mixer3 */
10431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10436 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10438
Takashi Iwaice875f02008-01-28 18:17:43 +010010439 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10440
Kailang Yangcd7509a2007-01-26 18:33:17 +010010441 { }
10442};
10443
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010444static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10445
10446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10448 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10449
10450 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10451 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10453 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10454
10455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10456 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10457 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10458 {}
10459};
10460
10461
Takashi Iwaicb53c622007-08-10 17:21:45 +020010462#ifdef CONFIG_SND_HDA_POWER_SAVE
10463#define alc262_loopbacks alc880_loopbacks
10464#endif
10465
Kailang Yangdf694da2005-12-05 19:42:22 +010010466/* pcm configuration: identiacal with ALC880 */
10467#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10468#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10469#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10470#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10471
10472/*
10473 * BIOS auto configuration
10474 */
10475static int alc262_parse_auto_config(struct hda_codec *codec)
10476{
10477 struct alc_spec *spec = codec->spec;
10478 int err;
10479 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10480
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010481 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10482 alc262_ignore);
10483 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010484 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010485 if (!spec->autocfg.line_outs) {
10486 if (spec->autocfg.dig_out_pin || spec->autocfg.dig_in_pin) {
10487 spec->multiout.max_channels = 2;
10488 spec->no_analog = 1;
10489 goto dig_only;
10490 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010491 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010492 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010493 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10494 if (err < 0)
10495 return err;
10496 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10497 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010498 return err;
10499
10500 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10501
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010502 dig_only:
10503 if (spec->autocfg.dig_out_pin) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010504 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010505 spec->dig_out_type = spec->autocfg.dig_out_type;
10506 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010507 if (spec->autocfg.dig_in_pin)
10508 spec->dig_in_nid = ALC262_DIGIN_NID;
10509
Takashi Iwai603c4012008-07-30 15:01:44 +020010510 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010511 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010512
Takashi Iwaid88897e2008-10-31 15:01:37 +010010513 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010514 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010515 spec->input_mux = &spec->private_imux;
10516
Takashi Iwai776e1842007-08-29 15:07:11 +020010517 err = alc_auto_add_mic_boost(codec);
10518 if (err < 0)
10519 return err;
10520
Takashi Iwaie044c392008-10-27 16:56:24 +010010521 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010522 return 1;
10523}
10524
10525#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10526#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10527#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010528#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010529
10530
10531/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010532static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010533{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010534 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010535 alc262_auto_init_multi_out(codec);
10536 alc262_auto_init_hp_out(codec);
10537 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010538 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010539 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010540 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010541}
10542
10543/*
10544 * configuration and preset
10545 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010546static const char *alc262_models[ALC262_MODEL_LAST] = {
10547 [ALC262_BASIC] = "basic",
10548 [ALC262_HIPPO] = "hippo",
10549 [ALC262_HIPPO_1] = "hippo_1",
10550 [ALC262_FUJITSU] = "fujitsu",
10551 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010552 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010553 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010554 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010555 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010556 [ALC262_BENQ_T31] = "benq-t31",
10557 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010558 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010559 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010560 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010561 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010562 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010563 [ALC262_AUTO] = "auto",
10564};
10565
10566static struct snd_pci_quirk alc262_cfg_tbl[] = {
10567 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010568 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010569 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010570 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010571 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10572 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010573 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010574 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010575 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010576 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010577 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010578 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010579 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010580 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010581 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010582 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010583 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010584 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010585 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10586 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10587 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010588 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10589 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010590 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010591 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010592 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010593 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10594 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10595 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010596 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10597 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010598 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010599 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010600 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010601 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010602 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010603 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010604 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010605 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010606 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010607 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010608 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010609 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010610 {}
10611};
10612
10613static struct alc_config_preset alc262_presets[] = {
10614 [ALC262_BASIC] = {
10615 .mixers = { alc262_base_mixer },
10616 .init_verbs = { alc262_init_verbs },
10617 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10618 .dac_nids = alc262_dac_nids,
10619 .hp_nid = 0x03,
10620 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10621 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010622 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010623 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010624 [ALC262_HIPPO] = {
10625 .mixers = { alc262_base_mixer },
10626 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10627 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10628 .dac_nids = alc262_dac_nids,
10629 .hp_nid = 0x03,
10630 .dig_out_nid = ALC262_DIGOUT_NID,
10631 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10632 .channel_mode = alc262_modes,
10633 .input_mux = &alc262_capture_source,
10634 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010635 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010636 },
10637 [ALC262_HIPPO_1] = {
10638 .mixers = { alc262_hippo1_mixer },
10639 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10640 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10641 .dac_nids = alc262_dac_nids,
10642 .hp_nid = 0x02,
10643 .dig_out_nid = ALC262_DIGOUT_NID,
10644 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10645 .channel_mode = alc262_modes,
10646 .input_mux = &alc262_capture_source,
10647 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010648 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010649 },
Takashi Iwai834be882006-03-01 14:16:17 +010010650 [ALC262_FUJITSU] = {
10651 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010652 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10653 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010654 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10655 .dac_nids = alc262_dac_nids,
10656 .hp_nid = 0x03,
10657 .dig_out_nid = ALC262_DIGOUT_NID,
10658 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10659 .channel_mode = alc262_modes,
10660 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010661 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010662 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010663 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010664 [ALC262_HP_BPC] = {
10665 .mixers = { alc262_HP_BPC_mixer },
10666 .init_verbs = { alc262_HP_BPC_init_verbs },
10667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10668 .dac_nids = alc262_dac_nids,
10669 .hp_nid = 0x03,
10670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10671 .channel_mode = alc262_modes,
10672 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010673 .unsol_event = alc262_hp_bpc_unsol_event,
10674 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010675 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010676 [ALC262_HP_BPC_D7000_WF] = {
10677 .mixers = { alc262_HP_BPC_WildWest_mixer },
10678 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10679 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10680 .dac_nids = alc262_dac_nids,
10681 .hp_nid = 0x03,
10682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10683 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010684 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010685 .unsol_event = alc262_hp_wildwest_unsol_event,
10686 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010687 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010688 [ALC262_HP_BPC_D7000_WL] = {
10689 .mixers = { alc262_HP_BPC_WildWest_mixer,
10690 alc262_HP_BPC_WildWest_option_mixer },
10691 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10692 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10693 .dac_nids = alc262_dac_nids,
10694 .hp_nid = 0x03,
10695 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10696 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010697 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010698 .unsol_event = alc262_hp_wildwest_unsol_event,
10699 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010700 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010701 [ALC262_HP_TC_T5735] = {
10702 .mixers = { alc262_hp_t5735_mixer },
10703 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10705 .dac_nids = alc262_dac_nids,
10706 .hp_nid = 0x03,
10707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10708 .channel_mode = alc262_modes,
10709 .input_mux = &alc262_capture_source,
10710 .unsol_event = alc262_hp_t5735_unsol_event,
10711 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010712 },
10713 [ALC262_HP_RP5700] = {
10714 .mixers = { alc262_hp_rp5700_mixer },
10715 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10717 .dac_nids = alc262_dac_nids,
10718 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10719 .channel_mode = alc262_modes,
10720 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010721 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010722 [ALC262_BENQ_ED8] = {
10723 .mixers = { alc262_base_mixer },
10724 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10725 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10726 .dac_nids = alc262_dac_nids,
10727 .hp_nid = 0x03,
10728 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10729 .channel_mode = alc262_modes,
10730 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010731 },
Kailang Yang272a5272007-05-14 11:00:38 +020010732 [ALC262_SONY_ASSAMD] = {
10733 .mixers = { alc262_sony_mixer },
10734 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10735 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10736 .dac_nids = alc262_dac_nids,
10737 .hp_nid = 0x02,
10738 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10739 .channel_mode = alc262_modes,
10740 .input_mux = &alc262_capture_source,
10741 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010742 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010743 },
10744 [ALC262_BENQ_T31] = {
10745 .mixers = { alc262_benq_t31_mixer },
10746 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10747 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10748 .dac_nids = alc262_dac_nids,
10749 .hp_nid = 0x03,
10750 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10751 .channel_mode = alc262_modes,
10752 .input_mux = &alc262_capture_source,
10753 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010754 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010755 },
Tobin Davisf651b502007-10-26 12:40:47 +020010756 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010757 .mixers = { alc262_ultra_mixer },
10758 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010759 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010760 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10761 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010762 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10763 .channel_mode = alc262_modes,
10764 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010765 .adc_nids = alc262_adc_nids, /* ADC0 */
10766 .capsrc_nids = alc262_capsrc_nids,
10767 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010768 .unsol_event = alc262_ultra_unsol_event,
10769 .init_hook = alc262_ultra_automute,
10770 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010771 [ALC262_LENOVO_3000] = {
10772 .mixers = { alc262_lenovo_3000_mixer },
10773 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10774 alc262_lenovo_3000_unsol_verbs },
10775 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10776 .dac_nids = alc262_dac_nids,
10777 .hp_nid = 0x03,
10778 .dig_out_nid = ALC262_DIGOUT_NID,
10779 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10780 .channel_mode = alc262_modes,
10781 .input_mux = &alc262_fujitsu_capture_source,
10782 .unsol_event = alc262_lenovo_3000_unsol_event,
10783 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010784 [ALC262_NEC] = {
10785 .mixers = { alc262_nec_mixer },
10786 .init_verbs = { alc262_nec_verbs },
10787 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10788 .dac_nids = alc262_dac_nids,
10789 .hp_nid = 0x03,
10790 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10791 .channel_mode = alc262_modes,
10792 .input_mux = &alc262_capture_source,
10793 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010794 [ALC262_TOSHIBA_S06] = {
10795 .mixers = { alc262_toshiba_s06_mixer },
10796 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10797 alc262_eapd_verbs },
10798 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10799 .capsrc_nids = alc262_dmic_capsrc_nids,
10800 .dac_nids = alc262_dac_nids,
10801 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10802 .dig_out_nid = ALC262_DIGOUT_NID,
10803 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10804 .channel_mode = alc262_modes,
10805 .input_mux = &alc262_dmic_capture_source,
10806 .unsol_event = alc262_toshiba_s06_unsol_event,
10807 .init_hook = alc262_toshiba_s06_init_hook,
10808 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010809 [ALC262_TOSHIBA_RX1] = {
10810 .mixers = { alc262_toshiba_rx1_mixer },
10811 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10812 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10813 .dac_nids = alc262_dac_nids,
10814 .hp_nid = 0x03,
10815 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10816 .channel_mode = alc262_modes,
10817 .input_mux = &alc262_capture_source,
10818 .unsol_event = alc262_hippo_unsol_event,
10819 .init_hook = alc262_hippo_automute,
10820 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010821};
10822
10823static int patch_alc262(struct hda_codec *codec)
10824{
10825 struct alc_spec *spec;
10826 int board_config;
10827 int err;
10828
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010829 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010830 if (spec == NULL)
10831 return -ENOMEM;
10832
10833 codec->spec = spec;
10834#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010835 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10836 * under-run
10837 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010838 {
10839 int tmp;
10840 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10841 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10842 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10843 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10844 }
10845#endif
10846
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010847 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10848
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010849 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10850 alc262_models,
10851 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010852
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010853 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010854 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10855 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010856 board_config = ALC262_AUTO;
10857 }
10858
10859 if (board_config == ALC262_AUTO) {
10860 /* automatic parse from the BIOS config */
10861 err = alc262_parse_auto_config(codec);
10862 if (err < 0) {
10863 alc_free(codec);
10864 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010865 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010866 printk(KERN_INFO
10867 "hda_codec: Cannot set up configuration "
10868 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010869 board_config = ALC262_BASIC;
10870 }
10871 }
10872
10873 if (board_config != ALC262_AUTO)
10874 setup_preset(spec, &alc262_presets[board_config]);
10875
10876 spec->stream_name_analog = "ALC262 Analog";
10877 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10878 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010879
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 spec->stream_name_digital = "ALC262 Digital";
10881 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10882 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10883
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010884 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010885 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010886 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010887 unsigned int wcap = get_wcaps(codec, 0x07);
10888
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010889 /* get type */
10890 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010891 if (wcap != AC_WID_AUD_IN) {
10892 spec->adc_nids = alc262_adc_nids_alt;
10893 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010894 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010895 } else {
10896 spec->adc_nids = alc262_adc_nids;
10897 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010898 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010899 }
10900 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010901 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010902 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010903
Takashi Iwai2134ea42008-01-10 16:53:55 +010010904 spec->vmaster_nid = 0x0c;
10905
Kailang Yangdf694da2005-12-05 19:42:22 +010010906 codec->patch_ops = alc_patch_ops;
10907 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010908 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010909#ifdef CONFIG_SND_HDA_POWER_SAVE
10910 if (!spec->loopback.amplist)
10911 spec->loopback.amplist = alc262_loopbacks;
10912#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010010913 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020010914
Kailang Yangdf694da2005-12-05 19:42:22 +010010915 return 0;
10916}
10917
Kailang Yangdf694da2005-12-05 19:42:22 +010010918/*
Kailang Yanga361d842007-06-05 12:30:55 +020010919 * ALC268 channel source setting (2 channel)
10920 */
10921#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10922#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010923
Kailang Yanga361d842007-06-05 12:30:55 +020010924static hda_nid_t alc268_dac_nids[2] = {
10925 /* front, hp */
10926 0x02, 0x03
10927};
10928
10929static hda_nid_t alc268_adc_nids[2] = {
10930 /* ADC0-1 */
10931 0x08, 0x07
10932};
10933
10934static hda_nid_t alc268_adc_nids_alt[1] = {
10935 /* ADC0 */
10936 0x08
10937};
10938
Takashi Iwaie1406342008-02-11 18:32:32 +010010939static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10940
Kailang Yanga361d842007-06-05 12:30:55 +020010941static struct snd_kcontrol_new alc268_base_mixer[] = {
10942 /* output mixer control */
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10944 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10945 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10948 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10949 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010950 { }
10951};
10952
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010953/* bind Beep switches of both NID 0x0f and 0x10 */
10954static struct hda_bind_ctls alc268_bind_beep_sw = {
10955 .ops = &snd_hda_bind_sw,
10956 .values = {
10957 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10958 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10959 0
10960 },
10961};
10962
10963static struct snd_kcontrol_new alc268_beep_mixer[] = {
10964 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10965 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10966 { }
10967};
10968
Kailang Yangd1a991a2007-08-15 16:21:59 +020010969static struct hda_verb alc268_eapd_verbs[] = {
10970 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10971 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10972 { }
10973};
10974
Takashi Iwaid2738092007-08-16 14:59:45 +020010975/* Toshiba specific */
10976#define alc268_toshiba_automute alc262_hippo_automute
10977
10978static struct hda_verb alc268_toshiba_verbs[] = {
10979 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10980 { } /* end */
10981};
10982
Kailang Yang8ef355d2008-08-26 13:10:22 +020010983static struct hda_input_mux alc268_acer_lc_capture_source = {
10984 .num_items = 2,
10985 .items = {
10986 { "i-Mic", 0x6 },
10987 { "E-Mic", 0x0 },
10988 },
10989};
10990
Takashi Iwaid2738092007-08-16 14:59:45 +020010991/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010992/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010993static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10994 .ops = &snd_hda_bind_vol,
10995 .values = {
10996 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10997 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10998 0
10999 },
11000};
11001
Takashi Iwai889c4392007-08-23 18:56:52 +020011002/* mute/unmute internal speaker according to the hp jack and mute state */
11003static void alc268_acer_automute(struct hda_codec *codec, int force)
11004{
11005 struct alc_spec *spec = codec->spec;
11006 unsigned int mute;
11007
11008 if (force || !spec->sense_updated) {
11009 unsigned int present;
11010 present = snd_hda_codec_read(codec, 0x14, 0,
11011 AC_VERB_GET_PIN_SENSE, 0);
11012 spec->jack_present = (present & 0x80000000) != 0;
11013 spec->sense_updated = 1;
11014 }
11015 if (spec->jack_present)
11016 mute = HDA_AMP_MUTE; /* mute internal speaker */
11017 else /* unmute internal speaker if necessary */
11018 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11019 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11020 HDA_AMP_MUTE, mute);
11021}
11022
11023
11024/* bind hp and internal speaker mute (with plug check) */
11025static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11026 struct snd_ctl_elem_value *ucontrol)
11027{
11028 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11029 long *valp = ucontrol->value.integer.value;
11030 int change;
11031
11032 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11033 HDA_AMP_MUTE,
11034 valp[0] ? 0 : HDA_AMP_MUTE);
11035 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11036 HDA_AMP_MUTE,
11037 valp[1] ? 0 : HDA_AMP_MUTE);
11038 if (change)
11039 alc268_acer_automute(codec, 0);
11040 return change;
11041}
Takashi Iwaid2738092007-08-16 14:59:45 +020011042
Kailang Yang8ef355d2008-08-26 13:10:22 +020011043static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11044 /* output mixer control */
11045 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11046 {
11047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11048 .name = "Master Playback Switch",
11049 .info = snd_hda_mixer_amp_switch_info,
11050 .get = snd_hda_mixer_amp_switch_get,
11051 .put = alc268_acer_master_sw_put,
11052 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11053 },
11054 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11055 { }
11056};
11057
Takashi Iwaid2738092007-08-16 14:59:45 +020011058static struct snd_kcontrol_new alc268_acer_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 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11070 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11071 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011072 { }
11073};
11074
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011075static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11076 /* output mixer control */
11077 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11078 {
11079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11080 .name = "Master Playback Switch",
11081 .info = snd_hda_mixer_amp_switch_info,
11082 .get = snd_hda_mixer_amp_switch_get,
11083 .put = alc268_acer_master_sw_put,
11084 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11085 },
11086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11087 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11088 { }
11089};
11090
Kailang Yang8ef355d2008-08-26 13:10:22 +020011091static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11092 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11095 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11096 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11098 { }
11099};
11100
Takashi Iwaid2738092007-08-16 14:59:45 +020011101static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011102 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11103 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011108 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11109 { }
11110};
11111
11112/* unsolicited event for HP jack sensing */
11113static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11114 unsigned int res)
11115{
Takashi Iwai889c4392007-08-23 18:56:52 +020011116 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011117 return;
11118 alc268_toshiba_automute(codec);
11119}
11120
11121static void alc268_acer_unsol_event(struct hda_codec *codec,
11122 unsigned int res)
11123{
Takashi Iwai889c4392007-08-23 18:56:52 +020011124 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011125 return;
11126 alc268_acer_automute(codec, 1);
11127}
11128
Takashi Iwai889c4392007-08-23 18:56:52 +020011129static void alc268_acer_init_hook(struct hda_codec *codec)
11130{
11131 alc268_acer_automute(codec, 1);
11132}
11133
Kailang Yang8ef355d2008-08-26 13:10:22 +020011134/* toggle speaker-output according to the hp-jack state */
11135static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11136{
11137 unsigned int present;
11138 unsigned char bits;
11139
11140 present = snd_hda_codec_read(codec, 0x15, 0,
11141 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11142 bits = present ? AMP_IN_MUTE(0) : 0;
11143 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11144 AMP_IN_MUTE(0), bits);
11145 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11146 AMP_IN_MUTE(0), bits);
11147}
11148
11149
11150static void alc268_acer_mic_automute(struct hda_codec *codec)
11151{
11152 unsigned int present;
11153
11154 present = snd_hda_codec_read(codec, 0x18, 0,
11155 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11156 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11157 present ? 0x0 : 0x6);
11158}
11159
11160static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11161 unsigned int res)
11162{
11163 if ((res >> 26) == ALC880_HP_EVENT)
11164 alc268_aspire_one_speaker_automute(codec);
11165 if ((res >> 26) == ALC880_MIC_EVENT)
11166 alc268_acer_mic_automute(codec);
11167}
11168
11169static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11170{
11171 alc268_aspire_one_speaker_automute(codec);
11172 alc268_acer_mic_automute(codec);
11173}
11174
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011175static struct snd_kcontrol_new alc268_dell_mixer[] = {
11176 /* output mixer control */
11177 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11178 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11179 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11180 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11182 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11183 { }
11184};
11185
11186static struct hda_verb alc268_dell_verbs[] = {
11187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11189 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11190 { }
11191};
11192
11193/* mute/unmute internal speaker according to the hp jack and mute state */
11194static void alc268_dell_automute(struct hda_codec *codec)
11195{
11196 unsigned int present;
11197 unsigned int mute;
11198
11199 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11200 if (present & 0x80000000)
11201 mute = HDA_AMP_MUTE;
11202 else
11203 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11205 HDA_AMP_MUTE, mute);
11206}
11207
11208static void alc268_dell_unsol_event(struct hda_codec *codec,
11209 unsigned int res)
11210{
11211 if ((res >> 26) != ALC880_HP_EVENT)
11212 return;
11213 alc268_dell_automute(codec);
11214}
11215
11216#define alc268_dell_init_hook alc268_dell_automute
11217
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011218static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11219 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11220 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11221 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11223 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11224 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11225 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11226 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11227 { }
11228};
11229
11230static struct hda_verb alc267_quanta_il1_verbs[] = {
11231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11232 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11233 { }
11234};
11235
11236static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11237{
11238 unsigned int present;
11239
11240 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11241 & AC_PINSENSE_PRESENCE;
11242 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11243 present ? 0 : PIN_OUT);
11244}
11245
11246static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11247{
11248 unsigned int present;
11249
11250 present = snd_hda_codec_read(codec, 0x18, 0,
11251 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11252 snd_hda_codec_write(codec, 0x23, 0,
11253 AC_VERB_SET_CONNECT_SEL,
11254 present ? 0x00 : 0x01);
11255}
11256
11257static void alc267_quanta_il1_automute(struct hda_codec *codec)
11258{
11259 alc267_quanta_il1_hp_automute(codec);
11260 alc267_quanta_il1_mic_automute(codec);
11261}
11262
11263static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11264 unsigned int res)
11265{
11266 switch (res >> 26) {
11267 case ALC880_HP_EVENT:
11268 alc267_quanta_il1_hp_automute(codec);
11269 break;
11270 case ALC880_MIC_EVENT:
11271 alc267_quanta_il1_mic_automute(codec);
11272 break;
11273 }
11274}
11275
Kailang Yanga361d842007-06-05 12:30:55 +020011276/*
11277 * generic initialization of ADC, input mixers and output mixers
11278 */
11279static struct hda_verb alc268_base_init_verbs[] = {
11280 /* Unmute DAC0-1 and set vol = 0 */
11281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11282 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11283 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11284 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11285 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11286 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11287
11288 /*
11289 * Set up output mixers (0x0c - 0x0e)
11290 */
11291 /* set vol=0 to output mixers */
11292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11295 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11296
11297 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11298 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11299
11300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11302 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11303 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11307 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11308
11309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11313 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11315 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011316
11317 /* set PCBEEP vol = 0, mute connections */
11318 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11320 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011321
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011322 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011323
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011324 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11326 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011328
Kailang Yanga361d842007-06-05 12:30:55 +020011329 { }
11330};
11331
11332/*
11333 * generic initialization of ADC, input mixers and output mixers
11334 */
11335static struct hda_verb alc268_volume_init_verbs[] = {
11336 /* set output DAC */
11337 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11338 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11339 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11340 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11341
11342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11343 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11344 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11345 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11346 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11347
11348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11353
11354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11357 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11358
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011359 /* set PCBEEP vol = 0, mute connections */
11360 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11361 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11362 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011363
11364 { }
11365};
11366
Kailang Yanga361d842007-06-05 12:30:55 +020011367static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11368 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11369 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11370 {
11371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11372 /* The multiple "Capture Source" controls confuse alsamixer
11373 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011374 */
11375 /* .name = "Capture Source", */
11376 .name = "Input Source",
11377 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011378 .info = alc_mux_enum_info,
11379 .get = alc_mux_enum_get,
11380 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011381 },
11382 { } /* end */
11383};
11384
11385static struct snd_kcontrol_new alc268_capture_mixer[] = {
11386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11390 {
11391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11392 /* The multiple "Capture Source" controls confuse alsamixer
11393 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011394 */
11395 /* .name = "Capture Source", */
11396 .name = "Input Source",
11397 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011398 .info = alc_mux_enum_info,
11399 .get = alc_mux_enum_get,
11400 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011401 },
11402 { } /* end */
11403};
11404
11405static struct hda_input_mux alc268_capture_source = {
11406 .num_items = 4,
11407 .items = {
11408 { "Mic", 0x0 },
11409 { "Front Mic", 0x1 },
11410 { "Line", 0x2 },
11411 { "CD", 0x3 },
11412 },
11413};
11414
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011415static struct hda_input_mux alc268_acer_capture_source = {
11416 .num_items = 3,
11417 .items = {
11418 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011419 { "Internal Mic", 0x1 },
11420 { "Line", 0x2 },
11421 },
11422};
11423
11424static struct hda_input_mux alc268_acer_dmic_capture_source = {
11425 .num_items = 3,
11426 .items = {
11427 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011428 { "Internal Mic", 0x6 },
11429 { "Line", 0x2 },
11430 },
11431};
11432
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011433#ifdef CONFIG_SND_DEBUG
11434static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011435 /* Volume widgets */
11436 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11437 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11438 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11439 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11440 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11441 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11442 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11443 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11444 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11445 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11446 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11447 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11448 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011449 /* The below appears problematic on some hardwares */
11450 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011451 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11452 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11453 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11454 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11455
11456 /* Modes for retasking pin widgets */
11457 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11458 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11459 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11460 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11461
11462 /* Controls for GPIO pins, assuming they are configured as outputs */
11463 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11464 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11465 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11466 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11467
11468 /* Switches to allow the digital SPDIF output pin to be enabled.
11469 * The ALC268 does not have an SPDIF input.
11470 */
11471 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11472
11473 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11474 * this output to turn on an external amplifier.
11475 */
11476 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11477 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11478
11479 { } /* end */
11480};
11481#endif
11482
Kailang Yanga361d842007-06-05 12:30:55 +020011483/* create input playback/capture controls for the given pin */
11484static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11485 const char *ctlname, int idx)
11486{
11487 char name[32];
11488 int err;
11489
11490 sprintf(name, "%s Playback Volume", ctlname);
11491 if (nid == 0x14) {
11492 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11493 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11494 HDA_OUTPUT));
11495 if (err < 0)
11496 return err;
11497 } else if (nid == 0x15) {
11498 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11499 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11500 HDA_OUTPUT));
11501 if (err < 0)
11502 return err;
11503 } else
11504 return -1;
11505 sprintf(name, "%s Playback Switch", ctlname);
11506 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11507 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11508 if (err < 0)
11509 return err;
11510 return 0;
11511}
11512
11513/* add playback controls from the parsed DAC table */
11514static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11515 const struct auto_pin_cfg *cfg)
11516{
11517 hda_nid_t nid;
11518 int err;
11519
11520 spec->multiout.num_dacs = 2; /* only use one dac */
11521 spec->multiout.dac_nids = spec->private_dac_nids;
11522 spec->multiout.dac_nids[0] = 2;
11523 spec->multiout.dac_nids[1] = 3;
11524
11525 nid = cfg->line_out_pins[0];
11526 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011527 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011528
11529 nid = cfg->speaker_pins[0];
11530 if (nid == 0x1d) {
11531 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11532 "Speaker Playback Volume",
11533 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11534 if (err < 0)
11535 return err;
11536 }
11537 nid = cfg->hp_pins[0];
11538 if (nid)
11539 alc268_new_analog_output(spec, nid, "Headphone", 0);
11540
11541 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11542 if (nid == 0x16) {
11543 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11544 "Mono Playback Switch",
11545 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11546 if (err < 0)
11547 return err;
11548 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011549 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011550}
11551
11552/* create playback/capture controls for input pins */
11553static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11554 const struct auto_pin_cfg *cfg)
11555{
11556 struct hda_input_mux *imux = &spec->private_imux;
11557 int i, idx1;
11558
11559 for (i = 0; i < AUTO_PIN_LAST; i++) {
11560 switch(cfg->input_pins[i]) {
11561 case 0x18:
11562 idx1 = 0; /* Mic 1 */
11563 break;
11564 case 0x19:
11565 idx1 = 1; /* Mic 2 */
11566 break;
11567 case 0x1a:
11568 idx1 = 2; /* Line In */
11569 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011570 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011571 idx1 = 3; /* CD */
11572 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011573 case 0x12:
11574 case 0x13:
11575 idx1 = 6; /* digital mics */
11576 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011577 default:
11578 continue;
11579 }
11580 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11581 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011582 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011583 }
11584 return 0;
11585}
11586
11587static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11588{
11589 struct alc_spec *spec = codec->spec;
11590 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11591 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11592 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11593 unsigned int dac_vol1, dac_vol2;
11594
11595 if (speaker_nid) {
11596 snd_hda_codec_write(codec, speaker_nid, 0,
11597 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11598 snd_hda_codec_write(codec, 0x0f, 0,
11599 AC_VERB_SET_AMP_GAIN_MUTE,
11600 AMP_IN_UNMUTE(1));
11601 snd_hda_codec_write(codec, 0x10, 0,
11602 AC_VERB_SET_AMP_GAIN_MUTE,
11603 AMP_IN_UNMUTE(1));
11604 } else {
11605 snd_hda_codec_write(codec, 0x0f, 0,
11606 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11607 snd_hda_codec_write(codec, 0x10, 0,
11608 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11609 }
11610
11611 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011612 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011613 dac_vol2 = AMP_OUT_ZERO;
11614 else if (line_nid == 0x15)
11615 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011616 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011617 dac_vol2 = AMP_OUT_ZERO;
11618 else if (hp_nid == 0x15)
11619 dac_vol1 = AMP_OUT_ZERO;
11620 if (line_nid != 0x16 || hp_nid != 0x16 ||
11621 spec->autocfg.line_out_pins[1] != 0x16 ||
11622 spec->autocfg.line_out_pins[2] != 0x16)
11623 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11624
11625 snd_hda_codec_write(codec, 0x02, 0,
11626 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11627 snd_hda_codec_write(codec, 0x03, 0,
11628 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11629}
11630
11631/* pcm configuration: identiacal with ALC880 */
11632#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11633#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011634#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011635#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11636
11637/*
11638 * BIOS auto configuration
11639 */
11640static int alc268_parse_auto_config(struct hda_codec *codec)
11641{
11642 struct alc_spec *spec = codec->spec;
11643 int err;
11644 static hda_nid_t alc268_ignore[] = { 0 };
11645
11646 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11647 alc268_ignore);
11648 if (err < 0)
11649 return err;
11650 if (!spec->autocfg.line_outs)
11651 return 0; /* can't find valid BIOS pin config */
11652
11653 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11654 if (err < 0)
11655 return err;
11656 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11657 if (err < 0)
11658 return err;
11659
11660 spec->multiout.max_channels = 2;
11661
11662 /* digital only support output */
11663 if (spec->autocfg.dig_out_pin)
11664 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11665
Takashi Iwai603c4012008-07-30 15:01:44 +020011666 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011667 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011668
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011669 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011670 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011671
Takashi Iwaid88897e2008-10-31 15:01:37 +010011672 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011673 spec->num_mux_defs = 1;
11674 spec->input_mux = &spec->private_imux;
11675
Takashi Iwai776e1842007-08-29 15:07:11 +020011676 err = alc_auto_add_mic_boost(codec);
11677 if (err < 0)
11678 return err;
11679
Takashi Iwaie044c392008-10-27 16:56:24 +010011680 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011681 return 1;
11682}
11683
11684#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11685#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11686#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11687
11688/* init callback for auto-configuration model -- overriding the default init */
11689static void alc268_auto_init(struct hda_codec *codec)
11690{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011691 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011692 alc268_auto_init_multi_out(codec);
11693 alc268_auto_init_hp_out(codec);
11694 alc268_auto_init_mono_speaker_out(codec);
11695 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011696 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011697 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011698}
11699
11700/*
11701 * configuration and preset
11702 */
11703static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011704 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011705 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011706 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011707 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011708 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011709 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011710 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011711 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011712#ifdef CONFIG_SND_DEBUG
11713 [ALC268_TEST] = "test",
11714#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011715 [ALC268_AUTO] = "auto",
11716};
11717
11718static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011719 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011720 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011721 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011722 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011723 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011724 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11725 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011726 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011727 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011728 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011729 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011730 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011731 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011732 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011733 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011734 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011735 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011736 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011737 {}
11738};
11739
11740static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011741 [ALC267_QUANTA_IL1] = {
11742 .mixers = { alc267_quanta_il1_mixer },
11743 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11744 alc267_quanta_il1_verbs },
11745 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11746 .dac_nids = alc268_dac_nids,
11747 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11748 .adc_nids = alc268_adc_nids_alt,
11749 .hp_nid = 0x03,
11750 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11751 .channel_mode = alc268_modes,
11752 .input_mux = &alc268_capture_source,
11753 .unsol_event = alc267_quanta_il1_unsol_event,
11754 .init_hook = alc267_quanta_il1_automute,
11755 },
Kailang Yanga361d842007-06-05 12:30:55 +020011756 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011757 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11758 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011759 .init_verbs = { alc268_base_init_verbs },
11760 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11761 .dac_nids = alc268_dac_nids,
11762 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11763 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011764 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011765 .hp_nid = 0x03,
11766 .dig_out_nid = ALC268_DIGOUT_NID,
11767 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11768 .channel_mode = alc268_modes,
11769 .input_mux = &alc268_capture_source,
11770 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011771 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011772 .mixers = { alc268_base_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_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011776 .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,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011781 .hp_nid = 0x03,
11782 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11783 .channel_mode = alc268_modes,
11784 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011785 .unsol_event = alc268_toshiba_unsol_event,
11786 .init_hook = alc268_toshiba_automute,
11787 },
11788 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011789 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11790 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011791 .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,
Takashi Iwaie1406342008-02-11 18:32:32 +010011797 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011798 .hp_nid = 0x02,
11799 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11800 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011801 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011802 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011803 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011804 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011805 [ALC268_ACER_DMIC] = {
11806 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11807 alc268_beep_mixer },
11808 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11809 alc268_acer_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 = 0x02,
11816 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11817 .channel_mode = alc268_modes,
11818 .input_mux = &alc268_acer_dmic_capture_source,
11819 .unsol_event = alc268_acer_unsol_event,
11820 .init_hook = alc268_acer_init_hook,
11821 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011822 [ALC268_ACER_ASPIRE_ONE] = {
11823 .mixers = { alc268_acer_aspire_one_mixer,
11824 alc268_capture_alt_mixer },
11825 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11826 alc268_acer_aspire_one_verbs },
11827 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11828 .dac_nids = alc268_dac_nids,
11829 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11830 .adc_nids = alc268_adc_nids_alt,
11831 .capsrc_nids = alc268_capsrc_nids,
11832 .hp_nid = 0x03,
11833 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11834 .channel_mode = alc268_modes,
11835 .input_mux = &alc268_acer_lc_capture_source,
11836 .unsol_event = alc268_acer_lc_unsol_event,
11837 .init_hook = alc268_acer_lc_init_hook,
11838 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011839 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011840 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011841 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11842 alc268_dell_verbs },
11843 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11844 .dac_nids = alc268_dac_nids,
11845 .hp_nid = 0x02,
11846 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11847 .channel_mode = alc268_modes,
11848 .unsol_event = alc268_dell_unsol_event,
11849 .init_hook = alc268_dell_init_hook,
11850 .input_mux = &alc268_capture_source,
11851 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011852 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011853 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11854 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011855 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11856 alc268_toshiba_verbs },
11857 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11858 .dac_nids = alc268_dac_nids,
11859 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11860 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011861 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011862 .hp_nid = 0x03,
11863 .dig_out_nid = ALC268_DIGOUT_NID,
11864 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11865 .channel_mode = alc268_modes,
11866 .input_mux = &alc268_capture_source,
11867 .unsol_event = alc268_toshiba_unsol_event,
11868 .init_hook = alc268_toshiba_automute
11869 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011870#ifdef CONFIG_SND_DEBUG
11871 [ALC268_TEST] = {
11872 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11873 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11874 alc268_volume_init_verbs },
11875 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11876 .dac_nids = alc268_dac_nids,
11877 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11878 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011879 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011880 .hp_nid = 0x03,
11881 .dig_out_nid = ALC268_DIGOUT_NID,
11882 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11883 .channel_mode = alc268_modes,
11884 .input_mux = &alc268_capture_source,
11885 },
11886#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011887};
11888
11889static int patch_alc268(struct hda_codec *codec)
11890{
11891 struct alc_spec *spec;
11892 int board_config;
11893 int err;
11894
11895 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11896 if (spec == NULL)
11897 return -ENOMEM;
11898
11899 codec->spec = spec;
11900
11901 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11902 alc268_models,
11903 alc268_cfg_tbl);
11904
11905 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11906 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11907 "trying auto-probe from BIOS...\n");
11908 board_config = ALC268_AUTO;
11909 }
11910
11911 if (board_config == ALC268_AUTO) {
11912 /* automatic parse from the BIOS config */
11913 err = alc268_parse_auto_config(codec);
11914 if (err < 0) {
11915 alc_free(codec);
11916 return err;
11917 } else if (!err) {
11918 printk(KERN_INFO
11919 "hda_codec: Cannot set up configuration "
11920 "from BIOS. Using base mode...\n");
11921 board_config = ALC268_3ST;
11922 }
11923 }
11924
11925 if (board_config != ALC268_AUTO)
11926 setup_preset(spec, &alc268_presets[board_config]);
11927
Kailang Yang2f893282008-05-27 12:14:47 +020011928 if (codec->vendor_id == 0x10ec0267) {
11929 spec->stream_name_analog = "ALC267 Analog";
11930 spec->stream_name_digital = "ALC267 Digital";
11931 } else {
11932 spec->stream_name_analog = "ALC268 Analog";
11933 spec->stream_name_digital = "ALC268 Digital";
11934 }
11935
Kailang Yanga361d842007-06-05 12:30:55 +020011936 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11937 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011938 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011939
Kailang Yanga361d842007-06-05 12:30:55 +020011940 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11941
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011942 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11943 /* override the amp caps for beep generator */
11944 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11945 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11946 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11947 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11948 (0 << AC_AMPCAP_MUTE_SHIFT));
11949
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011950 if (!spec->adc_nids && spec->input_mux) {
11951 /* check whether NID 0x07 is valid */
11952 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011953 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011954
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011955 /* get type */
11956 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011957 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011958 spec->adc_nids = alc268_adc_nids_alt;
11959 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011960 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011961 } else {
11962 spec->adc_nids = alc268_adc_nids;
11963 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011964 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011965 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011966 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011967 /* set default input source */
11968 for (i = 0; i < spec->num_adc_nids; i++)
11969 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11970 0, AC_VERB_SET_CONNECT_SEL,
11971 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011972 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011973
11974 spec->vmaster_nid = 0x02;
11975
Kailang Yanga361d842007-06-05 12:30:55 +020011976 codec->patch_ops = alc_patch_ops;
11977 if (board_config == ALC268_AUTO)
11978 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011979
Takashi Iwaidaead532008-11-28 12:55:36 +010011980 codec->proc_widget_hook = print_realtek_coef;
11981
Kailang Yanga361d842007-06-05 12:30:55 +020011982 return 0;
11983}
11984
11985/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011986 * ALC269 channel source setting (2 channel)
11987 */
11988#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11989
11990#define alc269_dac_nids alc260_dac_nids
11991
11992static hda_nid_t alc269_adc_nids[1] = {
11993 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011994 0x08,
11995};
11996
Takashi Iwaie01bf502008-08-21 16:25:07 +020011997static hda_nid_t alc269_capsrc_nids[1] = {
11998 0x23,
11999};
12000
12001/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12002 * not a mux!
12003 */
12004
Kailang Yangf53281e2008-07-18 12:36:43 +020012005static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12006 .num_items = 2,
12007 .items = {
12008 { "i-Mic", 0x5 },
12009 { "e-Mic", 0x0 },
12010 },
12011};
12012
12013static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12014 .num_items = 2,
12015 .items = {
12016 { "i-Mic", 0x1 },
12017 { "e-Mic", 0x0 },
12018 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012019};
12020
12021#define alc269_modes alc260_modes
12022#define alc269_capture_source alc880_lg_lw_capture_source
12023
12024static struct snd_kcontrol_new alc269_base_mixer[] = {
12025 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12026 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020012031 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12032 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010012033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12034 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12035 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12036 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12037 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12038 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12039 { } /* end */
12040};
12041
Kailang Yang60db6b52008-08-26 13:13:00 +020012042static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12043 /* output mixer control */
12044 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12045 {
12046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12047 .name = "Master Playback Switch",
12048 .info = snd_hda_mixer_amp_switch_info,
12049 .get = snd_hda_mixer_amp_switch_get,
12050 .put = alc268_acer_master_sw_put,
12051 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12052 },
12053 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12055 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12056 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12057 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12058 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12059 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12060 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12061 { }
12062};
12063
Tony Vroon64154832008-11-06 15:08:49 +000012064static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12065 /* output mixer control */
12066 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12067 {
12068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12069 .name = "Master Playback Switch",
12070 .info = snd_hda_mixer_amp_switch_info,
12071 .get = snd_hda_mixer_amp_switch_get,
12072 .put = alc268_acer_master_sw_put,
12073 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12074 },
12075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12078 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12079 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12080 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12081 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12082 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12083 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12084 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12085 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12086 { }
12087};
12088
Kailang Yangf53281e2008-07-18 12:36:43 +020012089/* bind volumes of both NID 0x0c and 0x0d */
12090static struct hda_bind_ctls alc269_epc_bind_vol = {
12091 .ops = &snd_hda_bind_vol,
12092 .values = {
12093 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12094 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12095 0
12096 },
12097};
12098
12099static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12100 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12101 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12102 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12103 { } /* end */
12104};
12105
Kailang Yangf6a92242007-12-13 16:52:54 +010012106/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012107static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12108 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12109 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12111 { } /* end */
12112};
12113
12114/* FSC amilo */
12115static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12116 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12118 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012119 { } /* end */
12120};
12121
Takashi Iwai2005af22008-08-20 18:38:26 +020012122/* beep control */
12123static struct snd_kcontrol_new alc269_beep_mixer[] = {
12124 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12125 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12126 { } /* end */
12127};
12128
Kailang Yang60db6b52008-08-26 13:13:00 +020012129static struct hda_verb alc269_quanta_fl1_verbs[] = {
12130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12131 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12133 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12134 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12135 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12136 { }
12137};
12138
Tony Vroon64154832008-11-06 15:08:49 +000012139static struct hda_verb alc269_lifebook_verbs[] = {
12140 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12141 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12142 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12143 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12144 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12145 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12147 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12148 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12149 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12150 { }
12151};
12152
Kailang Yang60db6b52008-08-26 13:13:00 +020012153/* toggle speaker-output according to the hp-jack state */
12154static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12155{
12156 unsigned int present;
12157 unsigned char bits;
12158
12159 present = snd_hda_codec_read(codec, 0x15, 0,
12160 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12161 bits = present ? AMP_IN_MUTE(0) : 0;
12162 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12163 AMP_IN_MUTE(0), bits);
12164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12165 AMP_IN_MUTE(0), bits);
12166
12167 snd_hda_codec_write(codec, 0x20, 0,
12168 AC_VERB_SET_COEF_INDEX, 0x0c);
12169 snd_hda_codec_write(codec, 0x20, 0,
12170 AC_VERB_SET_PROC_COEF, 0x680);
12171
12172 snd_hda_codec_write(codec, 0x20, 0,
12173 AC_VERB_SET_COEF_INDEX, 0x0c);
12174 snd_hda_codec_write(codec, 0x20, 0,
12175 AC_VERB_SET_PROC_COEF, 0x480);
12176}
12177
Tony Vroon64154832008-11-06 15:08:49 +000012178/* toggle speaker-output according to the hp-jacks state */
12179static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12180{
12181 unsigned int present;
12182 unsigned char bits;
12183
12184 /* Check laptop headphone socket */
12185 present = snd_hda_codec_read(codec, 0x15, 0,
12186 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12187
12188 /* Check port replicator headphone socket */
12189 present |= snd_hda_codec_read(codec, 0x1a, 0,
12190 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12191
12192 bits = present ? AMP_IN_MUTE(0) : 0;
12193 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12194 AMP_IN_MUTE(0), bits);
12195 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12196 AMP_IN_MUTE(0), bits);
12197
12198 snd_hda_codec_write(codec, 0x20, 0,
12199 AC_VERB_SET_COEF_INDEX, 0x0c);
12200 snd_hda_codec_write(codec, 0x20, 0,
12201 AC_VERB_SET_PROC_COEF, 0x680);
12202
12203 snd_hda_codec_write(codec, 0x20, 0,
12204 AC_VERB_SET_COEF_INDEX, 0x0c);
12205 snd_hda_codec_write(codec, 0x20, 0,
12206 AC_VERB_SET_PROC_COEF, 0x480);
12207}
12208
Kailang Yang60db6b52008-08-26 13:13:00 +020012209static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12210{
12211 unsigned int present;
12212
12213 present = snd_hda_codec_read(codec, 0x18, 0,
12214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12215 snd_hda_codec_write(codec, 0x23, 0,
12216 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12217}
12218
Tony Vroon64154832008-11-06 15:08:49 +000012219static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12220{
12221 unsigned int present_laptop;
12222 unsigned int present_dock;
12223
12224 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12225 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12226
12227 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12229
12230 /* Laptop mic port overrides dock mic port, design decision */
12231 if (present_dock)
12232 snd_hda_codec_write(codec, 0x23, 0,
12233 AC_VERB_SET_CONNECT_SEL, 0x3);
12234 if (present_laptop)
12235 snd_hda_codec_write(codec, 0x23, 0,
12236 AC_VERB_SET_CONNECT_SEL, 0x0);
12237 if (!present_dock && !present_laptop)
12238 snd_hda_codec_write(codec, 0x23, 0,
12239 AC_VERB_SET_CONNECT_SEL, 0x1);
12240}
12241
Kailang Yang60db6b52008-08-26 13:13:00 +020012242static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12243 unsigned int res)
12244{
12245 if ((res >> 26) == ALC880_HP_EVENT)
12246 alc269_quanta_fl1_speaker_automute(codec);
12247 if ((res >> 26) == ALC880_MIC_EVENT)
12248 alc269_quanta_fl1_mic_automute(codec);
12249}
12250
Tony Vroon64154832008-11-06 15:08:49 +000012251static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12252 unsigned int res)
12253{
12254 if ((res >> 26) == ALC880_HP_EVENT)
12255 alc269_lifebook_speaker_automute(codec);
12256 if ((res >> 26) == ALC880_MIC_EVENT)
12257 alc269_lifebook_mic_autoswitch(codec);
12258}
12259
Kailang Yang60db6b52008-08-26 13:13:00 +020012260static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12261{
12262 alc269_quanta_fl1_speaker_automute(codec);
12263 alc269_quanta_fl1_mic_automute(codec);
12264}
12265
Tony Vroon64154832008-11-06 15:08:49 +000012266static void alc269_lifebook_init_hook(struct hda_codec *codec)
12267{
12268 alc269_lifebook_speaker_automute(codec);
12269 alc269_lifebook_mic_autoswitch(codec);
12270}
12271
Kailang Yang60db6b52008-08-26 13:13:00 +020012272static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12274 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12275 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12277 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12278 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12280 {}
12281};
12282
12283static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12285 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12286 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12288 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12290 {}
12291};
12292
12293/* toggle speaker-output according to the hp-jack state */
12294static void alc269_speaker_automute(struct hda_codec *codec)
12295{
12296 unsigned int present;
12297 unsigned char bits;
12298
12299 present = snd_hda_codec_read(codec, 0x15, 0,
12300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12301 bits = present ? AMP_IN_MUTE(0) : 0;
12302 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12303 AMP_IN_MUTE(0), bits);
12304 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12305 AMP_IN_MUTE(0), bits);
12306}
12307
12308static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12309{
12310 unsigned int present;
12311
12312 present = snd_hda_codec_read(codec, 0x18, 0,
12313 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12314 snd_hda_codec_write(codec, 0x23, 0,
12315 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12316}
12317
12318static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12319{
12320 unsigned int present;
12321
12322 present = snd_hda_codec_read(codec, 0x18, 0,
12323 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12324 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12325 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12326 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12327 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12328}
12329
12330/* unsolicited event for HP jack sensing */
12331static void alc269_eeepc_dmic_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_dmic_automute(codec);
12339}
12340
12341static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12342{
12343 alc269_speaker_automute(codec);
12344 alc269_eeepc_dmic_automute(codec);
12345}
12346
12347/* unsolicited event for HP jack sensing */
12348static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12349 unsigned int res)
12350{
12351 if ((res >> 26) == ALC880_HP_EVENT)
12352 alc269_speaker_automute(codec);
12353
12354 if ((res >> 26) == ALC880_MIC_EVENT)
12355 alc269_eeepc_amic_automute(codec);
12356}
12357
12358static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12359{
12360 alc269_speaker_automute(codec);
12361 alc269_eeepc_amic_automute(codec);
12362}
12363
Kailang Yangf6a92242007-12-13 16:52:54 +010012364/*
12365 * generic initialization of ADC, input mixers and output mixers
12366 */
12367static struct hda_verb alc269_init_verbs[] = {
12368 /*
12369 * Unmute ADC0 and set the default input to mic-in
12370 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012372
12373 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12374 * analog-loopback mixer widget
12375 * Note: PASD motherboards uses the Line In 2 as the input for
12376 * front panel mic (mic 2)
12377 */
12378 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12384
12385 /*
12386 * Set up output mixers (0x0c - 0x0e)
12387 */
12388 /* set vol=0 to output mixers */
12389 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12390 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12391
12392 /* set up input amps for analog loopback */
12393 /* Amp Indices: DAC = 0, mixer = 1 */
12394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12400
12401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12403 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12404 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12405 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12408
12409 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12411 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12415 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12416
12417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12419
12420 /* FIXME: use matrix-type input source selection */
12421 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12422 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012425 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12426 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12427
12428 /* set EAPD */
12429 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12430 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12431 { }
12432};
12433
12434/* add playback controls from the parsed DAC table */
12435static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12436 const struct auto_pin_cfg *cfg)
12437{
12438 hda_nid_t nid;
12439 int err;
12440
12441 spec->multiout.num_dacs = 1; /* only use one dac */
12442 spec->multiout.dac_nids = spec->private_dac_nids;
12443 spec->multiout.dac_nids[0] = 2;
12444
12445 nid = cfg->line_out_pins[0];
12446 if (nid) {
12447 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12448 "Front Playback Volume",
12449 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12450 if (err < 0)
12451 return err;
12452 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12453 "Front Playback Switch",
12454 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12455 if (err < 0)
12456 return err;
12457 }
12458
12459 nid = cfg->speaker_pins[0];
12460 if (nid) {
12461 if (!cfg->line_out_pins[0]) {
12462 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12463 "Speaker Playback Volume",
12464 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12465 HDA_OUTPUT));
12466 if (err < 0)
12467 return err;
12468 }
12469 if (nid == 0x16) {
12470 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12471 "Speaker Playback Switch",
12472 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12473 HDA_OUTPUT));
12474 if (err < 0)
12475 return err;
12476 } else {
12477 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12478 "Speaker Playback Switch",
12479 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12480 HDA_OUTPUT));
12481 if (err < 0)
12482 return err;
12483 }
12484 }
12485 nid = cfg->hp_pins[0];
12486 if (nid) {
12487 /* spec->multiout.hp_nid = 2; */
12488 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12489 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12490 "Headphone Playback Volume",
12491 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12492 HDA_OUTPUT));
12493 if (err < 0)
12494 return err;
12495 }
12496 if (nid == 0x16) {
12497 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12498 "Headphone Playback Switch",
12499 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12500 HDA_OUTPUT));
12501 if (err < 0)
12502 return err;
12503 } else {
12504 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12505 "Headphone Playback Switch",
12506 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12507 HDA_OUTPUT));
12508 if (err < 0)
12509 return err;
12510 }
12511 }
12512 return 0;
12513}
12514
Takashi Iwaiee956e02008-10-31 17:16:31 +010012515static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12516 const struct auto_pin_cfg *cfg)
12517{
12518 int err;
12519
12520 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12521 if (err < 0)
12522 return err;
12523 /* digital-mic input pin is excluded in alc880_auto_create..()
12524 * because it's under 0x18
12525 */
12526 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12527 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12528 struct hda_input_mux *imux = &spec->private_imux;
12529 imux->items[imux->num_items].label = "Int Mic";
12530 imux->items[imux->num_items].index = 0x05;
12531 imux->num_items++;
12532 }
12533 return 0;
12534}
Kailang Yangf6a92242007-12-13 16:52:54 +010012535
12536#ifdef CONFIG_SND_HDA_POWER_SAVE
12537#define alc269_loopbacks alc880_loopbacks
12538#endif
12539
12540/* pcm configuration: identiacal with ALC880 */
12541#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12542#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12543#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12544#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12545
12546/*
12547 * BIOS auto configuration
12548 */
12549static int alc269_parse_auto_config(struct hda_codec *codec)
12550{
12551 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012552 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012553 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12554
12555 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12556 alc269_ignore);
12557 if (err < 0)
12558 return err;
12559
12560 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12561 if (err < 0)
12562 return err;
12563 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12564 if (err < 0)
12565 return err;
12566
12567 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12568
12569 if (spec->autocfg.dig_out_pin)
12570 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12571
Takashi Iwai603c4012008-07-30 15:01:44 +020012572 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012573 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012574
Takashi Iwai2005af22008-08-20 18:38:26 +020012575 /* create a beep mixer control if the pin 0x1d isn't assigned */
12576 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12577 if (spec->autocfg.input_pins[i] == 0x1d)
12578 break;
12579 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012580 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012581
Takashi Iwaid88897e2008-10-31 15:01:37 +010012582 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012583 spec->num_mux_defs = 1;
12584 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012585 /* set default input source */
12586 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12587 0, AC_VERB_SET_CONNECT_SEL,
12588 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012589
12590 err = alc_auto_add_mic_boost(codec);
12591 if (err < 0)
12592 return err;
12593
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012594 if (!spec->cap_mixer)
12595 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012596
Takashi Iwaie044c392008-10-27 16:56:24 +010012597 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012598 return 1;
12599}
12600
12601#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12602#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12603#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12604
12605
12606/* init callback for auto-configuration model -- overriding the default init */
12607static void alc269_auto_init(struct hda_codec *codec)
12608{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012609 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012610 alc269_auto_init_multi_out(codec);
12611 alc269_auto_init_hp_out(codec);
12612 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012613 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012614 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012615}
12616
12617/*
12618 * configuration and preset
12619 */
12620static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012621 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012622 [ALC269_QUANTA_FL1] = "quanta",
12623 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012624 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012625 [ALC269_FUJITSU] = "fujitsu",
12626 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012627};
12628
12629static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012630 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012631 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12632 ALC269_ASUS_EEEPC_P703),
12633 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12634 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012635 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12636 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012637 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012638 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012639 {}
12640};
12641
12642static struct alc_config_preset alc269_presets[] = {
12643 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012644 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012645 .init_verbs = { alc269_init_verbs },
12646 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12647 .dac_nids = alc269_dac_nids,
12648 .hp_nid = 0x03,
12649 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12650 .channel_mode = alc269_modes,
12651 .input_mux = &alc269_capture_source,
12652 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012653 [ALC269_QUANTA_FL1] = {
12654 .mixers = { alc269_quanta_fl1_mixer },
12655 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12656 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12657 .dac_nids = alc269_dac_nids,
12658 .hp_nid = 0x03,
12659 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12660 .channel_mode = alc269_modes,
12661 .input_mux = &alc269_capture_source,
12662 .unsol_event = alc269_quanta_fl1_unsol_event,
12663 .init_hook = alc269_quanta_fl1_init_hook,
12664 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012665 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012666 .mixers = { alc269_eeepc_mixer },
12667 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012668 .init_verbs = { alc269_init_verbs,
12669 alc269_eeepc_amic_init_verbs },
12670 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12671 .dac_nids = alc269_dac_nids,
12672 .hp_nid = 0x03,
12673 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12674 .channel_mode = alc269_modes,
12675 .input_mux = &alc269_eeepc_amic_capture_source,
12676 .unsol_event = alc269_eeepc_amic_unsol_event,
12677 .init_hook = alc269_eeepc_amic_inithook,
12678 },
12679 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012680 .mixers = { alc269_eeepc_mixer },
12681 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012682 .init_verbs = { alc269_init_verbs,
12683 alc269_eeepc_dmic_init_verbs },
12684 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12685 .dac_nids = alc269_dac_nids,
12686 .hp_nid = 0x03,
12687 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12688 .channel_mode = alc269_modes,
12689 .input_mux = &alc269_eeepc_dmic_capture_source,
12690 .unsol_event = alc269_eeepc_dmic_unsol_event,
12691 .init_hook = alc269_eeepc_dmic_inithook,
12692 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012693 [ALC269_FUJITSU] = {
12694 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12695 .cap_mixer = alc269_epc_capture_mixer,
12696 .init_verbs = { alc269_init_verbs,
12697 alc269_eeepc_dmic_init_verbs },
12698 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12699 .dac_nids = alc269_dac_nids,
12700 .hp_nid = 0x03,
12701 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12702 .channel_mode = alc269_modes,
12703 .input_mux = &alc269_eeepc_dmic_capture_source,
12704 .unsol_event = alc269_eeepc_dmic_unsol_event,
12705 .init_hook = alc269_eeepc_dmic_inithook,
12706 },
Tony Vroon64154832008-11-06 15:08:49 +000012707 [ALC269_LIFEBOOK] = {
12708 .mixers = { alc269_lifebook_mixer },
12709 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12710 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12711 .dac_nids = alc269_dac_nids,
12712 .hp_nid = 0x03,
12713 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12714 .channel_mode = alc269_modes,
12715 .input_mux = &alc269_capture_source,
12716 .unsol_event = alc269_lifebook_unsol_event,
12717 .init_hook = alc269_lifebook_init_hook,
12718 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012719};
12720
12721static int patch_alc269(struct hda_codec *codec)
12722{
12723 struct alc_spec *spec;
12724 int board_config;
12725 int err;
12726
12727 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12728 if (spec == NULL)
12729 return -ENOMEM;
12730
12731 codec->spec = spec;
12732
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012733 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12734
Kailang Yangf6a92242007-12-13 16:52:54 +010012735 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12736 alc269_models,
12737 alc269_cfg_tbl);
12738
12739 if (board_config < 0) {
12740 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12741 "trying auto-probe from BIOS...\n");
12742 board_config = ALC269_AUTO;
12743 }
12744
12745 if (board_config == ALC269_AUTO) {
12746 /* automatic parse from the BIOS config */
12747 err = alc269_parse_auto_config(codec);
12748 if (err < 0) {
12749 alc_free(codec);
12750 return err;
12751 } else if (!err) {
12752 printk(KERN_INFO
12753 "hda_codec: Cannot set up configuration "
12754 "from BIOS. Using base mode...\n");
12755 board_config = ALC269_BASIC;
12756 }
12757 }
12758
12759 if (board_config != ALC269_AUTO)
12760 setup_preset(spec, &alc269_presets[board_config]);
12761
12762 spec->stream_name_analog = "ALC269 Analog";
12763 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12764 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12765
12766 spec->stream_name_digital = "ALC269 Digital";
12767 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12768 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12769
12770 spec->adc_nids = alc269_adc_nids;
12771 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012772 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012773 if (!spec->cap_mixer)
12774 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012775
12776 codec->patch_ops = alc_patch_ops;
12777 if (board_config == ALC269_AUTO)
12778 spec->init_hook = alc269_auto_init;
12779#ifdef CONFIG_SND_HDA_POWER_SAVE
12780 if (!spec->loopback.amplist)
12781 spec->loopback.amplist = alc269_loopbacks;
12782#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012783 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012784
12785 return 0;
12786}
12787
12788/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012789 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12790 */
12791
12792/*
12793 * set the path ways for 2 channel output
12794 * need to set the codec line out and mic 1 pin widgets to inputs
12795 */
12796static struct hda_verb alc861_threestack_ch2_init[] = {
12797 /* set pin widget 1Ah (line in) for input */
12798 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012799 /* set pin widget 18h (mic1/2) for input, for mic also enable
12800 * the vref
12801 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012802 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12803
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012804 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12805#if 0
12806 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12807 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12808#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012809 { } /* end */
12810};
12811/*
12812 * 6ch mode
12813 * need to set the codec line out and mic 1 pin widgets to outputs
12814 */
12815static struct hda_verb alc861_threestack_ch6_init[] = {
12816 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12817 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12818 /* set pin widget 18h (mic1) for output (CLFE)*/
12819 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12820
12821 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012822 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012823
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012824 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12825#if 0
12826 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12827 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12828#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012829 { } /* end */
12830};
12831
12832static struct hda_channel_mode alc861_threestack_modes[2] = {
12833 { 2, alc861_threestack_ch2_init },
12834 { 6, alc861_threestack_ch6_init },
12835};
Takashi Iwai22309c32006-08-09 16:57:28 +020012836/* Set mic1 as input and unmute the mixer */
12837static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12838 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12839 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12840 { } /* end */
12841};
12842/* Set mic1 as output and mute mixer */
12843static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12844 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12845 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12846 { } /* end */
12847};
12848
12849static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12850 { 2, alc861_uniwill_m31_ch2_init },
12851 { 4, alc861_uniwill_m31_ch4_init },
12852};
Kailang Yangdf694da2005-12-05 19:42:22 +010012853
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012854/* Set mic1 and line-in as input and unmute the mixer */
12855static struct hda_verb alc861_asus_ch2_init[] = {
12856 /* set pin widget 1Ah (line in) for input */
12857 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012858 /* set pin widget 18h (mic1/2) for input, for mic also enable
12859 * the vref
12860 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012861 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12862
12863 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12864#if 0
12865 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12866 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12867#endif
12868 { } /* end */
12869};
12870/* Set mic1 nad line-in as output and mute mixer */
12871static struct hda_verb alc861_asus_ch6_init[] = {
12872 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12873 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12874 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12875 /* set pin widget 18h (mic1) for output (CLFE)*/
12876 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12877 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12878 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12879 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12880
12881 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12882#if 0
12883 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12884 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12885#endif
12886 { } /* end */
12887};
12888
12889static struct hda_channel_mode alc861_asus_modes[2] = {
12890 { 2, alc861_asus_ch2_init },
12891 { 6, alc861_asus_ch6_init },
12892};
12893
Kailang Yangdf694da2005-12-05 19:42:22 +010012894/* patch-ALC861 */
12895
12896static struct snd_kcontrol_new alc861_base_mixer[] = {
12897 /* output mixer control */
12898 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12899 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12900 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12901 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12902 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12903
12904 /*Input mixer control */
12905 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12907 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12908 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12909 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12910 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12912 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12913 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012915
Kailang Yangdf694da2005-12-05 19:42:22 +010012916 { } /* end */
12917};
12918
12919static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12920 /* output mixer control */
12921 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12922 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12924 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12925 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12926
12927 /* Input mixer control */
12928 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12929 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12930 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12931 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12932 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12933 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12935 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12936 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012938
Kailang Yangdf694da2005-12-05 19:42:22 +010012939 {
12940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12941 .name = "Channel Mode",
12942 .info = alc_ch_mode_info,
12943 .get = alc_ch_mode_get,
12944 .put = alc_ch_mode_put,
12945 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12946 },
12947 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012948};
12949
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012950static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012951 /* output mixer control */
12952 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12954 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012955
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012956 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012957};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012958
Takashi Iwai22309c32006-08-09 16:57:28 +020012959static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12960 /* output mixer control */
12961 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12962 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12963 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12964 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12965 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12966
12967 /* Input mixer control */
12968 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12970 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12971 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12972 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12973 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12975 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012978
Takashi Iwai22309c32006-08-09 16:57:28 +020012979 {
12980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12981 .name = "Channel Mode",
12982 .info = alc_ch_mode_info,
12983 .get = alc_ch_mode_get,
12984 .put = alc_ch_mode_put,
12985 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12986 },
12987 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012988};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012989
12990static struct snd_kcontrol_new alc861_asus_mixer[] = {
12991 /* output mixer control */
12992 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12993 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12994 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12995 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12996 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12997
12998 /* Input mixer control */
12999 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13000 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13001 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13002 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13003 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13004 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13006 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13009
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013010 {
13011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13012 .name = "Channel Mode",
13013 .info = alc_ch_mode_info,
13014 .get = alc_ch_mode_get,
13015 .put = alc_ch_mode_put,
13016 .private_value = ARRAY_SIZE(alc861_asus_modes),
13017 },
13018 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013019};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013020
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013021/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013022static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013023 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13024 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13025 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
13026 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
13027 { }
13028};
13029
Kailang Yangdf694da2005-12-05 19:42:22 +010013030/*
13031 * generic initialization of ADC, input mixers and output mixers
13032 */
13033static struct hda_verb alc861_base_init_verbs[] = {
13034 /*
13035 * Unmute ADC0 and set the default input to mic-in
13036 */
13037 /* port-A for surround (rear panel) */
13038 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13039 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13040 /* port-B for mic-in (rear panel) with vref */
13041 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13042 /* port-C for line-in (rear panel) */
13043 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13044 /* port-D for Front */
13045 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13046 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13047 /* port-E for HP out (front panel) */
13048 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13049 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013050 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013051 /* port-F for mic-in (front panel) with vref */
13052 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13053 /* port-G for CLFE (rear panel) */
13054 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13055 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13056 /* port-H for side (rear panel) */
13057 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13058 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13059 /* CD-in */
13060 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13061 /* route front mic to ADC1*/
13062 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013064
Kailang Yangdf694da2005-12-05 19:42:22 +010013065 /* Unmute DAC0~3 & spdif out*/
13066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13068 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13069 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013071
Kailang Yangdf694da2005-12-05 19:42:22 +010013072 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13073 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13074 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13075 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13076 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013077
Kailang Yangdf694da2005-12-05 19:42:22 +010013078 /* Unmute Stereo Mixer 15 */
13079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013083
13084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13085 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13087 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13088 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013092 /* hp used DAC 3 (Front) */
13093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13095
13096 { }
13097};
13098
13099static struct hda_verb alc861_threestack_init_verbs[] = {
13100 /*
13101 * Unmute ADC0 and set the default input to mic-in
13102 */
13103 /* port-A for surround (rear panel) */
13104 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13105 /* port-B for mic-in (rear panel) with vref */
13106 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13107 /* port-C for line-in (rear panel) */
13108 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13109 /* port-D for Front */
13110 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13111 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13112 /* port-E for HP out (front panel) */
13113 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13114 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013115 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013116 /* port-F for mic-in (front panel) with vref */
13117 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13118 /* port-G for CLFE (rear panel) */
13119 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13120 /* port-H for side (rear panel) */
13121 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13122 /* CD-in */
13123 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13124 /* route front mic to ADC1*/
13125 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13127 /* Unmute DAC0~3 & spdif out*/
13128 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13129 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13130 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13131 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013133
Kailang Yangdf694da2005-12-05 19:42:22 +010013134 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13135 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13136 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13137 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13138 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013139
Kailang Yangdf694da2005-12-05 19:42:22 +010013140 /* Unmute Stereo Mixer 15 */
13141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013144 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013145
13146 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13147 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13148 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13149 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13150 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13151 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13152 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13153 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013154 /* hp used DAC 3 (Front) */
13155 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013156 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13157 { }
13158};
Takashi Iwai22309c32006-08-09 16:57:28 +020013159
13160static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13161 /*
13162 * Unmute ADC0 and set the default input to mic-in
13163 */
13164 /* port-A for surround (rear panel) */
13165 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13166 /* port-B for mic-in (rear panel) with vref */
13167 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13168 /* port-C for line-in (rear panel) */
13169 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13170 /* port-D for Front */
13171 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13172 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13173 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013174 /* this has to be set to VREF80 */
13175 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013176 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013177 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013178 /* port-F for mic-in (front panel) with vref */
13179 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13180 /* port-G for CLFE (rear panel) */
13181 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13182 /* port-H for side (rear panel) */
13183 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13184 /* CD-in */
13185 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13186 /* route front mic to ADC1*/
13187 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13189 /* Unmute DAC0~3 & spdif out*/
13190 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13191 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13192 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13193 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013195
Takashi Iwai22309c32006-08-09 16:57:28 +020013196 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13197 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13198 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13199 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13200 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013201
Takashi Iwai22309c32006-08-09 16:57:28 +020013202 /* Unmute Stereo Mixer 15 */
13203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013207
13208 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13209 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13210 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13211 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13214 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13215 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013216 /* hp used DAC 3 (Front) */
13217 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013218 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13219 { }
13220};
13221
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013222static struct hda_verb alc861_asus_init_verbs[] = {
13223 /*
13224 * Unmute ADC0 and set the default input to mic-in
13225 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013226 /* port-A for surround (rear panel)
13227 * according to codec#0 this is the HP jack
13228 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013229 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13230 /* route front PCM to HP */
13231 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13232 /* port-B for mic-in (rear panel) with vref */
13233 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13234 /* port-C for line-in (rear panel) */
13235 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13236 /* port-D for Front */
13237 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13239 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013240 /* this has to be set to VREF80 */
13241 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013242 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013243 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013244 /* port-F for mic-in (front panel) with vref */
13245 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13246 /* port-G for CLFE (rear panel) */
13247 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13248 /* port-H for side (rear panel) */
13249 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13250 /* CD-in */
13251 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13252 /* route front mic to ADC1*/
13253 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13255 /* Unmute DAC0~3 & spdif out*/
13256 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13257 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13258 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13259 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13261 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13262 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13263 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13264 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013266
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013267 /* Unmute Stereo Mixer 15 */
13268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013272
13273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13276 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13277 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013281 /* hp used DAC 3 (Front) */
13282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13284 { }
13285};
13286
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013287/* additional init verbs for ASUS laptops */
13288static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13289 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13291 { }
13292};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013293
Kailang Yangdf694da2005-12-05 19:42:22 +010013294/*
13295 * generic initialization of ADC, input mixers and output mixers
13296 */
13297static struct hda_verb alc861_auto_init_verbs[] = {
13298 /*
13299 * Unmute ADC0 and set the default input to mic-in
13300 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013301 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013303
Kailang Yangdf694da2005-12-05 19:42:22 +010013304 /* Unmute DAC0~3 & spdif out*/
13305 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13306 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13307 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13308 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013310
Kailang Yangdf694da2005-12-05 19:42:22 +010013311 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13312 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13313 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13314 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13315 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013316
Kailang Yangdf694da2005-12-05 19:42:22 +010013317 /* Unmute Stereo Mixer 15 */
13318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13320 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13322
13323 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13324 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13325 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13326 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13327 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13329 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13331
13332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013334 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013336 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13337 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013338 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013340
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013341 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013342
13343 { }
13344};
13345
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013346static struct hda_verb alc861_toshiba_init_verbs[] = {
13347 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013348
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013349 { }
13350};
13351
13352/* toggle speaker-output according to the hp-jack state */
13353static void alc861_toshiba_automute(struct hda_codec *codec)
13354{
13355 unsigned int present;
13356
13357 present = snd_hda_codec_read(codec, 0x0f, 0,
13358 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013359 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13360 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13361 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13362 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013363}
13364
13365static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13366 unsigned int res)
13367{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013368 if ((res >> 26) == ALC880_HP_EVENT)
13369 alc861_toshiba_automute(codec);
13370}
13371
Kailang Yangdf694da2005-12-05 19:42:22 +010013372/* pcm configuration: identiacal with ALC880 */
13373#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13374#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13375#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13376#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13377
13378
13379#define ALC861_DIGOUT_NID 0x07
13380
13381static struct hda_channel_mode alc861_8ch_modes[1] = {
13382 { 8, NULL }
13383};
13384
13385static hda_nid_t alc861_dac_nids[4] = {
13386 /* front, surround, clfe, side */
13387 0x03, 0x06, 0x05, 0x04
13388};
13389
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013390static hda_nid_t alc660_dac_nids[3] = {
13391 /* front, clfe, surround */
13392 0x03, 0x05, 0x06
13393};
13394
Kailang Yangdf694da2005-12-05 19:42:22 +010013395static hda_nid_t alc861_adc_nids[1] = {
13396 /* ADC0-2 */
13397 0x08,
13398};
13399
13400static struct hda_input_mux alc861_capture_source = {
13401 .num_items = 5,
13402 .items = {
13403 { "Mic", 0x0 },
13404 { "Front Mic", 0x3 },
13405 { "Line", 0x1 },
13406 { "CD", 0x4 },
13407 { "Mixer", 0x5 },
13408 },
13409};
13410
13411/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013412static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13413 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013414{
13415 int i;
13416 hda_nid_t nid;
13417
13418 spec->multiout.dac_nids = spec->private_dac_nids;
13419 for (i = 0; i < cfg->line_outs; i++) {
13420 nid = cfg->line_out_pins[i];
13421 if (nid) {
13422 if (i >= ARRAY_SIZE(alc861_dac_nids))
13423 continue;
13424 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13425 }
13426 }
13427 spec->multiout.num_dacs = cfg->line_outs;
13428 return 0;
13429}
13430
13431/* add playback controls from the parsed DAC table */
13432static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13433 const struct auto_pin_cfg *cfg)
13434{
13435 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013436 static const char *chname[4] = {
13437 "Front", "Surround", NULL /*CLFE*/, "Side"
13438 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013439 hda_nid_t nid;
13440 int i, idx, err;
13441
13442 for (i = 0; i < cfg->line_outs; i++) {
13443 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013444 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013445 continue;
13446 if (nid == 0x05) {
13447 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013448 err = add_control(spec, ALC_CTL_BIND_MUTE,
13449 "Center Playback Switch",
13450 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13451 HDA_OUTPUT));
13452 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013453 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013454 err = add_control(spec, ALC_CTL_BIND_MUTE,
13455 "LFE Playback Switch",
13456 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13457 HDA_OUTPUT));
13458 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013459 return err;
13460 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013461 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13462 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013463 if (nid == alc861_dac_nids[idx])
13464 break;
13465 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013466 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13467 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13468 HDA_OUTPUT));
13469 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013470 return err;
13471 }
13472 }
13473 return 0;
13474}
13475
13476static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13477{
13478 int err;
13479 hda_nid_t nid;
13480
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013481 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013482 return 0;
13483
13484 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13485 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013486 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13487 "Headphone Playback Switch",
13488 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13489 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013490 return err;
13491 spec->multiout.hp_nid = nid;
13492 }
13493 return 0;
13494}
13495
13496/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013497static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13498 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013499{
Kailang Yangdf694da2005-12-05 19:42:22 +010013500 struct hda_input_mux *imux = &spec->private_imux;
13501 int i, err, idx, idx1;
13502
13503 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013504 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013505 case 0x0c:
13506 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013507 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013508 break;
13509 case 0x0f:
13510 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013511 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013512 break;
13513 case 0x0d:
13514 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013515 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013516 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013517 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013518 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013519 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013520 break;
13521 case 0x11:
13522 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013523 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013524 break;
13525 default:
13526 continue;
13527 }
13528
Takashi Iwai4a471b72005-12-07 13:56:29 +010013529 err = new_analog_input(spec, cfg->input_pins[i],
13530 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013531 if (err < 0)
13532 return err;
13533
Takashi Iwai4a471b72005-12-07 13:56:29 +010013534 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013535 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013536 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013537 }
13538 return 0;
13539}
13540
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013541static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13542 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013543 int pin_type, int dac_idx)
13544{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013545 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13546 pin_type);
13547 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13548 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013549}
13550
13551static void alc861_auto_init_multi_out(struct hda_codec *codec)
13552{
13553 struct alc_spec *spec = codec->spec;
13554 int i;
13555
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013556 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013557 for (i = 0; i < spec->autocfg.line_outs; i++) {
13558 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013559 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013560 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013561 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013562 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013563 }
13564}
13565
13566static void alc861_auto_init_hp_out(struct hda_codec *codec)
13567{
13568 struct alc_spec *spec = codec->spec;
13569 hda_nid_t pin;
13570
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013571 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013572 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013573 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13574 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013575 pin = spec->autocfg.speaker_pins[0];
13576 if (pin)
13577 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013578}
13579
13580static void alc861_auto_init_analog_input(struct hda_codec *codec)
13581{
13582 struct alc_spec *spec = codec->spec;
13583 int i;
13584
13585 for (i = 0; i < AUTO_PIN_LAST; i++) {
13586 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 if (nid >= 0x0c && nid <= 0x11) {
13588 snd_hda_codec_write(codec, nid, 0,
13589 AC_VERB_SET_PIN_WIDGET_CONTROL,
13590 i <= AUTO_PIN_FRONT_MIC ?
13591 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013592 }
13593 }
13594}
13595
13596/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013597/* return 1 if successful, 0 if the proper config is not found,
13598 * or a negative error code
13599 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013600static int alc861_parse_auto_config(struct hda_codec *codec)
13601{
13602 struct alc_spec *spec = codec->spec;
13603 int err;
13604 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013606 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13607 alc861_ignore);
13608 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013609 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013610 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013611 return 0; /* can't find valid BIOS pin config */
13612
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013613 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13614 if (err < 0)
13615 return err;
13616 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13617 if (err < 0)
13618 return err;
13619 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13620 if (err < 0)
13621 return err;
13622 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013624 return err;
13625
13626 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13627
13628 if (spec->autocfg.dig_out_pin)
13629 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13630
Takashi Iwai603c4012008-07-30 15:01:44 +020013631 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013632 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013633
Takashi Iwaid88897e2008-10-31 15:01:37 +010013634 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013635
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013636 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013637 spec->input_mux = &spec->private_imux;
13638
13639 spec->adc_nids = alc861_adc_nids;
13640 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013641 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013642
Takashi Iwaie044c392008-10-27 16:56:24 +010013643 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 return 1;
13645}
13646
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013647/* additional initialization for auto-configuration model */
13648static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013649{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013650 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013651 alc861_auto_init_multi_out(codec);
13652 alc861_auto_init_hp_out(codec);
13653 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013654 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013655 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013656}
13657
Takashi Iwaicb53c622007-08-10 17:21:45 +020013658#ifdef CONFIG_SND_HDA_POWER_SAVE
13659static struct hda_amp_list alc861_loopbacks[] = {
13660 { 0x15, HDA_INPUT, 0 },
13661 { 0x15, HDA_INPUT, 1 },
13662 { 0x15, HDA_INPUT, 2 },
13663 { 0x15, HDA_INPUT, 3 },
13664 { } /* end */
13665};
13666#endif
13667
Kailang Yangdf694da2005-12-05 19:42:22 +010013668
13669/*
13670 * configuration and preset
13671 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013672static const char *alc861_models[ALC861_MODEL_LAST] = {
13673 [ALC861_3ST] = "3stack",
13674 [ALC660_3ST] = "3stack-660",
13675 [ALC861_3ST_DIG] = "3stack-dig",
13676 [ALC861_6ST_DIG] = "6stack-dig",
13677 [ALC861_UNIWILL_M31] = "uniwill-m31",
13678 [ALC861_TOSHIBA] = "toshiba",
13679 [ALC861_ASUS] = "asus",
13680 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13681 [ALC861_AUTO] = "auto",
13682};
13683
13684static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013685 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013686 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13687 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13688 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013689 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013690 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013691 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013692 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13693 * Any other models that need this preset?
13694 */
13695 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013696 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13697 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013698 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13699 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13700 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13701 /* FIXME: the below seems conflict */
13702 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13703 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13704 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013705 {}
13706};
13707
13708static struct alc_config_preset alc861_presets[] = {
13709 [ALC861_3ST] = {
13710 .mixers = { alc861_3ST_mixer },
13711 .init_verbs = { alc861_threestack_init_verbs },
13712 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13713 .dac_nids = alc861_dac_nids,
13714 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13715 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013716 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013717 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13718 .adc_nids = alc861_adc_nids,
13719 .input_mux = &alc861_capture_source,
13720 },
13721 [ALC861_3ST_DIG] = {
13722 .mixers = { alc861_base_mixer },
13723 .init_verbs = { alc861_threestack_init_verbs },
13724 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13725 .dac_nids = alc861_dac_nids,
13726 .dig_out_nid = ALC861_DIGOUT_NID,
13727 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13728 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013729 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013730 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13731 .adc_nids = alc861_adc_nids,
13732 .input_mux = &alc861_capture_source,
13733 },
13734 [ALC861_6ST_DIG] = {
13735 .mixers = { alc861_base_mixer },
13736 .init_verbs = { alc861_base_init_verbs },
13737 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13738 .dac_nids = alc861_dac_nids,
13739 .dig_out_nid = ALC861_DIGOUT_NID,
13740 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13741 .channel_mode = alc861_8ch_modes,
13742 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13743 .adc_nids = alc861_adc_nids,
13744 .input_mux = &alc861_capture_source,
13745 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013746 [ALC660_3ST] = {
13747 .mixers = { alc861_3ST_mixer },
13748 .init_verbs = { alc861_threestack_init_verbs },
13749 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13750 .dac_nids = alc660_dac_nids,
13751 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13752 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013753 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013754 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13755 .adc_nids = alc861_adc_nids,
13756 .input_mux = &alc861_capture_source,
13757 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013758 [ALC861_UNIWILL_M31] = {
13759 .mixers = { alc861_uniwill_m31_mixer },
13760 .init_verbs = { alc861_uniwill_m31_init_verbs },
13761 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13762 .dac_nids = alc861_dac_nids,
13763 .dig_out_nid = ALC861_DIGOUT_NID,
13764 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13765 .channel_mode = alc861_uniwill_m31_modes,
13766 .need_dac_fix = 1,
13767 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13768 .adc_nids = alc861_adc_nids,
13769 .input_mux = &alc861_capture_source,
13770 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013771 [ALC861_TOSHIBA] = {
13772 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013773 .init_verbs = { alc861_base_init_verbs,
13774 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013775 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13776 .dac_nids = alc861_dac_nids,
13777 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13778 .channel_mode = alc883_3ST_2ch_modes,
13779 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13780 .adc_nids = alc861_adc_nids,
13781 .input_mux = &alc861_capture_source,
13782 .unsol_event = alc861_toshiba_unsol_event,
13783 .init_hook = alc861_toshiba_automute,
13784 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013785 [ALC861_ASUS] = {
13786 .mixers = { alc861_asus_mixer },
13787 .init_verbs = { alc861_asus_init_verbs },
13788 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13789 .dac_nids = alc861_dac_nids,
13790 .dig_out_nid = ALC861_DIGOUT_NID,
13791 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13792 .channel_mode = alc861_asus_modes,
13793 .need_dac_fix = 1,
13794 .hp_nid = 0x06,
13795 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13796 .adc_nids = alc861_adc_nids,
13797 .input_mux = &alc861_capture_source,
13798 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013799 [ALC861_ASUS_LAPTOP] = {
13800 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13801 .init_verbs = { alc861_asus_init_verbs,
13802 alc861_asus_laptop_init_verbs },
13803 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13804 .dac_nids = alc861_dac_nids,
13805 .dig_out_nid = ALC861_DIGOUT_NID,
13806 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13807 .channel_mode = alc883_3ST_2ch_modes,
13808 .need_dac_fix = 1,
13809 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13810 .adc_nids = alc861_adc_nids,
13811 .input_mux = &alc861_capture_source,
13812 },
13813};
Kailang Yangdf694da2005-12-05 19:42:22 +010013814
13815
13816static int patch_alc861(struct hda_codec *codec)
13817{
13818 struct alc_spec *spec;
13819 int board_config;
13820 int err;
13821
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013822 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 if (spec == NULL)
13824 return -ENOMEM;
13825
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013826 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013827
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013828 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13829 alc861_models,
13830 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013831
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013832 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013833 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13834 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013835 board_config = ALC861_AUTO;
13836 }
13837
13838 if (board_config == ALC861_AUTO) {
13839 /* automatic parse from the BIOS config */
13840 err = alc861_parse_auto_config(codec);
13841 if (err < 0) {
13842 alc_free(codec);
13843 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013844 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013845 printk(KERN_INFO
13846 "hda_codec: Cannot set up configuration "
13847 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 board_config = ALC861_3ST_DIG;
13849 }
13850 }
13851
13852 if (board_config != ALC861_AUTO)
13853 setup_preset(spec, &alc861_presets[board_config]);
13854
13855 spec->stream_name_analog = "ALC861 Analog";
13856 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13857 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13858
13859 spec->stream_name_digital = "ALC861 Digital";
13860 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13861 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13862
Takashi Iwai2134ea42008-01-10 16:53:55 +010013863 spec->vmaster_nid = 0x03;
13864
Kailang Yangdf694da2005-12-05 19:42:22 +010013865 codec->patch_ops = alc_patch_ops;
13866 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013867 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013868#ifdef CONFIG_SND_HDA_POWER_SAVE
13869 if (!spec->loopback.amplist)
13870 spec->loopback.amplist = alc861_loopbacks;
13871#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013872 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020013873
Kailang Yangdf694da2005-12-05 19:42:22 +010013874 return 0;
13875}
13876
13877/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013878 * ALC861-VD support
13879 *
13880 * Based on ALC882
13881 *
13882 * In addition, an independent DAC
13883 */
13884#define ALC861VD_DIGOUT_NID 0x06
13885
13886static hda_nid_t alc861vd_dac_nids[4] = {
13887 /* front, surr, clfe, side surr */
13888 0x02, 0x03, 0x04, 0x05
13889};
13890
13891/* dac_nids for ALC660vd are in a different order - according to
13892 * Realtek's driver.
13893 * This should probably tesult in a different mixer for 6stack models
13894 * of ALC660vd codecs, but for now there is only 3stack mixer
13895 * - and it is the same as in 861vd.
13896 * adc_nids in ALC660vd are (is) the same as in 861vd
13897 */
13898static hda_nid_t alc660vd_dac_nids[3] = {
13899 /* front, rear, clfe, rear_surr */
13900 0x02, 0x04, 0x03
13901};
13902
13903static hda_nid_t alc861vd_adc_nids[1] = {
13904 /* ADC0 */
13905 0x09,
13906};
13907
Takashi Iwaie1406342008-02-11 18:32:32 +010013908static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13909
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013910/* input MUX */
13911/* FIXME: should be a matrix-type input source selection */
13912static struct hda_input_mux alc861vd_capture_source = {
13913 .num_items = 4,
13914 .items = {
13915 { "Mic", 0x0 },
13916 { "Front Mic", 0x1 },
13917 { "Line", 0x2 },
13918 { "CD", 0x4 },
13919 },
13920};
13921
Kailang Yang272a5272007-05-14 11:00:38 +020013922static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013923 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013924 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013925 { "Ext Mic", 0x0 },
13926 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013927 },
13928};
13929
Kailang Yangd1a991a2007-08-15 16:21:59 +020013930static struct hda_input_mux alc861vd_hp_capture_source = {
13931 .num_items = 2,
13932 .items = {
13933 { "Front Mic", 0x0 },
13934 { "ATAPI Mic", 0x1 },
13935 },
13936};
13937
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013938/*
13939 * 2ch mode
13940 */
13941static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13942 { 2, NULL }
13943};
13944
13945/*
13946 * 6ch mode
13947 */
13948static struct hda_verb alc861vd_6stack_ch6_init[] = {
13949 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13950 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13951 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13952 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13953 { } /* end */
13954};
13955
13956/*
13957 * 8ch mode
13958 */
13959static struct hda_verb alc861vd_6stack_ch8_init[] = {
13960 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13961 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13962 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13963 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13964 { } /* end */
13965};
13966
13967static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13968 { 6, alc861vd_6stack_ch6_init },
13969 { 8, alc861vd_6stack_ch8_init },
13970};
13971
13972static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13973 {
13974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13975 .name = "Channel Mode",
13976 .info = alc_ch_mode_info,
13977 .get = alc_ch_mode_get,
13978 .put = alc_ch_mode_put,
13979 },
13980 { } /* end */
13981};
13982
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013983/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13984 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13985 */
13986static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13987 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13988 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13989
13990 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13991 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13992
13993 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13994 HDA_OUTPUT),
13995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13996 HDA_OUTPUT),
13997 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13998 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13999
14000 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14001 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14002
14003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14004
14005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14008
14009 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14010 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14011 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14012
14013 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14014 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14015
14016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14018
14019 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14020 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14021
14022 { } /* end */
14023};
14024
14025static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14026 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14027 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14028
14029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14030
14031 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14034
14035 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14036 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14038
14039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14041
14042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14044
14045 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14046 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14047
14048 { } /* end */
14049};
14050
Kailang Yangbdd148a2007-05-08 15:19:08 +020014051static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14052 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14053 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14054 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14055
14056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14057
14058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14061
14062 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14063 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14064 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14065
14066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14068
14069 { } /* end */
14070};
14071
Tobin Davisb419f342008-03-07 11:57:51 +010014072/* Pin assignment: Speaker=0x14, HP = 0x15,
14073 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014074 */
14075static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014076 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14077 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14079 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014080 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14081 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14082 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14083 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14084 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14085 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14086 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14087 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014088 { } /* end */
14089};
14090
Kailang Yangd1a991a2007-08-15 16:21:59 +020014091/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14092 * Front Mic=0x18, ATAPI Mic = 0x19,
14093 */
14094static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14095 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14098 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14099 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14101 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14102 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014103
Kailang Yangd1a991a2007-08-15 16:21:59 +020014104 { } /* end */
14105};
14106
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014107/*
14108 * generic initialization of ADC, input mixers and output mixers
14109 */
14110static struct hda_verb alc861vd_volume_init_verbs[] = {
14111 /*
14112 * Unmute ADC0 and set the default input to mic-in
14113 */
14114 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14116
14117 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14118 * the analog-loopback mixer widget
14119 */
14120 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014126
14127 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014132
14133 /*
14134 * Set up output mixers (0x02 - 0x05)
14135 */
14136 /* set vol=0 to output mixers */
14137 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14138 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14139 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14141
14142 /* set up input amps for analog loopback */
14143 /* Amp Indices: DAC = 0, mixer = 1 */
14144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14152
14153 { }
14154};
14155
14156/*
14157 * 3-stack pin configuration:
14158 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14159 */
14160static struct hda_verb alc861vd_3stack_init_verbs[] = {
14161 /*
14162 * Set pin mode and muting
14163 */
14164 /* set front pin widgets 0x14 for output */
14165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14166 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14167 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14168
14169 /* Mic (rear) pin: input vref at 80% */
14170 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14172 /* Front Mic pin: input vref at 80% */
14173 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14175 /* Line In pin: input */
14176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14178 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14181 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14182 /* CD pin widget for input */
14183 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14184
14185 { }
14186};
14187
14188/*
14189 * 6-stack pin configuration:
14190 */
14191static struct hda_verb alc861vd_6stack_init_verbs[] = {
14192 /*
14193 * Set pin mode and muting
14194 */
14195 /* set front pin widgets 0x14 for output */
14196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14198 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14199
14200 /* Rear Pin: output 1 (0x0d) */
14201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14204 /* CLFE Pin: output 2 (0x0e) */
14205 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14206 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14207 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14208 /* Side Pin: output 3 (0x0f) */
14209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14210 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14211 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14212
14213 /* Mic (rear) pin: input vref at 80% */
14214 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14215 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14216 /* Front Mic pin: input vref at 80% */
14217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14218 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14219 /* Line In pin: input */
14220 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14221 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14222 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14225 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14226 /* CD pin widget for input */
14227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14228
14229 { }
14230};
14231
Kailang Yangbdd148a2007-05-08 15:19:08 +020014232static struct hda_verb alc861vd_eapd_verbs[] = {
14233 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14234 { }
14235};
14236
Kailang Yangf9423e72008-05-27 12:32:25 +020014237static struct hda_verb alc660vd_eapd_verbs[] = {
14238 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14239 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14240 { }
14241};
14242
Kailang Yangbdd148a2007-05-08 15:19:08 +020014243static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014248 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014249 {}
14250};
14251
14252/* toggle speaker-output according to the hp-jack state */
14253static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14254{
14255 unsigned int present;
14256 unsigned char bits;
14257
14258 present = snd_hda_codec_read(codec, 0x1b, 0,
14259 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014260 bits = present ? HDA_AMP_MUTE : 0;
14261 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14262 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014263}
14264
14265static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14266{
14267 unsigned int present;
14268 unsigned char bits;
14269
14270 present = snd_hda_codec_read(codec, 0x18, 0,
14271 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014272 bits = present ? HDA_AMP_MUTE : 0;
14273 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14274 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014275}
14276
14277static void alc861vd_lenovo_automute(struct hda_codec *codec)
14278{
14279 alc861vd_lenovo_hp_automute(codec);
14280 alc861vd_lenovo_mic_automute(codec);
14281}
14282
14283static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14284 unsigned int res)
14285{
14286 switch (res >> 26) {
14287 case ALC880_HP_EVENT:
14288 alc861vd_lenovo_hp_automute(codec);
14289 break;
14290 case ALC880_MIC_EVENT:
14291 alc861vd_lenovo_mic_automute(codec);
14292 break;
14293 }
14294}
14295
Kailang Yang272a5272007-05-14 11:00:38 +020014296static struct hda_verb alc861vd_dallas_verbs[] = {
14297 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14298 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14299 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14300 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14301
14302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014310
Kailang Yang272a5272007-05-14 11:00:38 +020014311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14314 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14316 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14317 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14319
14320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14321 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14326 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14327 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14328
14329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14333
14334 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014336 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14337
14338 { } /* end */
14339};
14340
14341/* toggle speaker-output according to the hp-jack state */
14342static void alc861vd_dallas_automute(struct hda_codec *codec)
14343{
14344 unsigned int present;
14345
14346 present = snd_hda_codec_read(codec, 0x15, 0,
14347 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014348 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14349 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014350}
14351
14352static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14353{
14354 if ((res >> 26) == ALC880_HP_EVENT)
14355 alc861vd_dallas_automute(codec);
14356}
14357
Takashi Iwaicb53c622007-08-10 17:21:45 +020014358#ifdef CONFIG_SND_HDA_POWER_SAVE
14359#define alc861vd_loopbacks alc880_loopbacks
14360#endif
14361
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014362/* pcm configuration: identiacal with ALC880 */
14363#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14364#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14365#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14366#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14367
14368/*
14369 * configuration and preset
14370 */
14371static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14372 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014373 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014374 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014375 [ALC861VD_3ST] = "3stack",
14376 [ALC861VD_3ST_DIG] = "3stack-digout",
14377 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014378 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014379 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014380 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014381 [ALC861VD_AUTO] = "auto",
14382};
14383
14384static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014385 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14386 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014387 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014388 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014389 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014390 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014391 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014392 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014393 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014394 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014395 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014396 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014397 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014398 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14399 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a82008-07-07 16:04:04 +020014400 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014401 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014402 {}
14403};
14404
14405static struct alc_config_preset alc861vd_presets[] = {
14406 [ALC660VD_3ST] = {
14407 .mixers = { alc861vd_3st_mixer },
14408 .init_verbs = { alc861vd_volume_init_verbs,
14409 alc861vd_3stack_init_verbs },
14410 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14411 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014412 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14413 .channel_mode = alc861vd_3stack_2ch_modes,
14414 .input_mux = &alc861vd_capture_source,
14415 },
Mike Crash6963f842007-06-25 12:12:51 +020014416 [ALC660VD_3ST_DIG] = {
14417 .mixers = { alc861vd_3st_mixer },
14418 .init_verbs = { alc861vd_volume_init_verbs,
14419 alc861vd_3stack_init_verbs },
14420 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14421 .dac_nids = alc660vd_dac_nids,
14422 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014423 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14424 .channel_mode = alc861vd_3stack_2ch_modes,
14425 .input_mux = &alc861vd_capture_source,
14426 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014427 [ALC861VD_3ST] = {
14428 .mixers = { alc861vd_3st_mixer },
14429 .init_verbs = { alc861vd_volume_init_verbs,
14430 alc861vd_3stack_init_verbs },
14431 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14432 .dac_nids = alc861vd_dac_nids,
14433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14434 .channel_mode = alc861vd_3stack_2ch_modes,
14435 .input_mux = &alc861vd_capture_source,
14436 },
14437 [ALC861VD_3ST_DIG] = {
14438 .mixers = { alc861vd_3st_mixer },
14439 .init_verbs = { alc861vd_volume_init_verbs,
14440 alc861vd_3stack_init_verbs },
14441 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14442 .dac_nids = alc861vd_dac_nids,
14443 .dig_out_nid = ALC861VD_DIGOUT_NID,
14444 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14445 .channel_mode = alc861vd_3stack_2ch_modes,
14446 .input_mux = &alc861vd_capture_source,
14447 },
14448 [ALC861VD_6ST_DIG] = {
14449 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14450 .init_verbs = { alc861vd_volume_init_verbs,
14451 alc861vd_6stack_init_verbs },
14452 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14453 .dac_nids = alc861vd_dac_nids,
14454 .dig_out_nid = ALC861VD_DIGOUT_NID,
14455 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14456 .channel_mode = alc861vd_6stack_modes,
14457 .input_mux = &alc861vd_capture_source,
14458 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014459 [ALC861VD_LENOVO] = {
14460 .mixers = { alc861vd_lenovo_mixer },
14461 .init_verbs = { alc861vd_volume_init_verbs,
14462 alc861vd_3stack_init_verbs,
14463 alc861vd_eapd_verbs,
14464 alc861vd_lenovo_unsol_verbs },
14465 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14466 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014467 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14468 .channel_mode = alc861vd_3stack_2ch_modes,
14469 .input_mux = &alc861vd_capture_source,
14470 .unsol_event = alc861vd_lenovo_unsol_event,
14471 .init_hook = alc861vd_lenovo_automute,
14472 },
Kailang Yang272a5272007-05-14 11:00:38 +020014473 [ALC861VD_DALLAS] = {
14474 .mixers = { alc861vd_dallas_mixer },
14475 .init_verbs = { alc861vd_dallas_verbs },
14476 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14477 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014478 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14479 .channel_mode = alc861vd_3stack_2ch_modes,
14480 .input_mux = &alc861vd_dallas_capture_source,
14481 .unsol_event = alc861vd_dallas_unsol_event,
14482 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014483 },
14484 [ALC861VD_HP] = {
14485 .mixers = { alc861vd_hp_mixer },
14486 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14487 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14488 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014489 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014490 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14491 .channel_mode = alc861vd_3stack_2ch_modes,
14492 .input_mux = &alc861vd_hp_capture_source,
14493 .unsol_event = alc861vd_dallas_unsol_event,
14494 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014495 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014496 [ALC660VD_ASUS_V1S] = {
14497 .mixers = { alc861vd_lenovo_mixer },
14498 .init_verbs = { alc861vd_volume_init_verbs,
14499 alc861vd_3stack_init_verbs,
14500 alc861vd_eapd_verbs,
14501 alc861vd_lenovo_unsol_verbs },
14502 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14503 .dac_nids = alc660vd_dac_nids,
14504 .dig_out_nid = ALC861VD_DIGOUT_NID,
14505 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14506 .channel_mode = alc861vd_3stack_2ch_modes,
14507 .input_mux = &alc861vd_capture_source,
14508 .unsol_event = alc861vd_lenovo_unsol_event,
14509 .init_hook = alc861vd_lenovo_automute,
14510 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014511};
14512
14513/*
14514 * BIOS auto configuration
14515 */
14516static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14517 hda_nid_t nid, int pin_type, int dac_idx)
14518{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014519 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014520}
14521
14522static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14523{
14524 struct alc_spec *spec = codec->spec;
14525 int i;
14526
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014527 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014528 for (i = 0; i <= HDA_SIDE; i++) {
14529 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014530 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014531 if (nid)
14532 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014533 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014534 }
14535}
14536
14537
14538static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14539{
14540 struct alc_spec *spec = codec->spec;
14541 hda_nid_t pin;
14542
14543 pin = spec->autocfg.hp_pins[0];
14544 if (pin) /* connect to front and use dac 0 */
14545 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014546 pin = spec->autocfg.speaker_pins[0];
14547 if (pin)
14548 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014549}
14550
14551#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14552#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14553
14554static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14555{
14556 struct alc_spec *spec = codec->spec;
14557 int i;
14558
14559 for (i = 0; i < AUTO_PIN_LAST; i++) {
14560 hda_nid_t nid = spec->autocfg.input_pins[i];
14561 if (alc861vd_is_input_pin(nid)) {
14562 snd_hda_codec_write(codec, nid, 0,
14563 AC_VERB_SET_PIN_WIDGET_CONTROL,
14564 i <= AUTO_PIN_FRONT_MIC ?
14565 PIN_VREF80 : PIN_IN);
14566 if (nid != ALC861VD_PIN_CD_NID)
14567 snd_hda_codec_write(codec, nid, 0,
14568 AC_VERB_SET_AMP_GAIN_MUTE,
14569 AMP_OUT_MUTE);
14570 }
14571 }
14572}
14573
Takashi Iwaif511b012008-08-15 16:46:42 +020014574#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14575
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014576#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14577#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14578
14579/* add playback controls from the parsed DAC table */
14580/* Based on ALC880 version. But ALC861VD has separate,
14581 * different NIDs for mute/unmute switch and volume control */
14582static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14583 const struct auto_pin_cfg *cfg)
14584{
14585 char name[32];
14586 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14587 hda_nid_t nid_v, nid_s;
14588 int i, err;
14589
14590 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014591 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014592 continue;
14593 nid_v = alc861vd_idx_to_mixer_vol(
14594 alc880_dac_to_idx(
14595 spec->multiout.dac_nids[i]));
14596 nid_s = alc861vd_idx_to_mixer_switch(
14597 alc880_dac_to_idx(
14598 spec->multiout.dac_nids[i]));
14599
14600 if (i == 2) {
14601 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014602 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14603 "Center Playback Volume",
14604 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14605 HDA_OUTPUT));
14606 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014607 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014608 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14609 "LFE Playback Volume",
14610 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14611 HDA_OUTPUT));
14612 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014613 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014614 err = add_control(spec, ALC_CTL_BIND_MUTE,
14615 "Center Playback Switch",
14616 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14617 HDA_INPUT));
14618 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014619 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014620 err = add_control(spec, ALC_CTL_BIND_MUTE,
14621 "LFE Playback Switch",
14622 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14623 HDA_INPUT));
14624 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014625 return err;
14626 } else {
14627 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014628 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14629 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14630 HDA_OUTPUT));
14631 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014632 return err;
14633 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014634 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014635 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014636 HDA_INPUT));
14637 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014638 return err;
14639 }
14640 }
14641 return 0;
14642}
14643
14644/* add playback controls for speaker and HP outputs */
14645/* Based on ALC880 version. But ALC861VD has separate,
14646 * different NIDs for mute/unmute switch and volume control */
14647static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14648 hda_nid_t pin, const char *pfx)
14649{
14650 hda_nid_t nid_v, nid_s;
14651 int err;
14652 char name[32];
14653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014654 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014655 return 0;
14656
14657 if (alc880_is_fixed_pin(pin)) {
14658 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14659 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014660 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014661 spec->multiout.hp_nid = nid_v;
14662 else
14663 spec->multiout.extra_out_nid[0] = nid_v;
14664 /* control HP volume/switch on the output mixer amp */
14665 nid_v = alc861vd_idx_to_mixer_vol(
14666 alc880_fixed_pin_idx(pin));
14667 nid_s = alc861vd_idx_to_mixer_switch(
14668 alc880_fixed_pin_idx(pin));
14669
14670 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014671 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14672 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14673 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014674 return err;
14675 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014676 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14677 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14678 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014679 return err;
14680 } else if (alc880_is_multi_pin(pin)) {
14681 /* set manual connection */
14682 /* we have only a switch on HP-out PIN */
14683 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014684 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14685 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14686 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014687 return err;
14688 }
14689 return 0;
14690}
14691
14692/* parse the BIOS configuration and set up the alc_spec
14693 * return 1 if successful, 0 if the proper config is not found,
14694 * or a negative error code
14695 * Based on ALC880 version - had to change it to override
14696 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14697static int alc861vd_parse_auto_config(struct hda_codec *codec)
14698{
14699 struct alc_spec *spec = codec->spec;
14700 int err;
14701 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14702
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014703 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14704 alc861vd_ignore);
14705 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014707 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014708 return 0; /* can't find valid BIOS pin config */
14709
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014710 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14711 if (err < 0)
14712 return err;
14713 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14714 if (err < 0)
14715 return err;
14716 err = alc861vd_auto_create_extra_out(spec,
14717 spec->autocfg.speaker_pins[0],
14718 "Speaker");
14719 if (err < 0)
14720 return err;
14721 err = alc861vd_auto_create_extra_out(spec,
14722 spec->autocfg.hp_pins[0],
14723 "Headphone");
14724 if (err < 0)
14725 return err;
14726 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14727 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014728 return err;
14729
14730 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14731
14732 if (spec->autocfg.dig_out_pin)
14733 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14734
Takashi Iwai603c4012008-07-30 15:01:44 +020014735 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014736 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014737
Takashi Iwaid88897e2008-10-31 15:01:37 +010014738 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014739
14740 spec->num_mux_defs = 1;
14741 spec->input_mux = &spec->private_imux;
14742
Takashi Iwai776e1842007-08-29 15:07:11 +020014743 err = alc_auto_add_mic_boost(codec);
14744 if (err < 0)
14745 return err;
14746
Takashi Iwaie044c392008-10-27 16:56:24 +010014747 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014748 return 1;
14749}
14750
14751/* additional initialization for auto-configuration model */
14752static void alc861vd_auto_init(struct hda_codec *codec)
14753{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014754 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014755 alc861vd_auto_init_multi_out(codec);
14756 alc861vd_auto_init_hp_out(codec);
14757 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014758 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014759 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014760 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014761}
14762
14763static int patch_alc861vd(struct hda_codec *codec)
14764{
14765 struct alc_spec *spec;
14766 int err, board_config;
14767
14768 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14769 if (spec == NULL)
14770 return -ENOMEM;
14771
14772 codec->spec = spec;
14773
14774 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14775 alc861vd_models,
14776 alc861vd_cfg_tbl);
14777
14778 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14779 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14780 "ALC861VD, trying auto-probe from BIOS...\n");
14781 board_config = ALC861VD_AUTO;
14782 }
14783
14784 if (board_config == ALC861VD_AUTO) {
14785 /* automatic parse from the BIOS config */
14786 err = alc861vd_parse_auto_config(codec);
14787 if (err < 0) {
14788 alc_free(codec);
14789 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014790 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 printk(KERN_INFO
14792 "hda_codec: Cannot set up configuration "
14793 "from BIOS. Using base mode...\n");
14794 board_config = ALC861VD_3ST;
14795 }
14796 }
14797
14798 if (board_config != ALC861VD_AUTO)
14799 setup_preset(spec, &alc861vd_presets[board_config]);
14800
Kailang Yang2f893282008-05-27 12:14:47 +020014801 if (codec->vendor_id == 0x10ec0660) {
14802 spec->stream_name_analog = "ALC660-VD Analog";
14803 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014804 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014805 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014806 } else {
14807 spec->stream_name_analog = "ALC861VD Analog";
14808 spec->stream_name_digital = "ALC861VD Digital";
14809 }
14810
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014811 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14812 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14813
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014814 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14815 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14816
14817 spec->adc_nids = alc861vd_adc_nids;
14818 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014819 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014820 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014821
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014822 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014823
Takashi Iwai2134ea42008-01-10 16:53:55 +010014824 spec->vmaster_nid = 0x02;
14825
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014826 codec->patch_ops = alc_patch_ops;
14827
14828 if (board_config == ALC861VD_AUTO)
14829 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014830#ifdef CONFIG_SND_HDA_POWER_SAVE
14831 if (!spec->loopback.amplist)
14832 spec->loopback.amplist = alc861vd_loopbacks;
14833#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014834 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014835
14836 return 0;
14837}
14838
14839/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014840 * ALC662 support
14841 *
14842 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14843 * configuration. Each pin widget can choose any input DACs and a mixer.
14844 * Each ADC is connected from a mixer of all inputs. This makes possible
14845 * 6-channel independent captures.
14846 *
14847 * In addition, an independent DAC for the multi-playback (not used in this
14848 * driver yet).
14849 */
14850#define ALC662_DIGOUT_NID 0x06
14851#define ALC662_DIGIN_NID 0x0a
14852
14853static hda_nid_t alc662_dac_nids[4] = {
14854 /* front, rear, clfe, rear_surr */
14855 0x02, 0x03, 0x04
14856};
14857
14858static hda_nid_t alc662_adc_nids[1] = {
14859 /* ADC1-2 */
14860 0x09,
14861};
Takashi Iwaie1406342008-02-11 18:32:32 +010014862
Kailang Yang77a261b2008-02-19 11:38:05 +010014863static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014864
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014865/* input MUX */
14866/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014867static struct hda_input_mux alc662_capture_source = {
14868 .num_items = 4,
14869 .items = {
14870 { "Mic", 0x0 },
14871 { "Front Mic", 0x1 },
14872 { "Line", 0x2 },
14873 { "CD", 0x4 },
14874 },
14875};
14876
14877static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14878 .num_items = 2,
14879 .items = {
14880 { "Mic", 0x1 },
14881 { "Line", 0x2 },
14882 },
14883};
Kailang Yang291702f2007-10-16 14:28:03 +020014884
14885static struct hda_input_mux alc662_eeepc_capture_source = {
14886 .num_items = 2,
14887 .items = {
14888 { "i-Mic", 0x1 },
14889 { "e-Mic", 0x0 },
14890 },
14891};
14892
Kailang Yang6dda9f42008-05-27 12:05:31 +020014893static struct hda_input_mux alc663_capture_source = {
14894 .num_items = 3,
14895 .items = {
14896 { "Mic", 0x0 },
14897 { "Front Mic", 0x1 },
14898 { "Line", 0x2 },
14899 },
14900};
14901
14902static struct hda_input_mux alc663_m51va_capture_source = {
14903 .num_items = 2,
14904 .items = {
14905 { "Ext-Mic", 0x0 },
14906 { "D-Mic", 0x9 },
14907 },
14908};
14909
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014910/*
14911 * 2ch mode
14912 */
14913static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14914 { 2, NULL }
14915};
14916
14917/*
14918 * 2ch mode
14919 */
14920static struct hda_verb alc662_3ST_ch2_init[] = {
14921 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14922 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14925 { } /* end */
14926};
14927
14928/*
14929 * 6ch mode
14930 */
14931static struct hda_verb alc662_3ST_ch6_init[] = {
14932 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14933 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14934 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14935 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14936 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14937 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14938 { } /* end */
14939};
14940
14941static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14942 { 2, alc662_3ST_ch2_init },
14943 { 6, alc662_3ST_ch6_init },
14944};
14945
14946/*
14947 * 2ch mode
14948 */
14949static struct hda_verb alc662_sixstack_ch6_init[] = {
14950 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14951 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14952 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14953 { } /* end */
14954};
14955
14956/*
14957 * 6ch mode
14958 */
14959static struct hda_verb alc662_sixstack_ch8_init[] = {
14960 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14961 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14962 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14963 { } /* end */
14964};
14965
14966static struct hda_channel_mode alc662_5stack_modes[2] = {
14967 { 2, alc662_sixstack_ch6_init },
14968 { 6, alc662_sixstack_ch8_init },
14969};
14970
14971/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14972 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14973 */
14974
14975static struct snd_kcontrol_new alc662_base_mixer[] = {
14976 /* output mixer control */
14977 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014978 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014980 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014981 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014983 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14984 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14986
14987 /*Input mixer control */
14988 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14989 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14990 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14991 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14992 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14993 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014996 { } /* end */
14997};
14998
14999static struct snd_kcontrol_new alc662_3ST_2ch_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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15003 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15004 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15009 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013 { } /* end */
15014};
15015
15016static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15017 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015018 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015019 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015020 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015021 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15022 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015023 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15024 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15026 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15027 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
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, 0x0, HDA_INPUT),
15031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15032 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15033 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15034 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15035 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015036 { } /* end */
15037};
15038
15039static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15040 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15041 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015042 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15043 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015049 { } /* end */
15050};
15051
Kailang Yang291702f2007-10-16 14:28:03 +020015052static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015053 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015054
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015055 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15056 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015057
15058 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15059 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15060 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15061
15062 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15063 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15064 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15065 { } /* end */
15066};
15067
Kailang Yang8c427222008-01-10 13:03:59 +010015068static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015069 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15070 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015071 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15072 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15073 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15074 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15075 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15076 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015077 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015078 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15079 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15080 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15083 { } /* end */
15084};
15085
Kailang Yangf1d4e282008-08-26 14:03:29 +020015086static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15087 .ops = &snd_hda_bind_vol,
15088 .values = {
15089 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15090 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15091 0
15092 },
15093};
15094
15095static struct hda_bind_ctls alc663_asus_one_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(0x21, 3, 0, HDA_OUTPUT),
15100 0
15101 },
15102};
15103
Kailang Yang6dda9f42008-05-27 12:05:31 +020015104static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015105 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15106 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15109 { } /* end */
15110};
15111
15112static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15113 .ops = &snd_hda_bind_sw,
15114 .values = {
15115 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15116 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15117 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15118 0
15119 },
15120};
15121
15122static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15123 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15124 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15127 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15128 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15129
15130 { } /* end */
15131};
15132
15133static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15134 .ops = &snd_hda_bind_sw,
15135 .values = {
15136 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15137 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15138 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15139 0
15140 },
15141};
15142
15143static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15144 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15145 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15148 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15149 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15150 { } /* end */
15151};
15152
15153static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015154 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15155 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15159 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15160 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15161 { } /* end */
15162};
15163
15164static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15165 .ops = &snd_hda_bind_vol,
15166 .values = {
15167 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15168 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15169 0
15170 },
15171};
15172
15173static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15174 .ops = &snd_hda_bind_sw,
15175 .values = {
15176 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15177 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15178 0
15179 },
15180};
15181
15182static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15183 HDA_BIND_VOL("Master Playback Volume",
15184 &alc663_asus_two_bind_master_vol),
15185 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15186 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015190 { } /* end */
15191};
15192
15193static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15194 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15195 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15196 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015200 { } /* end */
15201};
15202
15203static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15204 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15205 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15206 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15207 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15208 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15209
15210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15212 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15213 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15214 { } /* end */
15215};
15216
15217static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15221
15222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15224 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15225 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15228 { } /* end */
15229};
15230
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015231static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15232 {
15233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15234 .name = "Channel Mode",
15235 .info = alc_ch_mode_info,
15236 .get = alc_ch_mode_get,
15237 .put = alc_ch_mode_put,
15238 },
15239 { } /* end */
15240};
15241
15242static struct hda_verb alc662_init_verbs[] = {
15243 /* ADC: mute amp left and right */
15244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15245 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15246 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15247
Takashi Iwaicb53c622007-08-10 17:21:45 +020015248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015253
Kailang Yangb60dd392007-09-20 12:50:29 +020015254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15257 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15258 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015260
15261 /* Front Pin: output 0 (0x0c) */
15262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15264
15265 /* Rear Pin: output 1 (0x0d) */
15266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15268
15269 /* CLFE Pin: output 2 (0x0e) */
15270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15272
15273 /* Mic (rear) pin: input vref at 80% */
15274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15276 /* Front Mic pin: input vref at 80% */
15277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15279 /* Line In pin: input */
15280 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15281 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15282 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15285 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15286 /* CD pin widget for input */
15287 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15288
15289 /* FIXME: use matrix-type input source selection */
15290 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15291 /* Input mixer */
15292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015296
15297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015301
15302 /* always trun on EAPD */
15303 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15304 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15305
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015306 { }
15307};
15308
15309static struct hda_verb alc662_sue_init_verbs[] = {
15310 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15311 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015312 {}
15313};
15314
15315static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15316 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15318 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015319};
15320
Kailang Yang8c427222008-01-10 13:03:59 +010015321/* Set Unsolicited Event*/
15322static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15324 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15325 {}
15326};
15327
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015328/*
15329 * generic initialization of ADC, input mixers and output mixers
15330 */
15331static struct hda_verb alc662_auto_init_verbs[] = {
15332 /*
15333 * Unmute ADC and set the default input to mic-in
15334 */
15335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15337
15338 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15339 * mixer widget
15340 * Note: PASD motherboards uses the Line In 2 as the input for front
15341 * panel mic (mic 2)
15342 */
15343 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015349
15350 /*
15351 * Set up output mixers (0x0c - 0x0f)
15352 */
15353 /* set vol=0 to output mixers */
15354 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15355 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15356 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15357
15358 /* set up input amps for analog loopback */
15359 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015366
15367
15368 /* FIXME: use matrix-type input source selection */
15369 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15370 /* Input mixer */
15371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015373 { }
15374};
15375
Takashi Iwai24fb9172008-09-02 14:48:20 +020015376/* additional verbs for ALC663 */
15377static struct hda_verb alc663_auto_init_verbs[] = {
15378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15380 { }
15381};
15382
Kailang Yang6dda9f42008-05-27 12:05:31 +020015383static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015386 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15387 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015388 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015391 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15392 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15393 {}
15394};
15395
Kailang Yangf1d4e282008-08-26 14:03:29 +020015396static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15397 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15398 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15399 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15402 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15403 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15404 {}
15405};
15406
15407static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15408 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15411 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15414 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15415 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15416 {}
15417};
15418
15419static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15425 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15426 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15427 {}
15428};
15429
15430static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15432 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15433 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15434 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15440 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15441 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15442 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15443 {}
15444};
15445
15446static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15447 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15456 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15457 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15459 {}
15460};
15461
Kailang Yang6dda9f42008-05-27 12:05:31 +020015462static struct hda_verb alc663_g71v_init_verbs[] = {
15463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15464 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15465 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15466
15467 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15468 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15469 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15470
15471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15472 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15473 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15474 {}
15475};
15476
15477static struct hda_verb alc663_g50v_init_verbs[] = {
15478 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15479 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15480 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15481
15482 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15483 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15484 {}
15485};
15486
Kailang Yangf1d4e282008-08-26 14:03:29 +020015487static struct hda_verb alc662_ecs_init_verbs[] = {
15488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15490 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15492 {}
15493};
15494
Kailang Yangf1d4e282008-08-26 14:03:29 +020015495static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15496 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15497 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15498 { } /* end */
15499};
15500
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015501static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15502{
15503 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015504 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505
15506 present = snd_hda_codec_read(codec, 0x14, 0,
15507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015508 bits = present ? HDA_AMP_MUTE : 0;
15509 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15510 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015511}
15512
15513static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15514{
15515 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015516 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015517
15518 present = snd_hda_codec_read(codec, 0x1b, 0,
15519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015520 bits = present ? HDA_AMP_MUTE : 0;
15521 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15522 HDA_AMP_MUTE, bits);
15523 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15524 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015525}
15526
15527static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15528 unsigned int res)
15529{
15530 if ((res >> 26) == ALC880_HP_EVENT)
15531 alc662_lenovo_101e_all_automute(codec);
15532 if ((res >> 26) == ALC880_FRONT_EVENT)
15533 alc662_lenovo_101e_ispeaker_automute(codec);
15534}
15535
Kailang Yang291702f2007-10-16 14:28:03 +020015536static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15537{
15538 unsigned int present;
15539
15540 present = snd_hda_codec_read(codec, 0x18, 0,
15541 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15542 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15543 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15544 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15545 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15546 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15547 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15548 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15549 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15550}
15551
15552/* unsolicited event for HP jack sensing */
15553static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15554 unsigned int res)
15555{
15556 if ((res >> 26) == ALC880_HP_EVENT)
15557 alc262_hippo1_automute( codec );
15558
15559 if ((res >> 26) == ALC880_MIC_EVENT)
15560 alc662_eeepc_mic_automute(codec);
15561}
15562
15563static void alc662_eeepc_inithook(struct hda_codec *codec)
15564{
15565 alc262_hippo1_automute( codec );
15566 alc662_eeepc_mic_automute(codec);
15567}
15568
Kailang Yang8c427222008-01-10 13:03:59 +010015569static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15570{
15571 unsigned int mute;
15572 unsigned int present;
15573
15574 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15575 present = snd_hda_codec_read(codec, 0x14, 0,
15576 AC_VERB_GET_PIN_SENSE, 0);
15577 present = (present & 0x80000000) != 0;
15578 if (present) {
15579 /* mute internal speaker */
15580 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015581 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015582 } else {
15583 /* unmute internal speaker if necessary */
15584 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15585 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015586 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015587 }
15588}
15589
15590/* unsolicited event for HP jack sensing */
15591static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15592 unsigned int res)
15593{
15594 if ((res >> 26) == ALC880_HP_EVENT)
15595 alc662_eeepc_ep20_automute(codec);
15596}
15597
15598static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15599{
15600 alc662_eeepc_ep20_automute(codec);
15601}
15602
Kailang Yang6dda9f42008-05-27 12:05:31 +020015603static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15604{
15605 unsigned int present;
15606 unsigned char bits;
15607
15608 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015609 AC_VERB_GET_PIN_SENSE, 0)
15610 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015611 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015612 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15613 AMP_IN_MUTE(0), bits);
15614 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15615 AMP_IN_MUTE(0), bits);
15616}
15617
15618static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15619{
15620 unsigned int present;
15621 unsigned char bits;
15622
15623 present = snd_hda_codec_read(codec, 0x21, 0,
15624 AC_VERB_GET_PIN_SENSE, 0)
15625 & AC_PINSENSE_PRESENCE;
15626 bits = present ? HDA_AMP_MUTE : 0;
15627 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15628 AMP_IN_MUTE(0), bits);
15629 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15630 AMP_IN_MUTE(0), bits);
15631 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15632 AMP_IN_MUTE(0), bits);
15633 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15634 AMP_IN_MUTE(0), bits);
15635}
15636
15637static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15638{
15639 unsigned int present;
15640 unsigned char bits;
15641
15642 present = snd_hda_codec_read(codec, 0x15, 0,
15643 AC_VERB_GET_PIN_SENSE, 0)
15644 & AC_PINSENSE_PRESENCE;
15645 bits = present ? HDA_AMP_MUTE : 0;
15646 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15647 AMP_IN_MUTE(0), bits);
15648 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15649 AMP_IN_MUTE(0), bits);
15650 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15651 AMP_IN_MUTE(0), bits);
15652 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15653 AMP_IN_MUTE(0), bits);
15654}
15655
15656static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15657{
15658 unsigned int present;
15659 unsigned char bits;
15660
15661 present = snd_hda_codec_read(codec, 0x1b, 0,
15662 AC_VERB_GET_PIN_SENSE, 0)
15663 & AC_PINSENSE_PRESENCE;
15664 bits = present ? 0 : PIN_OUT;
15665 snd_hda_codec_write(codec, 0x14, 0,
15666 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15667}
15668
15669static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15670{
15671 unsigned int present1, present2;
15672
15673 present1 = snd_hda_codec_read(codec, 0x21, 0,
15674 AC_VERB_GET_PIN_SENSE, 0)
15675 & AC_PINSENSE_PRESENCE;
15676 present2 = snd_hda_codec_read(codec, 0x15, 0,
15677 AC_VERB_GET_PIN_SENSE, 0)
15678 & AC_PINSENSE_PRESENCE;
15679
15680 if (present1 || present2) {
15681 snd_hda_codec_write_cache(codec, 0x14, 0,
15682 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15683 } else {
15684 snd_hda_codec_write_cache(codec, 0x14, 0,
15685 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15686 }
15687}
15688
15689static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15690{
15691 unsigned int present1, present2;
15692
15693 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15694 AC_VERB_GET_PIN_SENSE, 0)
15695 & AC_PINSENSE_PRESENCE;
15696 present2 = snd_hda_codec_read(codec, 0x15, 0,
15697 AC_VERB_GET_PIN_SENSE, 0)
15698 & AC_PINSENSE_PRESENCE;
15699
15700 if (present1 || present2) {
15701 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15702 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15703 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15704 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15705 } else {
15706 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15707 AMP_IN_MUTE(0), 0);
15708 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15709 AMP_IN_MUTE(0), 0);
15710 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015711}
15712
15713static void alc663_m51va_mic_automute(struct hda_codec *codec)
15714{
15715 unsigned int present;
15716
15717 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015718 AC_VERB_GET_PIN_SENSE, 0)
15719 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015720 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015721 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015722 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015723 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015724 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015725 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015726 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015727 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015728}
15729
15730static void alc663_m51va_unsol_event(struct hda_codec *codec,
15731 unsigned int res)
15732{
15733 switch (res >> 26) {
15734 case ALC880_HP_EVENT:
15735 alc663_m51va_speaker_automute(codec);
15736 break;
15737 case ALC880_MIC_EVENT:
15738 alc663_m51va_mic_automute(codec);
15739 break;
15740 }
15741}
15742
15743static void alc663_m51va_inithook(struct hda_codec *codec)
15744{
15745 alc663_m51va_speaker_automute(codec);
15746 alc663_m51va_mic_automute(codec);
15747}
15748
Kailang Yangf1d4e282008-08-26 14:03:29 +020015749/* ***************** Mode1 ******************************/
15750static void alc663_mode1_unsol_event(struct hda_codec *codec,
15751 unsigned int res)
15752{
15753 switch (res >> 26) {
15754 case ALC880_HP_EVENT:
15755 alc663_m51va_speaker_automute(codec);
15756 break;
15757 case ALC880_MIC_EVENT:
15758 alc662_eeepc_mic_automute(codec);
15759 break;
15760 }
15761}
15762
15763static void alc663_mode1_inithook(struct hda_codec *codec)
15764{
15765 alc663_m51va_speaker_automute(codec);
15766 alc662_eeepc_mic_automute(codec);
15767}
15768/* ***************** Mode2 ******************************/
15769static void alc662_mode2_unsol_event(struct hda_codec *codec,
15770 unsigned int res)
15771{
15772 switch (res >> 26) {
15773 case ALC880_HP_EVENT:
15774 alc662_f5z_speaker_automute(codec);
15775 break;
15776 case ALC880_MIC_EVENT:
15777 alc662_eeepc_mic_automute(codec);
15778 break;
15779 }
15780}
15781
15782static void alc662_mode2_inithook(struct hda_codec *codec)
15783{
15784 alc662_f5z_speaker_automute(codec);
15785 alc662_eeepc_mic_automute(codec);
15786}
15787/* ***************** Mode3 ******************************/
15788static void alc663_mode3_unsol_event(struct hda_codec *codec,
15789 unsigned int res)
15790{
15791 switch (res >> 26) {
15792 case ALC880_HP_EVENT:
15793 alc663_two_hp_m1_speaker_automute(codec);
15794 break;
15795 case ALC880_MIC_EVENT:
15796 alc662_eeepc_mic_automute(codec);
15797 break;
15798 }
15799}
15800
15801static void alc663_mode3_inithook(struct hda_codec *codec)
15802{
15803 alc663_two_hp_m1_speaker_automute(codec);
15804 alc662_eeepc_mic_automute(codec);
15805}
15806/* ***************** Mode4 ******************************/
15807static void alc663_mode4_unsol_event(struct hda_codec *codec,
15808 unsigned int res)
15809{
15810 switch (res >> 26) {
15811 case ALC880_HP_EVENT:
15812 alc663_21jd_two_speaker_automute(codec);
15813 break;
15814 case ALC880_MIC_EVENT:
15815 alc662_eeepc_mic_automute(codec);
15816 break;
15817 }
15818}
15819
15820static void alc663_mode4_inithook(struct hda_codec *codec)
15821{
15822 alc663_21jd_two_speaker_automute(codec);
15823 alc662_eeepc_mic_automute(codec);
15824}
15825/* ***************** Mode5 ******************************/
15826static void alc663_mode5_unsol_event(struct hda_codec *codec,
15827 unsigned int res)
15828{
15829 switch (res >> 26) {
15830 case ALC880_HP_EVENT:
15831 alc663_15jd_two_speaker_automute(codec);
15832 break;
15833 case ALC880_MIC_EVENT:
15834 alc662_eeepc_mic_automute(codec);
15835 break;
15836 }
15837}
15838
15839static void alc663_mode5_inithook(struct hda_codec *codec)
15840{
15841 alc663_15jd_two_speaker_automute(codec);
15842 alc662_eeepc_mic_automute(codec);
15843}
15844/* ***************** Mode6 ******************************/
15845static void alc663_mode6_unsol_event(struct hda_codec *codec,
15846 unsigned int res)
15847{
15848 switch (res >> 26) {
15849 case ALC880_HP_EVENT:
15850 alc663_two_hp_m2_speaker_automute(codec);
15851 break;
15852 case ALC880_MIC_EVENT:
15853 alc662_eeepc_mic_automute(codec);
15854 break;
15855 }
15856}
15857
15858static void alc663_mode6_inithook(struct hda_codec *codec)
15859{
15860 alc663_two_hp_m2_speaker_automute(codec);
15861 alc662_eeepc_mic_automute(codec);
15862}
15863
Kailang Yang6dda9f42008-05-27 12:05:31 +020015864static void alc663_g71v_hp_automute(struct hda_codec *codec)
15865{
15866 unsigned int present;
15867 unsigned char bits;
15868
15869 present = snd_hda_codec_read(codec, 0x21, 0,
15870 AC_VERB_GET_PIN_SENSE, 0)
15871 & AC_PINSENSE_PRESENCE;
15872 bits = present ? HDA_AMP_MUTE : 0;
15873 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15874 HDA_AMP_MUTE, bits);
15875 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15876 HDA_AMP_MUTE, bits);
15877}
15878
15879static void alc663_g71v_front_automute(struct hda_codec *codec)
15880{
15881 unsigned int present;
15882 unsigned char bits;
15883
15884 present = snd_hda_codec_read(codec, 0x15, 0,
15885 AC_VERB_GET_PIN_SENSE, 0)
15886 & AC_PINSENSE_PRESENCE;
15887 bits = present ? HDA_AMP_MUTE : 0;
15888 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15889 HDA_AMP_MUTE, bits);
15890}
15891
15892static void alc663_g71v_unsol_event(struct hda_codec *codec,
15893 unsigned int res)
15894{
15895 switch (res >> 26) {
15896 case ALC880_HP_EVENT:
15897 alc663_g71v_hp_automute(codec);
15898 break;
15899 case ALC880_FRONT_EVENT:
15900 alc663_g71v_front_automute(codec);
15901 break;
15902 case ALC880_MIC_EVENT:
15903 alc662_eeepc_mic_automute(codec);
15904 break;
15905 }
15906}
15907
15908static void alc663_g71v_inithook(struct hda_codec *codec)
15909{
15910 alc663_g71v_front_automute(codec);
15911 alc663_g71v_hp_automute(codec);
15912 alc662_eeepc_mic_automute(codec);
15913}
15914
15915static void alc663_g50v_unsol_event(struct hda_codec *codec,
15916 unsigned int res)
15917{
15918 switch (res >> 26) {
15919 case ALC880_HP_EVENT:
15920 alc663_m51va_speaker_automute(codec);
15921 break;
15922 case ALC880_MIC_EVENT:
15923 alc662_eeepc_mic_automute(codec);
15924 break;
15925 }
15926}
15927
15928static void alc663_g50v_inithook(struct hda_codec *codec)
15929{
15930 alc663_m51va_speaker_automute(codec);
15931 alc662_eeepc_mic_automute(codec);
15932}
15933
Kailang Yangf1d4e282008-08-26 14:03:29 +020015934/* bind hp and internal speaker mute (with plug check) */
15935static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15936 struct snd_ctl_elem_value *ucontrol)
15937{
15938 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15939 long *valp = ucontrol->value.integer.value;
15940 int change;
15941
15942 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15943 HDA_AMP_MUTE,
15944 valp[0] ? 0 : HDA_AMP_MUTE);
15945 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15946 HDA_AMP_MUTE,
15947 valp[1] ? 0 : HDA_AMP_MUTE);
15948 if (change)
15949 alc262_hippo1_automute(codec);
15950 return change;
15951}
15952
15953static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15954 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15955 {
15956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15957 .name = "Master Playback Switch",
15958 .info = snd_hda_mixer_amp_switch_info,
15959 .get = snd_hda_mixer_amp_switch_get,
15960 .put = alc662_ecs_master_sw_put,
15961 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15962 },
15963
15964 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15965 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15966 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15967
15968 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15969 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15970 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15971 { } /* end */
15972};
15973
Takashi Iwaicb53c622007-08-10 17:21:45 +020015974#ifdef CONFIG_SND_HDA_POWER_SAVE
15975#define alc662_loopbacks alc880_loopbacks
15976#endif
15977
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015978
15979/* pcm configuration: identiacal with ALC880 */
15980#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15981#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15982#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15983#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15984
15985/*
15986 * configuration and preset
15987 */
15988static const char *alc662_models[ALC662_MODEL_LAST] = {
15989 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15990 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15991 [ALC662_3ST_6ch] = "3stack-6ch",
15992 [ALC662_5ST_DIG] = "6stack-dig",
15993 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015994 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015995 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015996 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015997 [ALC663_ASUS_M51VA] = "m51va",
15998 [ALC663_ASUS_G71V] = "g71v",
15999 [ALC663_ASUS_H13] = "h13",
16000 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016001 [ALC663_ASUS_MODE1] = "asus-mode1",
16002 [ALC662_ASUS_MODE2] = "asus-mode2",
16003 [ALC663_ASUS_MODE3] = "asus-mode3",
16004 [ALC663_ASUS_MODE4] = "asus-mode4",
16005 [ALC663_ASUS_MODE5] = "asus-mode5",
16006 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016007 [ALC662_AUTO] = "auto",
16008};
16009
16010static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016011 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020016012 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016013 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016014 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016015 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016016 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16017 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
16018 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16019 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16020 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16021 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
16022 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16023 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16024 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016025 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016026 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16027 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16028 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16029 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16030 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16031 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16032 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16033 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16034 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16035 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16036 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16037 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16038 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16039 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16040 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16041 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16042 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16043 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16044 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16045 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16046 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16047 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016048 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16049 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016050 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016051 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16052 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016053 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16054 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016055 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020016056 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016057 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016058 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
16059 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
16060 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016061 {}
16062};
16063
16064static struct alc_config_preset alc662_presets[] = {
16065 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016066 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016067 .init_verbs = { alc662_init_verbs },
16068 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16069 .dac_nids = alc662_dac_nids,
16070 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071 .dig_in_nid = ALC662_DIGIN_NID,
16072 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16073 .channel_mode = alc662_3ST_2ch_modes,
16074 .input_mux = &alc662_capture_source,
16075 },
16076 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016077 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016078 .init_verbs = { alc662_init_verbs },
16079 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16080 .dac_nids = alc662_dac_nids,
16081 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016082 .dig_in_nid = ALC662_DIGIN_NID,
16083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16084 .channel_mode = alc662_3ST_6ch_modes,
16085 .need_dac_fix = 1,
16086 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016087 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016088 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016089 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016090 .init_verbs = { alc662_init_verbs },
16091 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16092 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016093 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16094 .channel_mode = alc662_3ST_6ch_modes,
16095 .need_dac_fix = 1,
16096 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016097 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016098 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016099 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016100 .init_verbs = { alc662_init_verbs },
16101 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16102 .dac_nids = alc662_dac_nids,
16103 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016104 .dig_in_nid = ALC662_DIGIN_NID,
16105 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16106 .channel_mode = alc662_5stack_modes,
16107 .input_mux = &alc662_capture_source,
16108 },
16109 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016110 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016111 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16112 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16113 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016114 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16115 .channel_mode = alc662_3ST_2ch_modes,
16116 .input_mux = &alc662_lenovo_101e_capture_source,
16117 .unsol_event = alc662_lenovo_101e_unsol_event,
16118 .init_hook = alc662_lenovo_101e_all_automute,
16119 },
Kailang Yang291702f2007-10-16 14:28:03 +020016120 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016121 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016122 .init_verbs = { alc662_init_verbs,
16123 alc662_eeepc_sue_init_verbs },
16124 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16125 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016126 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16127 .channel_mode = alc662_3ST_2ch_modes,
16128 .input_mux = &alc662_eeepc_capture_source,
16129 .unsol_event = alc662_eeepc_unsol_event,
16130 .init_hook = alc662_eeepc_inithook,
16131 },
Kailang Yang8c427222008-01-10 13:03:59 +010016132 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016133 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016134 alc662_chmode_mixer },
16135 .init_verbs = { alc662_init_verbs,
16136 alc662_eeepc_ep20_sue_init_verbs },
16137 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16138 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016139 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16140 .channel_mode = alc662_3ST_6ch_modes,
16141 .input_mux = &alc662_lenovo_101e_capture_source,
16142 .unsol_event = alc662_eeepc_ep20_unsol_event,
16143 .init_hook = alc662_eeepc_ep20_inithook,
16144 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016145 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016146 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016147 .init_verbs = { alc662_init_verbs,
16148 alc662_ecs_init_verbs },
16149 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16150 .dac_nids = alc662_dac_nids,
16151 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16152 .channel_mode = alc662_3ST_2ch_modes,
16153 .input_mux = &alc662_eeepc_capture_source,
16154 .unsol_event = alc662_eeepc_unsol_event,
16155 .init_hook = alc662_eeepc_inithook,
16156 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016157 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016158 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016159 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16160 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16161 .dac_nids = alc662_dac_nids,
16162 .dig_out_nid = ALC662_DIGOUT_NID,
16163 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16164 .channel_mode = alc662_3ST_2ch_modes,
16165 .input_mux = &alc663_m51va_capture_source,
16166 .unsol_event = alc663_m51va_unsol_event,
16167 .init_hook = alc663_m51va_inithook,
16168 },
16169 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016170 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016171 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16172 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16173 .dac_nids = alc662_dac_nids,
16174 .dig_out_nid = ALC662_DIGOUT_NID,
16175 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16176 .channel_mode = alc662_3ST_2ch_modes,
16177 .input_mux = &alc662_eeepc_capture_source,
16178 .unsol_event = alc663_g71v_unsol_event,
16179 .init_hook = alc663_g71v_inithook,
16180 },
16181 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016182 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016183 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16184 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16185 .dac_nids = alc662_dac_nids,
16186 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16187 .channel_mode = alc662_3ST_2ch_modes,
16188 .input_mux = &alc663_m51va_capture_source,
16189 .unsol_event = alc663_m51va_unsol_event,
16190 .init_hook = alc663_m51va_inithook,
16191 },
16192 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016193 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016194 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16195 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16196 .dac_nids = alc662_dac_nids,
16197 .dig_out_nid = ALC662_DIGOUT_NID,
16198 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16199 .channel_mode = alc662_3ST_6ch_modes,
16200 .input_mux = &alc663_capture_source,
16201 .unsol_event = alc663_g50v_unsol_event,
16202 .init_hook = alc663_g50v_inithook,
16203 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016204 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016205 .mixers = { alc663_m51va_mixer },
16206 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016207 .init_verbs = { alc662_init_verbs,
16208 alc663_21jd_amic_init_verbs },
16209 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16210 .hp_nid = 0x03,
16211 .dac_nids = alc662_dac_nids,
16212 .dig_out_nid = ALC662_DIGOUT_NID,
16213 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16214 .channel_mode = alc662_3ST_2ch_modes,
16215 .input_mux = &alc662_eeepc_capture_source,
16216 .unsol_event = alc663_mode1_unsol_event,
16217 .init_hook = alc663_mode1_inithook,
16218 },
16219 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016220 .mixers = { alc662_1bjd_mixer },
16221 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016222 .init_verbs = { alc662_init_verbs,
16223 alc662_1bjd_amic_init_verbs },
16224 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16225 .dac_nids = alc662_dac_nids,
16226 .dig_out_nid = ALC662_DIGOUT_NID,
16227 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16228 .channel_mode = alc662_3ST_2ch_modes,
16229 .input_mux = &alc662_eeepc_capture_source,
16230 .unsol_event = alc662_mode2_unsol_event,
16231 .init_hook = alc662_mode2_inithook,
16232 },
16233 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016234 .mixers = { alc663_two_hp_m1_mixer },
16235 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016236 .init_verbs = { alc662_init_verbs,
16237 alc663_two_hp_amic_m1_init_verbs },
16238 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16239 .hp_nid = 0x03,
16240 .dac_nids = alc662_dac_nids,
16241 .dig_out_nid = ALC662_DIGOUT_NID,
16242 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16243 .channel_mode = alc662_3ST_2ch_modes,
16244 .input_mux = &alc662_eeepc_capture_source,
16245 .unsol_event = alc663_mode3_unsol_event,
16246 .init_hook = alc663_mode3_inithook,
16247 },
16248 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016249 .mixers = { alc663_asus_21jd_clfe_mixer },
16250 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016251 .init_verbs = { alc662_init_verbs,
16252 alc663_21jd_amic_init_verbs},
16253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16254 .hp_nid = 0x03,
16255 .dac_nids = alc662_dac_nids,
16256 .dig_out_nid = ALC662_DIGOUT_NID,
16257 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16258 .channel_mode = alc662_3ST_2ch_modes,
16259 .input_mux = &alc662_eeepc_capture_source,
16260 .unsol_event = alc663_mode4_unsol_event,
16261 .init_hook = alc663_mode4_inithook,
16262 },
16263 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016264 .mixers = { alc663_asus_15jd_clfe_mixer },
16265 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016266 .init_verbs = { alc662_init_verbs,
16267 alc663_15jd_amic_init_verbs },
16268 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16269 .hp_nid = 0x03,
16270 .dac_nids = alc662_dac_nids,
16271 .dig_out_nid = ALC662_DIGOUT_NID,
16272 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16273 .channel_mode = alc662_3ST_2ch_modes,
16274 .input_mux = &alc662_eeepc_capture_source,
16275 .unsol_event = alc663_mode5_unsol_event,
16276 .init_hook = alc663_mode5_inithook,
16277 },
16278 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016279 .mixers = { alc663_two_hp_m2_mixer },
16280 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016281 .init_verbs = { alc662_init_verbs,
16282 alc663_two_hp_amic_m2_init_verbs },
16283 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16284 .hp_nid = 0x03,
16285 .dac_nids = alc662_dac_nids,
16286 .dig_out_nid = ALC662_DIGOUT_NID,
16287 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16288 .channel_mode = alc662_3ST_2ch_modes,
16289 .input_mux = &alc662_eeepc_capture_source,
16290 .unsol_event = alc663_mode6_unsol_event,
16291 .init_hook = alc663_mode6_inithook,
16292 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016293};
16294
16295
16296/*
16297 * BIOS auto configuration
16298 */
16299
16300/* add playback controls from the parsed DAC table */
16301static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16302 const struct auto_pin_cfg *cfg)
16303{
16304 char name[32];
16305 static const char *chname[4] = {
16306 "Front", "Surround", NULL /*CLFE*/, "Side"
16307 };
16308 hda_nid_t nid;
16309 int i, err;
16310
16311 for (i = 0; i < cfg->line_outs; i++) {
16312 if (!spec->multiout.dac_nids[i])
16313 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016314 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315 if (i == 2) {
16316 /* Center/LFE */
16317 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16318 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016319 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16320 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321 if (err < 0)
16322 return err;
16323 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16324 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016325 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16326 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016327 if (err < 0)
16328 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016329 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016330 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016331 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016332 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016333 if (err < 0)
16334 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016335 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016336 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016337 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016338 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016339 if (err < 0)
16340 return err;
16341 } else {
16342 sprintf(name, "%s Playback Volume", chname[i]);
16343 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016344 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16345 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016346 if (err < 0)
16347 return err;
16348 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016349 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16350 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16351 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016352 if (err < 0)
16353 return err;
16354 }
16355 }
16356 return 0;
16357}
16358
16359/* add playback controls for speaker and HP outputs */
16360static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16361 const char *pfx)
16362{
16363 hda_nid_t nid;
16364 int err;
16365 char name[32];
16366
16367 if (!pin)
16368 return 0;
16369
Takashi Iwai24fb9172008-09-02 14:48:20 +020016370 if (pin == 0x17) {
16371 /* ALC663 has a mono output pin on 0x17 */
16372 sprintf(name, "%s Playback Switch", pfx);
16373 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16374 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16375 return err;
16376 }
16377
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016378 if (alc880_is_fixed_pin(pin)) {
16379 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16380 /* printk("DAC nid=%x\n",nid); */
16381 /* specify the DAC as the extra output */
16382 if (!spec->multiout.hp_nid)
16383 spec->multiout.hp_nid = nid;
16384 else
16385 spec->multiout.extra_out_nid[0] = nid;
16386 /* control HP volume/switch on the output mixer amp */
16387 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16388 sprintf(name, "%s Playback Volume", pfx);
16389 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16391 if (err < 0)
16392 return err;
16393 sprintf(name, "%s Playback Switch", pfx);
16394 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16395 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16396 if (err < 0)
16397 return err;
16398 } else if (alc880_is_multi_pin(pin)) {
16399 /* set manual connection */
16400 /* we have only a switch on HP-out PIN */
16401 sprintf(name, "%s Playback Switch", pfx);
16402 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16403 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16404 if (err < 0)
16405 return err;
16406 }
16407 return 0;
16408}
16409
16410/* create playback/capture controls for input pins */
16411static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16412 const struct auto_pin_cfg *cfg)
16413{
16414 struct hda_input_mux *imux = &spec->private_imux;
16415 int i, err, idx;
16416
16417 for (i = 0; i < AUTO_PIN_LAST; i++) {
16418 if (alc880_is_input_pin(cfg->input_pins[i])) {
16419 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16420 err = new_analog_input(spec, cfg->input_pins[i],
16421 auto_pin_cfg_labels[i],
16422 idx, 0x0b);
16423 if (err < 0)
16424 return err;
16425 imux->items[imux->num_items].label =
16426 auto_pin_cfg_labels[i];
16427 imux->items[imux->num_items].index =
16428 alc880_input_pin_idx(cfg->input_pins[i]);
16429 imux->num_items++;
16430 }
16431 }
16432 return 0;
16433}
16434
16435static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16436 hda_nid_t nid, int pin_type,
16437 int dac_idx)
16438{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016439 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016440 /* need the manual connection? */
16441 if (alc880_is_multi_pin(nid)) {
16442 struct alc_spec *spec = codec->spec;
16443 int idx = alc880_multi_pin_idx(nid);
16444 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16445 AC_VERB_SET_CONNECT_SEL,
16446 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16447 }
16448}
16449
16450static void alc662_auto_init_multi_out(struct hda_codec *codec)
16451{
16452 struct alc_spec *spec = codec->spec;
16453 int i;
16454
Kailang Yang8c427222008-01-10 13:03:59 +010016455 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016456 for (i = 0; i <= HDA_SIDE; i++) {
16457 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016458 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016459 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016460 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016461 i);
16462 }
16463}
16464
16465static void alc662_auto_init_hp_out(struct hda_codec *codec)
16466{
16467 struct alc_spec *spec = codec->spec;
16468 hda_nid_t pin;
16469
16470 pin = spec->autocfg.hp_pins[0];
16471 if (pin) /* connect to front */
16472 /* use dac 0 */
16473 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016474 pin = spec->autocfg.speaker_pins[0];
16475 if (pin)
16476 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016477}
16478
16479#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16480#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16481
16482static void alc662_auto_init_analog_input(struct hda_codec *codec)
16483{
16484 struct alc_spec *spec = codec->spec;
16485 int i;
16486
16487 for (i = 0; i < AUTO_PIN_LAST; i++) {
16488 hda_nid_t nid = spec->autocfg.input_pins[i];
16489 if (alc662_is_input_pin(nid)) {
16490 snd_hda_codec_write(codec, nid, 0,
16491 AC_VERB_SET_PIN_WIDGET_CONTROL,
16492 (i <= AUTO_PIN_FRONT_MIC ?
16493 PIN_VREF80 : PIN_IN));
16494 if (nid != ALC662_PIN_CD_NID)
16495 snd_hda_codec_write(codec, nid, 0,
16496 AC_VERB_SET_AMP_GAIN_MUTE,
16497 AMP_OUT_MUTE);
16498 }
16499 }
16500}
16501
Takashi Iwaif511b012008-08-15 16:46:42 +020016502#define alc662_auto_init_input_src alc882_auto_init_input_src
16503
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016504static int alc662_parse_auto_config(struct hda_codec *codec)
16505{
16506 struct alc_spec *spec = codec->spec;
16507 int err;
16508 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16509
16510 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16511 alc662_ignore);
16512 if (err < 0)
16513 return err;
16514 if (!spec->autocfg.line_outs)
16515 return 0; /* can't find valid BIOS pin config */
16516
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016517 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16518 if (err < 0)
16519 return err;
16520 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16521 if (err < 0)
16522 return err;
16523 err = alc662_auto_create_extra_out(spec,
16524 spec->autocfg.speaker_pins[0],
16525 "Speaker");
16526 if (err < 0)
16527 return err;
16528 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16529 "Headphone");
16530 if (err < 0)
16531 return err;
16532 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16533 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016534 return err;
16535
16536 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16537
16538 if (spec->autocfg.dig_out_pin)
16539 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16540
Takashi Iwai603c4012008-07-30 15:01:44 +020016541 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016542 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016543
16544 spec->num_mux_defs = 1;
16545 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016546
Takashi Iwaid88897e2008-10-31 15:01:37 +010016547 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016548 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016549 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016550
16551 err = alc_auto_add_mic_boost(codec);
16552 if (err < 0)
16553 return err;
16554
Takashi Iwaie044c392008-10-27 16:56:24 +010016555 store_pin_configs(codec);
Takashi Iwai8c872862007-06-19 12:11:16 +020016556 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016557}
16558
16559/* additional initialization for auto-configuration model */
16560static void alc662_auto_init(struct hda_codec *codec)
16561{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016562 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016563 alc662_auto_init_multi_out(codec);
16564 alc662_auto_init_hp_out(codec);
16565 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016566 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016567 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016568 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016569}
16570
16571static int patch_alc662(struct hda_codec *codec)
16572{
16573 struct alc_spec *spec;
16574 int err, board_config;
16575
16576 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16577 if (!spec)
16578 return -ENOMEM;
16579
16580 codec->spec = spec;
16581
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016582 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16583
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016584 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16585 alc662_models,
16586 alc662_cfg_tbl);
16587 if (board_config < 0) {
16588 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16589 "trying auto-probe from BIOS...\n");
16590 board_config = ALC662_AUTO;
16591 }
16592
16593 if (board_config == ALC662_AUTO) {
16594 /* automatic parse from the BIOS config */
16595 err = alc662_parse_auto_config(codec);
16596 if (err < 0) {
16597 alc_free(codec);
16598 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020016599 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600 printk(KERN_INFO
16601 "hda_codec: Cannot set up configuration "
16602 "from BIOS. Using base mode...\n");
16603 board_config = ALC662_3ST_2ch_DIG;
16604 }
16605 }
16606
16607 if (board_config != ALC662_AUTO)
16608 setup_preset(spec, &alc662_presets[board_config]);
16609
Kailang Yang6dda9f42008-05-27 12:05:31 +020016610 if (codec->vendor_id == 0x10ec0663) {
16611 spec->stream_name_analog = "ALC663 Analog";
16612 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016613 } else if (codec->vendor_id == 0x10ec0272) {
16614 spec->stream_name_analog = "ALC272 Analog";
16615 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016616 } else {
16617 spec->stream_name_analog = "ALC662 Analog";
16618 spec->stream_name_digital = "ALC662 Digital";
16619 }
16620
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016621 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16622 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16623
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016624 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16625 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16626
Takashi Iwaie1406342008-02-11 18:32:32 +010016627 spec->adc_nids = alc662_adc_nids;
16628 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16629 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016630 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016631
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016632 if (!spec->cap_mixer)
16633 set_capture_mixer(spec);
16634
Takashi Iwai2134ea42008-01-10 16:53:55 +010016635 spec->vmaster_nid = 0x02;
16636
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016637 codec->patch_ops = alc_patch_ops;
16638 if (board_config == ALC662_AUTO)
16639 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016640#ifdef CONFIG_SND_HDA_POWER_SAVE
16641 if (!spec->loopback.amplist)
16642 spec->loopback.amplist = alc662_loopbacks;
16643#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016644 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016645
16646 return 0;
16647}
16648
16649/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016650 * patch entries
16651 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016652static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016653 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016654 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016655 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016656 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016657 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016658 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016659 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016660 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016661 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16662 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16663 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016664 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16665 .patch = patch_alc883 },
16666 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16667 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016668 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016669 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016670 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016671 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016672 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16673 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016674 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016675 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016676 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016677 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016678 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16679 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016680 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016681 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016682 {} /* terminator */
16683};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016684
16685MODULE_ALIAS("snd-hda-codec-id:10ec*");
16686
16687MODULE_LICENSE("GPL");
16688MODULE_DESCRIPTION("Realtek HD-audio codec");
16689
16690static struct hda_codec_preset_list realtek_list = {
16691 .preset = snd_hda_preset_realtek,
16692 .owner = THIS_MODULE,
16693};
16694
16695static int __init patch_realtek_init(void)
16696{
16697 return snd_hda_add_codec_preset(&realtek_list);
16698}
16699
16700static void __exit patch_realtek_exit(void)
16701{
16702 snd_hda_delete_codec_preset(&realtek_list);
16703}
16704
16705module_init(patch_realtek_init)
16706module_exit(patch_realtek_exit)