blob: 82097790f6f322a62e83b757e53451a0684b96f7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200191 ALC662_AUTO,
192 ALC662_MODEL_LAST,
193};
194
Kailang Yangdf694da2005-12-05 19:42:22 +0100195/* ALC882 models */
196enum {
197 ALC882_3ST_DIG,
198 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200199 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200200 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200201 ALC882_TARGA,
202 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200203 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100204 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200205 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200206 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200207 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100208 ALC882_MODEL_LAST,
209};
210
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211/* ALC883 models */
212enum {
213 ALC883_3ST_2ch_DIG,
214 ALC883_3ST_6ch_DIG,
215 ALC883_3ST_6ch,
216 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200217 ALC883_TARGA_DIG,
218 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200219 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200220 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800221 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200222 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200223 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100224 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200225 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200226 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200227 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200228 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200229 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200230 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100231 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100232 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100233 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100234 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800235 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200236 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_ASUS_M90V,
238 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100239 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200240 ALC883_AUTO,
241 ALC883_MODEL_LAST,
242};
243
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200244/* styles of capture selection */
245enum {
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
249};
250
Kailang Yangdf694da2005-12-05 19:42:22 +0100251/* for GPIO Poll */
252#define GPIO_MASK 0x03
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254struct alc_spec {
255 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200262 * don't forget NULL
263 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200264 */
265 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 struct hda_pcm_stream *stream_analog_playback;
269 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100270 struct hda_pcm_stream *stream_analog_alt_playback;
271 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200273 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 struct hda_pcm_stream *stream_digital_playback;
275 struct hda_pcm_stream *stream_digital_capture;
276
277 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200278 struct hda_multi_out multiout; /* playback set-up
279 * max_channels, dacs must be set
280 * dig_out_nid and hp_nid are optional
281 */
Takashi Iwai63300792008-01-24 15:31:36 +0100282 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100284 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* capture */
287 unsigned int num_adc_nids;
288 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100289 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200291 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200294 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 const struct hda_input_mux *input_mux;
296 unsigned int cur_mux[3];
297
298 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100299 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200301 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100304 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200305
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200306 /* dynamic controls, init_verbs and input_mux */
307 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200308 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200309 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100311
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100312 /* hooks */
313 void (*init_hook)(struct hda_codec *codec);
314 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
315
Takashi Iwai834be882006-03-01 14:16:17 +0100316 /* for pin sensing */
317 unsigned int sense_updated: 1;
318 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100319 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200320
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100321 /* other flags */
322 unsigned int no_analog :1; /* digital I/O only */
323
Takashi Iwai2134ea42008-01-10 16:53:55 +0100324 /* for virtual master */
325 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200326#ifdef CONFIG_SND_HDA_POWER_SAVE
327 struct hda_loopback_check loopback;
328#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200329
330 /* for PLL fix */
331 hda_nid_t pll_nid;
332 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100333};
334
335/*
336 * configuration template - to be copied to the spec instance
337 */
338struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 struct snd_kcontrol_new *mixers[5]; /* should be identical size
340 * with spec
341 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100342 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100343 const struct hda_verb *init_verbs[5];
344 unsigned int num_dacs;
345 hda_nid_t *dac_nids;
346 hda_nid_t dig_out_nid; /* optional */
347 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800348 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100349 unsigned int num_adc_nids;
350 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100351 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100352 hda_nid_t dig_in_nid;
353 unsigned int num_channel_mode;
354 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200355 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200356 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100358 void (*unsol_event)(struct hda_codec *, unsigned int);
359 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_amp_list *loopbacks;
362#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363};
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366/*
367 * input MUX handling
368 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200369static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200374 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
375 if (mux_idx >= spec->num_mux_defs)
376 mux_idx = 0;
377 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200380static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
386
387 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
388 return 0;
389}
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100396 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100398 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100399 hda_nid_t nid = spec->capsrc_nids ?
400 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Takashi Iwaicd896c32008-11-18 12:36:33 +0100402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
403 imux = &spec->input_mux[mux_idx];
404
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100407 /* Matrix-mixer style (e.g. ALC882) */
408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
409 unsigned int i, idx;
410
411 idx = ucontrol->value.enumerated.item[0];
412 if (idx >= imux->num_items)
413 idx = imux->num_items - 1;
414 if (*cur_val == idx)
415 return 0;
416 for (i = 0; i < imux->num_items; i++) {
417 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
418 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
419 imux->items[i].index,
420 HDA_AMP_MUTE, v);
421 }
422 *cur_val = idx;
423 return 1;
424 } else {
425 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100426 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100427 &spec->cur_mux[adc_idx]);
428 }
429}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431/*
432 * channel mode setting
433 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100439 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
440 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100448 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449 spec->num_channel_mode,
450 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200458 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
459 spec->num_channel_mode,
460 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200461 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200462 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
463 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100467 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200468 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100469 * being part of a format specifier. Maximum allowed length of a value is
470 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100471 *
472 * Note: some retasking pin complexes seem to ignore requests for input
473 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
474 * are requested. Therefore order this list so that this behaviour will not
475 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
477 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200478 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100479static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100480 "Mic 50pc bias", "Mic 80pc bias",
481 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482};
483static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100484 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485};
486/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200487 * in the pin being assumed to be exclusively an input or an output pin. In
488 * addition, "input" pins may or may not process the mic bias option
489 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
490 * accept requests for bias as of chip versions up to March 2006) and/or
491 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200493#define ALC_PIN_DIR_IN 0x00
494#define ALC_PIN_DIR_OUT 0x01
495#define ALC_PIN_DIR_INOUT 0x02
496#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
497#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498
Kailang Yangea1fb292008-08-26 12:58:38 +0200499/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500 * For each direction the minimum and maximum values are given.
501 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200502static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503 { 0, 2 }, /* ALC_PIN_DIR_IN */
504 { 3, 4 }, /* ALC_PIN_DIR_OUT */
505 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
507 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508};
509#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
510#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
511#define alc_pin_mode_n_items(_dir) \
512 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 unsigned int item_num = uinfo->value.enumerated.item;
518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
519
520 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
523
524 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
525 item_num = alc_pin_mode_min(dir);
526 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 return 0;
528}
529
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_PIN_WIDGET_CONTROL,
540 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542 /* Find enumerated value for current pinctl setting */
543 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 return 0;
548}
549
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552{
553 signed int change;
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
557 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_PIN_WIDGET_CONTROL,
560 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200562 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 val = alc_pin_mode_min(dir);
564
565 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100566 if (change) {
567 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200568 snd_hda_codec_write_cache(codec, nid, 0,
569 AC_VERB_SET_PIN_WIDGET_CONTROL,
570 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571
Kailang Yangea1fb292008-08-26 12:58:38 +0200572 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100573 * for the requested pin mode. Enum values of 2 or less are
574 * input modes.
575 *
576 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577 * reduces noise slightly (particularly on input) so we'll
578 * do it. However, having both input and output buffers
579 * enabled simultaneously doesn't seem to be problematic if
580 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 */
582 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, HDA_AMP_MUTE);
585 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
586 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200588 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
591 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100592 }
593 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200594 return change;
595}
596
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100599 .info = alc_pin_mode_info, \
600 .get = alc_pin_mode_get, \
601 .put = alc_pin_mode_put, \
602 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100603
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100604/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
605 * together using a mask with more than one bit set. This control is
606 * currently used only by the ALC260 test model. At this stage they are not
607 * needed for any "production" models.
608 */
609#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200610#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200611
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 hda_nid_t nid = kcontrol->private_value & 0xffff;
617 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
618 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200619 unsigned int val = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100621
622 *valp = (val & mask) != 0;
623 return 0;
624}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627{
628 signed int change;
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA,
635 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100636
637 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
639 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100640 gpio_data &= ~mask;
641 else
642 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200643 snd_hda_codec_write_cache(codec, nid, 0,
644 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645
646 return change;
647}
648#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
650 .info = alc_gpio_data_info, \
651 .get = alc_gpio_data_get, \
652 .put = alc_gpio_data_put, \
653 .private_value = nid | (mask<<16) }
654#endif /* CONFIG_SND_DEBUG */
655
Jonathan Woithe92621f12006-02-28 11:47:47 +0100656/* A switch control to allow the enabling of the digital IO pins on the
657 * ALC260. This is incredibly simplistic; the intention of this control is
658 * to provide something in the test model allowing digital outputs to be
659 * identified if present. If models are found which can utilise these
660 * outputs a more complete mixer control can be devised for those models if
661 * necessary.
662 */
663#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200664#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200665
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100668{
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100674 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100675
676 *valp = (val & mask) != 0;
677 return 0;
678}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681{
682 signed int change;
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100688 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200689 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100690
691 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693 if (val==0)
694 ctrl_data &= ~mask;
695 else
696 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
698 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699
700 return change;
701}
702#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
703 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
704 .info = alc_spdif_ctrl_info, \
705 .get = alc_spdif_ctrl_get, \
706 .put = alc_spdif_ctrl_put, \
707 .private_value = nid | (mask<<16) }
708#endif /* CONFIG_SND_DEBUG */
709
Jonathan Woithef8225f62008-01-08 12:16:54 +0100710/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
711 * Again, this is only used in the ALC26x test models to help identify when
712 * the EAPD line must be asserted for features to work.
713 */
714#ifdef CONFIG_SND_DEBUG
715#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
716
717static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
719{
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long *valp = ucontrol->value.integer.value;
724 unsigned int val = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
726
727 *valp = (val & mask) != 0;
728 return 0;
729}
730
731static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 int change;
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long val = *ucontrol->value.integer.value;
739 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE,
741 0x00);
742
743 /* Set/unset the masked control bit(s) as needed */
744 change = (!val ? 0 : mask) != (ctrl_data & mask);
745 if (!val)
746 ctrl_data &= ~mask;
747 else
748 ctrl_data |= mask;
749 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
750 ctrl_data);
751
752 return change;
753}
754
755#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
756 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
757 .info = alc_eapd_ctrl_info, \
758 .get = alc_eapd_ctrl_get, \
759 .put = alc_eapd_ctrl_put, \
760 .private_value = nid | (mask<<16) }
761#endif /* CONFIG_SND_DEBUG */
762
Kailang Yangdf694da2005-12-05 19:42:22 +0100763/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100764 * set up the input pin config (depending on the given auto-pin type)
765 */
766static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
767 int auto_pin_type)
768{
769 unsigned int val = PIN_IN;
770
771 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
772 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100773 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100774 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
775 if (pincap & AC_PINCAP_VREF_80)
776 val = PIN_VREF80;
777 }
778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
779}
780
781/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100782 */
783static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
784{
785 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
786 return;
787 spec->mixers[spec->num_mixers++] = mix;
788}
789
790static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
791{
792 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
793 return;
794 spec->init_verbs[spec->num_init_verbs++] = verb;
795}
796
Takashi Iwaidaead532008-11-28 12:55:36 +0100797#ifdef CONFIG_PROC_FS
798/*
799 * hook for proc
800 */
801static void print_realtek_coef(struct snd_info_buffer *buffer,
802 struct hda_codec *codec, hda_nid_t nid)
803{
804 int coeff;
805
806 if (nid != 0x20)
807 return;
808 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
809 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
810 coeff = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_COEF_INDEX, 0);
812 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
813}
814#else
815#define print_realtek_coef NULL
816#endif
817
Takashi Iwaid88897e2008-10-31 15:01:37 +0100818/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100819 * set up from the preset table
820 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200821static void setup_preset(struct alc_spec *spec,
822 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100823{
824 int i;
825
826 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100827 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100828 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200829 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
830 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100831 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200832
Kailang Yangdf694da2005-12-05 19:42:22 +0100833 spec->channel_mode = preset->channel_mode;
834 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200835 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100836
837 spec->multiout.max_channels = spec->channel_mode[0].channels;
838
839 spec->multiout.num_dacs = preset->num_dacs;
840 spec->multiout.dac_nids = preset->dac_nids;
841 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800842 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100843 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200844
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200845 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200846 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200847 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100848 spec->input_mux = preset->input_mux;
849
850 spec->num_adc_nids = preset->num_adc_nids;
851 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100852 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100854
855 spec->unsol_event = preset->unsol_event;
856 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200857#ifdef CONFIG_SND_HDA_POWER_SAVE
858 spec->loopback.amplist = preset->loopbacks;
859#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100860}
861
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200862/* Enable GPIO mask and set output */
863static struct hda_verb alc_gpio1_init_verbs[] = {
864 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
865 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
866 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
867 { }
868};
869
870static struct hda_verb alc_gpio2_init_verbs[] = {
871 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
872 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
873 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
874 { }
875};
876
Kailang Yangbdd148a2007-05-08 15:19:08 +0200877static struct hda_verb alc_gpio3_init_verbs[] = {
878 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
880 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
881 { }
882};
883
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200884/*
885 * Fix hardware PLL issue
886 * On some codecs, the analog PLL gating control must be off while
887 * the default value is 1.
888 */
889static void alc_fix_pll(struct hda_codec *codec)
890{
891 struct alc_spec *spec = codec->spec;
892 unsigned int val;
893
894 if (!spec->pll_nid)
895 return;
896 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
897 spec->pll_coef_idx);
898 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
899 AC_VERB_GET_PROC_COEF, 0);
900 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
901 spec->pll_coef_idx);
902 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
903 val & ~(1 << spec->pll_coef_bit));
904}
905
906static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
907 unsigned int coef_idx, unsigned int coef_bit)
908{
909 struct alc_spec *spec = codec->spec;
910 spec->pll_nid = nid;
911 spec->pll_coef_idx = coef_idx;
912 spec->pll_coef_bit = coef_bit;
913 alc_fix_pll(codec);
914}
915
Kailang Yangc9b58002007-10-16 14:30:01 +0200916static void alc_sku_automute(struct hda_codec *codec)
917{
918 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 unsigned int present;
920 unsigned int hp_nid = spec->autocfg.hp_pins[0];
921 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
922
923 /* need to execute and sync at first */
924 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
925 present = snd_hda_codec_read(codec, hp_nid, 0,
926 AC_VERB_GET_PIN_SENSE, 0);
927 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100928 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
929 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200930}
931
Takashi Iwai4605b712008-10-31 14:18:24 +0100932#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200933static void alc_mic_automute(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int present;
937 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
938 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
939 unsigned int mix_nid = spec->capsrc_nids[0];
940 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
941
942 capsrc_idx_mic = mic_nid - 0x18;
943 capsrc_idx_fmic = fmic_nid - 0x18;
944 present = snd_hda_codec_read(codec, mic_nid, 0,
945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
946 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
947 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
948 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
949 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
950 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
952}
Takashi Iwai4605b712008-10-31 14:18:24 +0100953#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100954#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100955#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200956
Kailang Yangc9b58002007-10-16 14:30:01 +0200957/* unsolicited event for HP jack sensing */
958static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
959{
960 if (codec->vendor_id == 0x10ec0880)
961 res >>= 28;
962 else
963 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200964 if (res == ALC880_HP_EVENT)
965 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200966
Kailang Yang7fb0d782008-10-15 11:12:35 +0200967 if (res == ALC880_MIC_EVENT)
968 alc_mic_automute(codec);
969}
970
971static void alc_inithook(struct hda_codec *codec)
972{
Kailang Yangc9b58002007-10-16 14:30:01 +0200973 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200974 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200975}
976
Kailang Yangf9423e72008-05-27 12:32:25 +0200977/* additional initialization for ALC888 variants */
978static void alc888_coef_init(struct hda_codec *codec)
979{
980 unsigned int tmp;
981
982 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
983 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +0100985 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +0200986 /* alc888S-VC */
987 snd_hda_codec_read(codec, 0x20, 0,
988 AC_VERB_SET_PROC_COEF, 0x830);
989 else
990 /* alc888-VB */
991 snd_hda_codec_read(codec, 0x20, 0,
992 AC_VERB_SET_PROC_COEF, 0x3030);
993}
994
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200995/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
996 * 31 ~ 16 : Manufacture ID
997 * 15 ~ 8 : SKU ID
998 * 7 ~ 0 : Assembly ID
999 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1000 */
1001static void alc_subsystem_id(struct hda_codec *codec,
1002 unsigned int porta, unsigned int porte,
1003 unsigned int portd)
1004{
Kailang Yangc9b58002007-10-16 14:30:01 +02001005 unsigned int ass, tmp, i;
1006 unsigned nid;
1007 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001008
Kailang Yangc9b58002007-10-16 14:30:01 +02001009 ass = codec->subsystem_id & 0xffff;
1010 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1011 goto do_sku;
1012
Kailang Yangea1fb292008-08-26 12:58:38 +02001013 /*
Kailang Yangc9b58002007-10-16 14:30:01 +02001014 * 31~30 : port conetcivity
1015 * 29~21 : reserve
1016 * 20 : PCBEEP input
1017 * 19~16 : Check sum (15:1)
1018 * 15~1 : Custom
1019 * 0 : override
1020 */
1021 nid = 0x1d;
1022 if (codec->vendor_id == 0x10ec0260)
1023 nid = 0x17;
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001024 ass = snd_hda_codec_get_pincfg(codec, nid);
Kailang Yangc9b58002007-10-16 14:30:01 +02001025 if (!(ass & 1) && !(ass & 0x100000))
1026 return;
1027 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001028 return;
1029
Kailang Yangc9b58002007-10-16 14:30:01 +02001030 /* check sum */
1031 tmp = 0;
1032 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001033 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001034 tmp++;
1035 }
1036 if (((ass >> 16) & 0xf) != tmp)
1037 return;
1038do_sku:
1039 /*
1040 * 0 : override
1041 * 1 : Swap Jack
1042 * 2 : 0 --> Desktop, 1 --> Laptop
1043 * 3~5 : External Amplifier control
1044 * 7~6 : Reserved
1045 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001046 tmp = (ass & 0x38) >> 3; /* external Amp control */
1047 switch (tmp) {
1048 case 1:
1049 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1050 break;
1051 case 3:
1052 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1053 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 case 7:
1055 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1056 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001057 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001058 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001059 case 0x10ec0260:
1060 snd_hda_codec_write(codec, 0x0f, 0,
1061 AC_VERB_SET_EAPD_BTLENABLE, 2);
1062 snd_hda_codec_write(codec, 0x10, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 break;
1065 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001066 case 0x10ec0267:
1067 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001068 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001069 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001070 case 0x10ec0660:
1071 case 0x10ec0662:
1072 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001073 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001074 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001075 snd_hda_codec_write(codec, 0x14, 0,
1076 AC_VERB_SET_EAPD_BTLENABLE, 2);
1077 snd_hda_codec_write(codec, 0x15, 0,
1078 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001079 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001080 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001081 switch (codec->vendor_id) {
1082 case 0x10ec0260:
1083 snd_hda_codec_write(codec, 0x1a, 0,
1084 AC_VERB_SET_COEF_INDEX, 7);
1085 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1086 AC_VERB_GET_PROC_COEF, 0);
1087 snd_hda_codec_write(codec, 0x1a, 0,
1088 AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x1a, 0,
1090 AC_VERB_SET_PROC_COEF,
1091 tmp | 0x2010);
1092 break;
1093 case 0x10ec0262:
1094 case 0x10ec0880:
1095 case 0x10ec0882:
1096 case 0x10ec0883:
1097 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001098 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001099 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 snd_hda_codec_write(codec, 0x20, 0,
1101 AC_VERB_SET_COEF_INDEX, 7);
1102 tmp = snd_hda_codec_read(codec, 0x20, 0,
1103 AC_VERB_GET_PROC_COEF, 0);
1104 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001105 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_PROC_COEF,
1108 tmp | 0x2010);
1109 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001110 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001111 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001112 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0267:
1114 case 0x10ec0268:
1115 snd_hda_codec_write(codec, 0x20, 0,
1116 AC_VERB_SET_COEF_INDEX, 7);
1117 tmp = snd_hda_codec_read(codec, 0x20, 0,
1118 AC_VERB_GET_PROC_COEF, 0);
1119 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001120 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 snd_hda_codec_write(codec, 0x20, 0,
1122 AC_VERB_SET_PROC_COEF,
1123 tmp | 0x3000);
1124 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001125 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001127 break;
1128 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001129
Kailang Yang8c427222008-01-10 13:03:59 +01001130 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 * when the external headphone out jack is plugged"
1132 */
Kailang Yang8c427222008-01-10 13:03:59 +01001133 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 return;
1135 /*
1136 * 10~8 : Jack location
1137 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1138 * 14~13: Resvered
1139 * 15 : 1 --> enable the function "Mute internal speaker
1140 * when the external headphone out jack is plugged"
1141 */
1142 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001143 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001145 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 else
1147 return;
1148 }
1149
1150 if (!spec->autocfg.hp_pins[0]) {
1151 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1152 if (tmp == 0)
1153 spec->autocfg.hp_pins[0] = porta;
1154 else if (tmp == 1)
1155 spec->autocfg.hp_pins[0] = porte;
1156 else if (tmp == 2)
1157 spec->autocfg.hp_pins[0] = portd;
1158 else
1159 return;
1160 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001161 if (spec->autocfg.hp_pins[0])
1162 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1163 AC_VERB_SET_UNSOLICITED_ENABLE,
1164 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165
Takashi Iwai4605b712008-10-31 14:18:24 +01001166#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001167 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1168 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1169 snd_hda_codec_write(codec,
1170 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1171 AC_VERB_SET_UNSOLICITED_ENABLE,
1172 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001173#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Kailang Yangc9b58002007-10-16 14:30:01 +02001175 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001176}
1177
Takashi Iwai41e41f12005-06-08 14:48:49 +02001178/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001179 * Fix-up pin default configurations
1180 */
1181
1182struct alc_pincfg {
1183 hda_nid_t nid;
1184 u32 val;
1185};
1186
1187static void alc_fix_pincfg(struct hda_codec *codec,
1188 const struct snd_pci_quirk *quirk,
1189 const struct alc_pincfg **pinfix)
1190{
1191 const struct alc_pincfg *cfg;
1192
1193 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1194 if (!quirk)
1195 return;
1196
1197 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001198 for (; cfg->nid; cfg++)
1199 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001200}
1201
1202/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001203 * ALC888
1204 */
1205
1206/*
1207 * 2ch mode
1208 */
1209static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1210/* Mic-in jack as mic in */
1211 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1212 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1213/* Line-in jack as Line in */
1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1216/* Line-Out as Front */
1217 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1218 { } /* end */
1219};
1220
1221/*
1222 * 4ch mode
1223 */
1224static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1225/* Mic-in jack as mic in */
1226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1228/* Line-in jack as Surround */
1229 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1230 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1231/* Line-Out as Front */
1232 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1233 { } /* end */
1234};
1235
1236/*
1237 * 6ch mode
1238 */
1239static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1240/* Mic-in jack as CLFE */
1241 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243/* Line-in jack as Surround */
1244 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1245 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1246/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1247 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1248 { } /* end */
1249};
1250
1251/*
1252 * 8ch mode
1253 */
1254static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1255/* Mic-in jack as CLFE */
1256 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1257 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1258/* Line-in jack as Surround */
1259 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1260 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1261/* Line-Out as Side */
1262 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1263 { } /* end */
1264};
1265
1266static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1267 { 2, alc888_4ST_ch2_intel_init },
1268 { 4, alc888_4ST_ch4_intel_init },
1269 { 6, alc888_4ST_ch6_intel_init },
1270 { 8, alc888_4ST_ch8_intel_init },
1271};
1272
1273/*
1274 * ALC888 Fujitsu Siemens Amillo xa3530
1275 */
1276
1277static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1278/* Front Mic: set to PIN_IN (empty by default) */
1279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1280/* Connect Internal HP to Front */
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1284/* Connect Bass HP to Front */
1285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1288/* Connect Line-Out side jack (SPDIF) to Side */
1289 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1292/* Connect Mic jack to CLFE */
1293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1296/* Connect Line-in jack to Surround */
1297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1300/* Connect HP out jack to Front */
1301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1303 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1304/* Enable unsolicited event for HP jack and Line-out jack */
1305 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1306 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1307 {}
1308};
1309
1310static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1311{
1312 unsigned int present;
1313 unsigned int bits;
1314 /* Line out presence */
1315 present = snd_hda_codec_read(codec, 0x17, 0,
1316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1317 /* HP out presence */
1318 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1320 bits = present ? HDA_AMP_MUTE : 0;
1321 /* Toggle internal speakers muting */
1322 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1323 HDA_AMP_MUTE, bits);
1324 /* Toggle internal bass muting */
1325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1326 HDA_AMP_MUTE, bits);
1327}
1328
1329static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1330 unsigned int res)
1331{
1332 if (res >> 26 == ALC880_HP_EVENT)
1333 alc888_fujitsu_xa3530_automute(codec);
1334}
1335
1336
1337/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001338 * ALC888 Acer Aspire 4930G model
1339 */
1340
1341static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1342/* Front Mic: set to PIN_IN (empty by default) */
1343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1344/* Unselect Front Mic by default in input mixer 3 */
1345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001346/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1348/* Connect Internal HP to front */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1352/* Connect HP out to front */
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1356 { }
1357};
1358
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001359static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001360 /* Front mic only available on one ADC */
1361 {
1362 .num_items = 4,
1363 .items = {
1364 { "Mic", 0x0 },
1365 { "Line", 0x2 },
1366 { "CD", 0x4 },
1367 { "Front Mic", 0xb },
1368 },
1369 },
1370 {
1371 .num_items = 3,
1372 .items = {
1373 { "Mic", 0x0 },
1374 { "Line", 0x2 },
1375 { "CD", 0x4 },
1376 },
1377 }
1378};
1379
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001380static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1382 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1383 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1384 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1385 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1386 HDA_OUTPUT),
1387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1389 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1391 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001399 { } /* end */
1400};
1401
1402static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1403{
1404 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001405 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001406 present = snd_hda_codec_read(codec, 0x15, 0,
1407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001408 bits = present ? HDA_AMP_MUTE : 0;
1409 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1410 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001411}
1412
1413static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1414 unsigned int res)
1415{
1416 if (res >> 26 == ALC880_HP_EVENT)
1417 alc888_acer_aspire_4930g_automute(codec);
1418}
1419
1420/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001421 * ALC880 3-stack model
1422 *
1423 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001424 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1425 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 */
1427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001428static hda_nid_t alc880_dac_nids[4] = {
1429 /* front, rear, clfe, rear_surr */
1430 0x02, 0x05, 0x04, 0x03
1431};
1432
1433static hda_nid_t alc880_adc_nids[3] = {
1434 /* ADC0-2 */
1435 0x07, 0x08, 0x09,
1436};
1437
1438/* The datasheet says the node 0x07 is connected from inputs,
1439 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001440 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001442static hda_nid_t alc880_adc_nids_alt[2] = {
1443 /* ADC1-2 */
1444 0x08, 0x09,
1445};
1446
1447#define ALC880_DIGOUT_NID 0x06
1448#define ALC880_DIGIN_NID 0x0a
1449
1450static struct hda_input_mux alc880_capture_source = {
1451 .num_items = 4,
1452 .items = {
1453 { "Mic", 0x0 },
1454 { "Front Mic", 0x3 },
1455 { "Line", 0x2 },
1456 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458};
1459
1460/* channel source setting (2/6 channel selection for 3-stack) */
1461/* 2ch mode */
1462static struct hda_verb alc880_threestack_ch2_init[] = {
1463 /* set line-in to input, mute it */
1464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1466 /* set mic-in to input vref 80%, mute it */
1467 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1468 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 { } /* end */
1470};
1471
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001472/* 6ch mode */
1473static struct hda_verb alc880_threestack_ch6_init[] = {
1474 /* set line-in to output, unmute it */
1475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477 /* set mic-in to output, unmute it */
1478 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480 { } /* end */
1481};
1482
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001483static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001484 { 2, alc880_threestack_ch2_init },
1485 { 6, alc880_threestack_ch6_init },
1486};
1487
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001488static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001489 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001491 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001492 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1494 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001495 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1496 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001506 {
1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001509 .info = alc_ch_mode_info,
1510 .get = alc_ch_mode_get,
1511 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001512 },
1513 { } /* end */
1514};
1515
1516/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001517static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1518 struct snd_ctl_elem_info *uinfo)
1519{
1520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1521 struct alc_spec *spec = codec->spec;
1522 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001523
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_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001528 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001529 return err;
1530}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001532static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1533 unsigned int size, unsigned int __user *tlv)
1534{
1535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1536 struct alc_spec *spec = codec->spec;
1537 int err;
1538
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001539 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001540 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1541 HDA_INPUT);
1542 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001543 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001544 return err;
1545}
1546
1547typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1548 struct snd_ctl_elem_value *ucontrol);
1549
1550static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1551 struct snd_ctl_elem_value *ucontrol,
1552 getput_call_t func)
1553{
1554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1555 struct alc_spec *spec = codec->spec;
1556 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1557 int err;
1558
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001559 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001560 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1561 3, 0, HDA_INPUT);
1562 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001563 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001564 return err;
1565}
1566
1567static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1568 struct snd_ctl_elem_value *ucontrol)
1569{
1570 return alc_cap_getput_caller(kcontrol, ucontrol,
1571 snd_hda_mixer_amp_volume_get);
1572}
1573
1574static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1576{
1577 return alc_cap_getput_caller(kcontrol, ucontrol,
1578 snd_hda_mixer_amp_volume_put);
1579}
1580
1581/* capture mixer elements */
1582#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1583
1584static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1585 struct snd_ctl_elem_value *ucontrol)
1586{
1587 return alc_cap_getput_caller(kcontrol, ucontrol,
1588 snd_hda_mixer_amp_switch_get);
1589}
1590
1591static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1592 struct snd_ctl_elem_value *ucontrol)
1593{
1594 return alc_cap_getput_caller(kcontrol, ucontrol,
1595 snd_hda_mixer_amp_switch_put);
1596}
1597
Takashi Iwaia23b6882009-03-23 15:21:36 +01001598#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001599 { \
1600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1601 .name = "Capture Switch", \
1602 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1603 .count = num, \
1604 .info = alc_cap_sw_info, \
1605 .get = alc_cap_sw_get, \
1606 .put = alc_cap_sw_put, \
1607 }, \
1608 { \
1609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1610 .name = "Capture Volume", \
1611 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1612 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1613 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1614 .count = num, \
1615 .info = alc_cap_vol_info, \
1616 .get = alc_cap_vol_get, \
1617 .put = alc_cap_vol_put, \
1618 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001619 }
1620
1621#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001622 { \
1623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1624 /* .name = "Capture Source", */ \
1625 .name = "Input Source", \
1626 .count = num, \
1627 .info = alc_mux_enum_info, \
1628 .get = alc_mux_enum_get, \
1629 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001630 }
1631
1632#define DEFINE_CAPMIX(num) \
1633static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1634 _DEFINE_CAPMIX(num), \
1635 _DEFINE_CAPSRC(num), \
1636 { } /* end */ \
1637}
1638
1639#define DEFINE_CAPMIX_NOSRC(num) \
1640static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1641 _DEFINE_CAPMIX(num), \
1642 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001643}
1644
1645/* up to three ADCs */
1646DEFINE_CAPMIX(1);
1647DEFINE_CAPMIX(2);
1648DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001649DEFINE_CAPMIX_NOSRC(1);
1650DEFINE_CAPMIX_NOSRC(2);
1651DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001652
1653/*
1654 * ALC880 5-stack model
1655 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001656 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1657 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001658 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1659 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1660 */
1661
1662/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001663static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001665 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 { } /* end */
1667};
1668
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001669/* channel source setting (6/8 channel selection for 5-stack) */
1670/* 6ch mode */
1671static struct hda_verb alc880_fivestack_ch6_init[] = {
1672 /* set line-in to input, mute it */
1673 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1674 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001675 { } /* end */
1676};
1677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678/* 8ch mode */
1679static struct hda_verb alc880_fivestack_ch8_init[] = {
1680 /* set line-in to output, unmute it */
1681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1682 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1683 { } /* end */
1684};
1685
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001686static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001687 { 6, alc880_fivestack_ch6_init },
1688 { 8, alc880_fivestack_ch8_init },
1689};
1690
1691
1692/*
1693 * ALC880 6-stack model
1694 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001695 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1696 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001697 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1698 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1699 */
1700
1701static hda_nid_t alc880_6st_dac_nids[4] = {
1702 /* front, rear, clfe, rear_surr */
1703 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001704};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001705
1706static struct hda_input_mux alc880_6stack_capture_source = {
1707 .num_items = 4,
1708 .items = {
1709 { "Mic", 0x0 },
1710 { "Front Mic", 0x1 },
1711 { "Line", 0x2 },
1712 { "CD", 0x4 },
1713 },
1714};
1715
1716/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001717static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001718 { 8, NULL },
1719};
1720
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001721static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001723 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001724 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001725 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001726 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1727 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001728 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1729 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001730 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001731 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001740 {
1741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1742 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001743 .info = alc_ch_mode_info,
1744 .get = alc_ch_mode_get,
1745 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001746 },
1747 { } /* end */
1748};
1749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001750
1751/*
1752 * ALC880 W810 model
1753 *
1754 * W810 has rear IO for:
1755 * Front (DAC 02)
1756 * Surround (DAC 03)
1757 * Center/LFE (DAC 04)
1758 * Digital out (06)
1759 *
1760 * The system also has a pair of internal speakers, and a headphone jack.
1761 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001762 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 * There is a variable resistor to control the speaker or headphone
1764 * volume. This is a hardware-only device without a software API.
1765 *
1766 * Plugging headphones in will disable the internal speakers. This is
1767 * implemented in hardware, not via the driver using jack sense. In
1768 * a similar fashion, plugging into the rear socket marked "front" will
1769 * disable both the speakers and headphones.
1770 *
1771 * For input, there's a microphone jack, and an "audio in" jack.
1772 * These may not do anything useful with this driver yet, because I
1773 * haven't setup any initialization verbs for these yet...
1774 */
1775
1776static hda_nid_t alc880_w810_dac_nids[3] = {
1777 /* front, rear/surround, clfe */
1778 0x02, 0x03, 0x04
1779};
1780
1781/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001782static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001783 { 6, NULL }
1784};
1785
1786/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001787static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001791 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1793 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001794 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1795 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1797 { } /* end */
1798};
1799
1800
1801/*
1802 * Z710V model
1803 *
1804 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001805 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1806 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001807 */
1808
1809static hda_nid_t alc880_z71v_dac_nids[1] = {
1810 0x02
1811};
1812#define ALC880_Z71V_HP_DAC 0x03
1813
1814/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001815static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816 { 2, NULL }
1817};
1818
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001819static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001821 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001822 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001823 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1828 { } /* end */
1829};
1830
1831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832/*
1833 * ALC880 F1734 model
1834 *
1835 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1836 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1837 */
1838
1839static hda_nid_t alc880_f1734_dac_nids[1] = {
1840 0x03
1841};
1842#define ALC880_F1734_HP_DAC 0x02
1843
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001844static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001845 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001846 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001847 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1848 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001849 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1850 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001853 { } /* end */
1854};
1855
Takashi Iwai937b4162008-02-11 14:52:36 +01001856static struct hda_input_mux alc880_f1734_capture_source = {
1857 .num_items = 2,
1858 .items = {
1859 { "Mic", 0x1 },
1860 { "CD", 0x4 },
1861 },
1862};
1863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001864
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001865/*
1866 * ALC880 ASUS model
1867 *
1868 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1869 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1870 * Mic = 0x18, Line = 0x1a
1871 */
1872
1873#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1874#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1875
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001876static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001878 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001880 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001883 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001891 {
1892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1893 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001894 .info = alc_ch_mode_info,
1895 .get = alc_ch_mode_get,
1896 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001897 },
1898 { } /* end */
1899};
1900
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001901/*
1902 * ALC880 ASUS W1V model
1903 *
1904 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1905 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1906 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1907 */
1908
1909/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001910static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001911 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1912 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001913 { } /* end */
1914};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915
Kailang Yangdf694da2005-12-05 19:42:22 +01001916/* TCL S700 */
1917static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1919 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1922 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1926 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001927 { } /* end */
1928};
1929
Kailang Yangccc656c2006-10-17 12:32:26 +02001930/* Uniwill */
1931static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1933 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1935 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001936 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1937 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1938 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1939 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1940 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1941 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1946 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1947 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001948 {
1949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1950 .name = "Channel Mode",
1951 .info = alc_ch_mode_info,
1952 .get = alc_ch_mode_get,
1953 .put = alc_ch_mode_put,
1954 },
1955 { } /* end */
1956};
1957
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001958static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1960 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1964 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1965 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1966 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1967 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1968 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1969 { } /* end */
1970};
1971
Kailang Yangccc656c2006-10-17 12:32:26 +02001972static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001973 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1974 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1975 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1976 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1979 { } /* end */
1980};
1981
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001983 * virtual master controls
1984 */
1985
1986/*
1987 * slave controls for virtual master
1988 */
1989static const char *alc_slave_vols[] = {
1990 "Front Playback Volume",
1991 "Surround Playback Volume",
1992 "Center Playback Volume",
1993 "LFE Playback Volume",
1994 "Side Playback Volume",
1995 "Headphone Playback Volume",
1996 "Speaker Playback Volume",
1997 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001998 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001999 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002000 NULL,
2001};
2002
2003static const char *alc_slave_sws[] = {
2004 "Front Playback Switch",
2005 "Surround Playback Switch",
2006 "Center Playback Switch",
2007 "LFE Playback Switch",
2008 "Side Playback Switch",
2009 "Headphone Playback Switch",
2010 "Speaker Playback Switch",
2011 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002012 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002013 NULL,
2014};
2015
2016/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002019
2020static void alc_free_kctls(struct hda_codec *codec);
2021
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002022/* additional beep mixers; the actual parameters are overwritten at build */
2023static struct snd_kcontrol_new alc_beep_mixer[] = {
2024 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2025 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2026 { } /* end */
2027};
2028
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029static int alc_build_controls(struct hda_codec *codec)
2030{
2031 struct alc_spec *spec = codec->spec;
2032 int err;
2033 int i;
2034
2035 for (i = 0; i < spec->num_mixers; i++) {
2036 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2037 if (err < 0)
2038 return err;
2039 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002040 if (spec->cap_mixer) {
2041 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2042 if (err < 0)
2043 return err;
2044 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002045 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002046 err = snd_hda_create_spdif_out_ctls(codec,
2047 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048 if (err < 0)
2049 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002050 if (!spec->no_analog) {
2051 err = snd_hda_create_spdif_share_sw(codec,
2052 &spec->multiout);
2053 if (err < 0)
2054 return err;
2055 spec->multiout.share_spdif = 1;
2056 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 }
2058 if (spec->dig_in_nid) {
2059 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2060 if (err < 0)
2061 return err;
2062 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002063
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002064 /* create beep controls if needed */
2065 if (spec->beep_amp) {
2066 struct snd_kcontrol_new *knew;
2067 for (knew = alc_beep_mixer; knew->name; knew++) {
2068 struct snd_kcontrol *kctl;
2069 kctl = snd_ctl_new1(knew, codec);
2070 if (!kctl)
2071 return -ENOMEM;
2072 kctl->private_value = spec->beep_amp;
2073 err = snd_hda_ctl_add(codec, kctl);
2074 if (err < 0)
2075 return err;
2076 }
2077 }
2078
Takashi Iwai2134ea42008-01-10 16:53:55 +01002079 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002080 if (!spec->no_analog &&
2081 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002082 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002083 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002084 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002085 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002086 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002087 if (err < 0)
2088 return err;
2089 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002090 if (!spec->no_analog &&
2091 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002092 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2093 NULL, alc_slave_sws);
2094 if (err < 0)
2095 return err;
2096 }
2097
Takashi Iwai603c4012008-07-30 15:01:44 +02002098 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099 return 0;
2100}
2101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103/*
2104 * initialize the codec volumes, etc
2105 */
2106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002107/*
2108 * generic initialization of ADC, input mixers and output mixers
2109 */
2110static struct hda_verb alc880_volume_init_verbs[] = {
2111 /*
2112 * Unmute ADC0-2 and set the default input to mic-in
2113 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002114 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002116 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2122 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002123 * Note: PASD motherboards uses the Line In 2 as the input for front
2124 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002135 /*
2136 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002138 /* set vol=0 to output mixers */
2139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2143 /* set up input amps for analog loopback */
2144 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2148 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2152 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153
2154 { }
2155};
2156
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157/*
2158 * 3-stack pin configuration:
2159 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2160 */
2161static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2162 /*
2163 * preset connection lists of input pins
2164 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2165 */
2166 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2167 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2168 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2169
2170 /*
2171 * Set pin mode and muting
2172 */
2173 /* set front pin widgets 0x14 for output */
2174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2176 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2179 /* Mic2 (as headphone out) for HP output */
2180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2182 /* Line In pin widget for input */
2183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2184 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2185 /* Line2 (as front mic) pin widget for input and vref at 80% */
2186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2188 /* CD pin widget for input */
2189 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2190
2191 { }
2192};
2193
2194/*
2195 * 5-stack pin configuration:
2196 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2197 * line-in/side = 0x1a, f-mic = 0x1b
2198 */
2199static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2200 /*
2201 * preset connection lists of input pins
2202 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2203 */
2204 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2205 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2206
2207 /*
2208 * Set pin mode and muting
2209 */
2210 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2214 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 /* unmute pins for output (no gain on this amp) */
2216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2218 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2224 /* Mic2 (as headphone out) for HP output */
2225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002227 /* Line In pin widget for input */
2228 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2230 /* Line2 (as front mic) pin widget for input and vref at 80% */
2231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2232 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2233 /* CD pin widget for input */
2234 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235
2236 { }
2237};
2238
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239/*
2240 * W810 pin configuration:
2241 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2242 */
2243static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 /* hphone/speaker input selector: front DAC */
2245 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2246
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2248 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2252 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2253
2254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 { }
2258};
2259
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260/*
2261 * Z71V pin configuration:
2262 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2263 */
2264static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002269
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002274
2275 { }
2276};
2277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278/*
2279 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002280 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2281 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 */
2283static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2285
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2294
Takashi Iwai16ded522005-06-10 19:58:24 +02002295 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002297 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002299 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305 { }
2306};
Takashi Iwai16ded522005-06-10 19:58:24 +02002307
Kailang Yangccc656c2006-10-17 12:32:26 +02002308/*
2309 * Uniwill pin configuration:
2310 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2311 * line = 0x1a
2312 */
2313static struct hda_verb alc880_uniwill_init_verbs[] = {
2314 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2315
2316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2320 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2321 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2322 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2323 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2330
2331 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2333 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2335 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2337 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2338 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2339 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2340
2341 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2342 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2343
2344 { }
2345};
2346
2347/*
2348* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002349* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002350 */
2351static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2352 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2353
2354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2358 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2359 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2366
2367 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2373
2374 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2375 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2376
2377 { }
2378};
2379
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002380static struct hda_verb alc880_beep_init_verbs[] = {
2381 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2382 { }
2383};
2384
Kailang Yangccc656c2006-10-17 12:32:26 +02002385/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002386static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002387{
2388 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002389 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002390
2391 present = snd_hda_codec_read(codec, 0x14, 0,
2392 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002393 bits = present ? HDA_AMP_MUTE : 0;
2394 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2395 HDA_AMP_MUTE, bits);
2396 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2397 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002398}
2399
2400/* auto-toggle front mic */
2401static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2402{
2403 unsigned int present;
2404 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002405
2406 present = snd_hda_codec_read(codec, 0x18, 0,
2407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002408 bits = present ? HDA_AMP_MUTE : 0;
2409 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002410}
2411
2412static void alc880_uniwill_automute(struct hda_codec *codec)
2413{
2414 alc880_uniwill_hp_automute(codec);
2415 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002416}
2417
2418static void alc880_uniwill_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 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002424 switch (res >> 28) {
2425 case ALC880_HP_EVENT:
2426 alc880_uniwill_hp_automute(codec);
2427 break;
2428 case ALC880_MIC_EVENT:
2429 alc880_uniwill_mic_automute(codec);
2430 break;
2431 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002432}
2433
2434static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2435{
2436 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002437 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002438
2439 present = snd_hda_codec_read(codec, 0x14, 0,
2440 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002441 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002442 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002443}
2444
2445static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2446{
2447 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002448
Kailang Yangccc656c2006-10-17 12:32:26 +02002449 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002450 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2451 present &= HDA_AMP_VOLMASK;
2452 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2453 HDA_AMP_VOLMASK, present);
2454 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2455 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002456}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002457
Kailang Yangccc656c2006-10-17 12:32:26 +02002458static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2459 unsigned int res)
2460{
2461 /* Looks like the unsol event is incompatible with the standard
2462 * definition. 4bit tag is placed at 28 bit!
2463 */
2464 if ((res >> 28) == ALC880_HP_EVENT)
2465 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002466 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002467 alc880_uniwill_p53_dcvol_automute(codec);
2468}
2469
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002470/*
2471 * F1734 pin configuration:
2472 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2473 */
2474static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002476 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2477 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2478 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2479 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2480
2481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2483 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2485
2486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2490 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2491 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2492 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2493 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002495
Takashi Iwai937b4162008-02-11 14:52:36 +01002496 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2497 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2498
Takashi Iwai16ded522005-06-10 19:58:24 +02002499 { }
2500};
2501
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002502/*
2503 * ASUS pin configuration:
2504 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2505 */
2506static struct hda_verb alc880_pin_asus_init_verbs[] = {
2507 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2508 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2509 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2510 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2511
2512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2513 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2516 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520
2521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2523 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002530
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 { }
2532};
2533
2534/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002535#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2536#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537
Kailang Yangdf694da2005-12-05 19:42:22 +01002538/* Clevo m520g init */
2539static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2540 /* headphone output */
2541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2542 /* line-out */
2543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2544 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2545 /* Line-in */
2546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 /* CD */
2549 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2550 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 /* Mic1 (rear panel) */
2552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2553 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2554 /* Mic2 (front panel) */
2555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 /* headphone */
2558 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 /* change to EAPD mode */
2561 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2562 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2563
2564 { }
2565};
2566
2567static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002568 /* change to EAPD mode */
2569 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2570 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2571
Kailang Yangdf694da2005-12-05 19:42:22 +01002572 /* Headphone output */
2573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2574 /* Front output*/
2575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2577
2578 /* Line In pin widget for input */
2579 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2580 /* CD pin widget for input */
2581 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2582 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2583 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2584
2585 /* change to EAPD mode */
2586 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2587 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2588
2589 { }
2590};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002591
2592/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002593 * LG m1 express dual
2594 *
2595 * Pin assignment:
2596 * Rear Line-In/Out (blue): 0x14
2597 * Build-in Mic-In: 0x15
2598 * Speaker-out: 0x17
2599 * HP-Out (green): 0x1b
2600 * Mic-In/Out (red): 0x19
2601 * SPDIF-Out: 0x1e
2602 */
2603
2604/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2605static hda_nid_t alc880_lg_dac_nids[3] = {
2606 0x05, 0x02, 0x03
2607};
2608
2609/* seems analog CD is not working */
2610static struct hda_input_mux alc880_lg_capture_source = {
2611 .num_items = 3,
2612 .items = {
2613 { "Mic", 0x1 },
2614 { "Line", 0x5 },
2615 { "Internal Mic", 0x6 },
2616 },
2617};
2618
2619/* 2,4,6 channel modes */
2620static struct hda_verb alc880_lg_ch2_init[] = {
2621 /* set line-in and mic-in to input */
2622 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2623 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2624 { }
2625};
2626
2627static struct hda_verb alc880_lg_ch4_init[] = {
2628 /* set line-in to out and mic-in to input */
2629 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2630 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2631 { }
2632};
2633
2634static struct hda_verb alc880_lg_ch6_init[] = {
2635 /* set line-in and mic-in to output */
2636 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2637 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2638 { }
2639};
2640
2641static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2642 { 2, alc880_lg_ch2_init },
2643 { 4, alc880_lg_ch4_init },
2644 { 6, alc880_lg_ch6_init },
2645};
2646
2647static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2649 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2651 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2654 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2655 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2660 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2661 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2662 {
2663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2664 .name = "Channel Mode",
2665 .info = alc_ch_mode_info,
2666 .get = alc_ch_mode_get,
2667 .put = alc_ch_mode_put,
2668 },
2669 { } /* end */
2670};
2671
2672static struct hda_verb alc880_lg_init_verbs[] = {
2673 /* set capture source to mic-in */
2674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2677 /* mute all amp mixer inputs */
2678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002681 /* line-in to input */
2682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2684 /* built-in mic */
2685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2687 /* speaker-out */
2688 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2689 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 /* mic-in to input */
2691 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2692 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2693 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 /* HP-out */
2695 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2698 /* jack sense */
2699 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2700 { }
2701};
2702
2703/* toggle speaker-output according to the hp-jack state */
2704static void alc880_lg_automute(struct hda_codec *codec)
2705{
2706 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002707 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002708
2709 present = snd_hda_codec_read(codec, 0x1b, 0,
2710 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002711 bits = present ? HDA_AMP_MUTE : 0;
2712 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2713 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002714}
2715
2716static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2717{
2718 /* Looks like the unsol event is incompatible with the standard
2719 * definition. 4bit tag is placed at 28 bit!
2720 */
2721 if ((res >> 28) == 0x01)
2722 alc880_lg_automute(codec);
2723}
2724
2725/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002726 * LG LW20
2727 *
2728 * Pin assignment:
2729 * Speaker-out: 0x14
2730 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002731 * Built-in Mic-In: 0x19
2732 * Line-In: 0x1b
2733 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002734 * SPDIF-Out: 0x1e
2735 */
2736
Takashi Iwaid6815182006-03-23 16:06:23 +01002737static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002738 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002739 .items = {
2740 { "Mic", 0x0 },
2741 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002742 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002743 },
2744};
2745
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002746#define alc880_lg_lw_modes alc880_threestack_modes
2747
Takashi Iwaid6815182006-03-23 16:06:23 +01002748static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2750 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2751 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2752 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2753 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2754 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2755 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2756 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2761 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2762 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002763 {
2764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2765 .name = "Channel Mode",
2766 .info = alc_ch_mode_info,
2767 .get = alc_ch_mode_get,
2768 .put = alc_ch_mode_put,
2769 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002770 { } /* end */
2771};
2772
2773static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002774 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2775 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2776 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2777
Takashi Iwaid6815182006-03-23 16:06:23 +01002778 /* set capture source to mic-in */
2779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2781 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002783 /* speaker-out */
2784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2786 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789 /* mic-in to input */
2790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2792 /* built-in mic */
2793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2794 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2795 /* jack sense */
2796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2797 { }
2798};
2799
2800/* toggle speaker-output according to the hp-jack state */
2801static void alc880_lg_lw_automute(struct hda_codec *codec)
2802{
2803 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002804 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002805
2806 present = snd_hda_codec_read(codec, 0x1b, 0,
2807 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002808 bits = present ? HDA_AMP_MUTE : 0;
2809 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2810 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002811}
2812
2813static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2814{
2815 /* Looks like the unsol event is incompatible with the standard
2816 * definition. 4bit tag is placed at 28 bit!
2817 */
2818 if ((res >> 28) == 0x01)
2819 alc880_lg_lw_automute(codec);
2820}
2821
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002822static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2823 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2824 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2827 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2828 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2829 { } /* end */
2830};
2831
2832static struct hda_input_mux alc880_medion_rim_capture_source = {
2833 .num_items = 2,
2834 .items = {
2835 { "Mic", 0x0 },
2836 { "Internal Mic", 0x1 },
2837 },
2838};
2839
2840static struct hda_verb alc880_medion_rim_init_verbs[] = {
2841 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2842
2843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2845
2846 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2849 /* Mic2 (as headphone out) for HP output */
2850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2852 /* Internal Speaker */
2853 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855
2856 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2857 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2858
2859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2860 { }
2861};
2862
2863/* toggle speaker-output according to the hp-jack state */
2864static void alc880_medion_rim_automute(struct hda_codec *codec)
2865{
2866 unsigned int present;
2867 unsigned char bits;
2868
2869 present = snd_hda_codec_read(codec, 0x14, 0,
2870 AC_VERB_GET_PIN_SENSE, 0)
2871 & AC_PINSENSE_PRESENCE;
2872 bits = present ? HDA_AMP_MUTE : 0;
2873 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2874 HDA_AMP_MUTE, bits);
2875 if (present)
2876 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2877 else
2878 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2879}
2880
2881static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2882 unsigned int res)
2883{
2884 /* Looks like the unsol event is incompatible with the standard
2885 * definition. 4bit tag is placed at 28 bit!
2886 */
2887 if ((res >> 28) == ALC880_HP_EVENT)
2888 alc880_medion_rim_automute(codec);
2889}
2890
Takashi Iwaicb53c622007-08-10 17:21:45 +02002891#ifdef CONFIG_SND_HDA_POWER_SAVE
2892static struct hda_amp_list alc880_loopbacks[] = {
2893 { 0x0b, HDA_INPUT, 0 },
2894 { 0x0b, HDA_INPUT, 1 },
2895 { 0x0b, HDA_INPUT, 2 },
2896 { 0x0b, HDA_INPUT, 3 },
2897 { 0x0b, HDA_INPUT, 4 },
2898 { } /* end */
2899};
2900
2901static struct hda_amp_list alc880_lg_loopbacks[] = {
2902 { 0x0b, HDA_INPUT, 1 },
2903 { 0x0b, HDA_INPUT, 6 },
2904 { 0x0b, HDA_INPUT, 7 },
2905 { } /* end */
2906};
2907#endif
2908
Takashi Iwaid6815182006-03-23 16:06:23 +01002909/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002910 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002911 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002912
Linus Torvalds1da177e2005-04-16 15:20:36 -07002913static int alc_init(struct hda_codec *codec)
2914{
2915 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 unsigned int i;
2917
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002918 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002919 if (codec->vendor_id == 0x10ec0888)
2920 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002922 for (i = 0; i < spec->num_init_verbs; i++)
2923 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002924
2925 if (spec->init_hook)
2926 spec->init_hook(codec);
2927
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928 return 0;
2929}
2930
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002931static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2932{
2933 struct alc_spec *spec = codec->spec;
2934
2935 if (spec->unsol_event)
2936 spec->unsol_event(codec, res);
2937}
2938
Takashi Iwaicb53c622007-08-10 17:21:45 +02002939#ifdef CONFIG_SND_HDA_POWER_SAVE
2940static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2941{
2942 struct alc_spec *spec = codec->spec;
2943 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2944}
2945#endif
2946
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947/*
2948 * Analog playback callbacks
2949 */
2950static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2951 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002952 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953{
2954 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002955 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2956 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957}
2958
2959static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2960 struct hda_codec *codec,
2961 unsigned int stream_tag,
2962 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002963 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964{
2965 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002966 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2967 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968}
2969
2970static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2971 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002972 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973{
2974 struct alc_spec *spec = codec->spec;
2975 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2976}
2977
2978/*
2979 * Digital out
2980 */
2981static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2982 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002983 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002984{
2985 struct alc_spec *spec = codec->spec;
2986 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2987}
2988
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002989static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2990 struct hda_codec *codec,
2991 unsigned int stream_tag,
2992 unsigned int format,
2993 struct snd_pcm_substream *substream)
2994{
2995 struct alc_spec *spec = codec->spec;
2996 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2997 stream_tag, format, substream);
2998}
2999
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003000static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3001 struct hda_codec *codec,
3002 struct snd_pcm_substream *substream)
3003{
3004 struct alc_spec *spec = codec->spec;
3005 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3006}
3007
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3009 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003010 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011{
3012 struct alc_spec *spec = codec->spec;
3013 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3014}
3015
3016/*
3017 * Analog capture
3018 */
Takashi Iwai63300792008-01-24 15:31:36 +01003019static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 struct hda_codec *codec,
3021 unsigned int stream_tag,
3022 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003023 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024{
3025 struct alc_spec *spec = codec->spec;
3026
Takashi Iwai63300792008-01-24 15:31:36 +01003027 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003028 stream_tag, 0, format);
3029 return 0;
3030}
3031
Takashi Iwai63300792008-01-24 15:31:36 +01003032static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003033 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003034 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035{
3036 struct alc_spec *spec = codec->spec;
3037
Takashi Iwai888afa12008-03-18 09:57:50 +01003038 snd_hda_codec_cleanup_stream(codec,
3039 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003040 return 0;
3041}
3042
3043
3044/*
3045 */
3046static struct hda_pcm_stream alc880_pcm_analog_playback = {
3047 .substreams = 1,
3048 .channels_min = 2,
3049 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003051 .ops = {
3052 .open = alc880_playback_pcm_open,
3053 .prepare = alc880_playback_pcm_prepare,
3054 .cleanup = alc880_playback_pcm_cleanup
3055 },
3056};
3057
3058static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003059 .substreams = 1,
3060 .channels_min = 2,
3061 .channels_max = 2,
3062 /* NID is set in alc_build_pcms */
3063};
3064
3065static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3066 .substreams = 1,
3067 .channels_min = 2,
3068 .channels_max = 2,
3069 /* NID is set in alc_build_pcms */
3070};
3071
3072static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3073 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003074 .channels_min = 2,
3075 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003078 .prepare = alc880_alt_capture_pcm_prepare,
3079 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080 },
3081};
3082
3083static struct hda_pcm_stream alc880_pcm_digital_playback = {
3084 .substreams = 1,
3085 .channels_min = 2,
3086 .channels_max = 2,
3087 /* NID is set in alc_build_pcms */
3088 .ops = {
3089 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003090 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003091 .prepare = alc880_dig_playback_pcm_prepare,
3092 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093 },
3094};
3095
3096static struct hda_pcm_stream alc880_pcm_digital_capture = {
3097 .substreams = 1,
3098 .channels_min = 2,
3099 .channels_max = 2,
3100 /* NID is set in alc_build_pcms */
3101};
3102
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003103/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003104static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003105 .substreams = 0,
3106 .channels_min = 0,
3107 .channels_max = 0,
3108};
3109
Linus Torvalds1da177e2005-04-16 15:20:36 -07003110static int alc_build_pcms(struct hda_codec *codec)
3111{
3112 struct alc_spec *spec = codec->spec;
3113 struct hda_pcm *info = spec->pcm_rec;
3114 int i;
3115
3116 codec->num_pcms = 1;
3117 codec->pcm_info = info;
3118
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003119 if (spec->no_analog)
3120 goto skip_analog;
3121
Linus Torvalds1da177e2005-04-16 15:20:36 -07003122 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003123 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003124 if (snd_BUG_ON(!spec->multiout.dac_nids))
3125 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003126 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3127 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3128 }
3129 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003130 if (snd_BUG_ON(!spec->adc_nids))
3131 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003132 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3133 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3134 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003135
Takashi Iwai4a471b72005-12-07 13:56:29 +01003136 if (spec->channel_mode) {
3137 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3138 for (i = 0; i < spec->num_channel_mode; i++) {
3139 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3140 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3141 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003142 }
3143 }
3144
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003145 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003146 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003147 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003148 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003149 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003150 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003151 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003152 if (spec->dig_out_type)
3153 info->pcm_type = spec->dig_out_type;
3154 else
3155 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003156 if (spec->multiout.dig_out_nid &&
3157 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003158 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3159 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3160 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003161 if (spec->dig_in_nid &&
3162 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3164 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3165 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003166 /* FIXME: do we need this for all Realtek codec models? */
3167 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003168 }
3169
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003170 if (spec->no_analog)
3171 return 0;
3172
Takashi Iwaie08a0072006-09-07 17:52:14 +02003173 /* If the use of more than one ADC is requested for the current
3174 * model, configure a second analog capture-only PCM.
3175 */
3176 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003177 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3178 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003179 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003180 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003181 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003182 if (spec->alt_dac_nid) {
3183 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3184 *spec->stream_analog_alt_playback;
3185 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3186 spec->alt_dac_nid;
3187 } else {
3188 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3189 alc_pcm_null_stream;
3190 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3191 }
3192 if (spec->num_adc_nids > 1) {
3193 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3194 *spec->stream_analog_alt_capture;
3195 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3196 spec->adc_nids[1];
3197 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3198 spec->num_adc_nids - 1;
3199 } else {
3200 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3201 alc_pcm_null_stream;
3202 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003203 }
3204 }
3205
Linus Torvalds1da177e2005-04-16 15:20:36 -07003206 return 0;
3207}
3208
Takashi Iwai603c4012008-07-30 15:01:44 +02003209static void alc_free_kctls(struct hda_codec *codec)
3210{
3211 struct alc_spec *spec = codec->spec;
3212
3213 if (spec->kctls.list) {
3214 struct snd_kcontrol_new *kctl = spec->kctls.list;
3215 int i;
3216 for (i = 0; i < spec->kctls.used; i++)
3217 kfree(kctl[i].name);
3218 }
3219 snd_array_free(&spec->kctls);
3220}
3221
Linus Torvalds1da177e2005-04-16 15:20:36 -07003222static void alc_free(struct hda_codec *codec)
3223{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003224 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003226 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227 return;
3228
Takashi Iwai603c4012008-07-30 15:01:44 +02003229 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003231 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003232}
3233
Takashi Iwaie044c392008-10-27 16:56:24 +01003234#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003235static int alc_resume(struct hda_codec *codec)
3236{
Takashi Iwaie044c392008-10-27 16:56:24 +01003237 codec->patch_ops.init(codec);
3238 snd_hda_codec_resume_amp(codec);
3239 snd_hda_codec_resume_cache(codec);
3240 return 0;
3241}
Takashi Iwaie044c392008-10-27 16:56:24 +01003242#endif
3243
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244/*
3245 */
3246static struct hda_codec_ops alc_patch_ops = {
3247 .build_controls = alc_build_controls,
3248 .build_pcms = alc_build_pcms,
3249 .init = alc_init,
3250 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003251 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003252#ifdef SND_HDA_NEEDS_RESUME
3253 .resume = alc_resume,
3254#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003255#ifdef CONFIG_SND_HDA_POWER_SAVE
3256 .check_power_status = alc_check_power_status,
3257#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003258};
3259
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003260
3261/*
3262 * Test configuration for debugging
3263 *
3264 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3265 * enum controls.
3266 */
3267#ifdef CONFIG_SND_DEBUG
3268static hda_nid_t alc880_test_dac_nids[4] = {
3269 0x02, 0x03, 0x04, 0x05
3270};
3271
3272static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003273 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003274 .items = {
3275 { "In-1", 0x0 },
3276 { "In-2", 0x1 },
3277 { "In-3", 0x2 },
3278 { "In-4", 0x3 },
3279 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003280 { "Front", 0x5 },
3281 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003282 },
3283};
3284
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003285static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003286 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003287 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003288 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003289 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003290};
3291
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003292static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3293 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003294{
3295 static char *texts[] = {
3296 "N/A", "Line Out", "HP Out",
3297 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3298 };
3299 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3300 uinfo->count = 1;
3301 uinfo->value.enumerated.items = 8;
3302 if (uinfo->value.enumerated.item >= 8)
3303 uinfo->value.enumerated.item = 7;
3304 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3305 return 0;
3306}
3307
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003308static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3309 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003310{
3311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3312 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3313 unsigned int pin_ctl, item = 0;
3314
3315 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3316 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3317 if (pin_ctl & AC_PINCTL_OUT_EN) {
3318 if (pin_ctl & AC_PINCTL_HP_EN)
3319 item = 2;
3320 else
3321 item = 1;
3322 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3323 switch (pin_ctl & AC_PINCTL_VREFEN) {
3324 case AC_PINCTL_VREF_HIZ: item = 3; break;
3325 case AC_PINCTL_VREF_50: item = 4; break;
3326 case AC_PINCTL_VREF_GRD: item = 5; break;
3327 case AC_PINCTL_VREF_80: item = 6; break;
3328 case AC_PINCTL_VREF_100: item = 7; break;
3329 }
3330 }
3331 ucontrol->value.enumerated.item[0] = item;
3332 return 0;
3333}
3334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003335static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3336 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003337{
3338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3339 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3340 static unsigned int ctls[] = {
3341 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3342 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3343 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3344 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3345 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3346 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3347 };
3348 unsigned int old_ctl, new_ctl;
3349
3350 old_ctl = snd_hda_codec_read(codec, nid, 0,
3351 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3352 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3353 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003354 int val;
3355 snd_hda_codec_write_cache(codec, nid, 0,
3356 AC_VERB_SET_PIN_WIDGET_CONTROL,
3357 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003358 val = ucontrol->value.enumerated.item[0] >= 3 ?
3359 HDA_AMP_MUTE : 0;
3360 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3361 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003362 return 1;
3363 }
3364 return 0;
3365}
3366
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003367static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3368 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003369{
3370 static char *texts[] = {
3371 "Front", "Surround", "CLFE", "Side"
3372 };
3373 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3374 uinfo->count = 1;
3375 uinfo->value.enumerated.items = 4;
3376 if (uinfo->value.enumerated.item >= 4)
3377 uinfo->value.enumerated.item = 3;
3378 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3379 return 0;
3380}
3381
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003382static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3383 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003384{
3385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3386 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3387 unsigned int sel;
3388
3389 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3390 ucontrol->value.enumerated.item[0] = sel & 3;
3391 return 0;
3392}
3393
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003394static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3395 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003396{
3397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3398 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3399 unsigned int sel;
3400
3401 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3402 if (ucontrol->value.enumerated.item[0] != sel) {
3403 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003404 snd_hda_codec_write_cache(codec, nid, 0,
3405 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003406 return 1;
3407 }
3408 return 0;
3409}
3410
3411#define PIN_CTL_TEST(xname,nid) { \
3412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3413 .name = xname, \
3414 .info = alc_test_pin_ctl_info, \
3415 .get = alc_test_pin_ctl_get, \
3416 .put = alc_test_pin_ctl_put, \
3417 .private_value = nid \
3418 }
3419
3420#define PIN_SRC_TEST(xname,nid) { \
3421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3422 .name = xname, \
3423 .info = alc_test_pin_src_info, \
3424 .get = alc_test_pin_src_get, \
3425 .put = alc_test_pin_src_put, \
3426 .private_value = nid \
3427 }
3428
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003429static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3431 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3432 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3433 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3436 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3437 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003438 PIN_CTL_TEST("Front Pin Mode", 0x14),
3439 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3440 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3441 PIN_CTL_TEST("Side Pin Mode", 0x17),
3442 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3443 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3444 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3445 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3446 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3447 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3448 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3449 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3450 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3451 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3452 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3453 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3454 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3455 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3456 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3457 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003460 {
3461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3462 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003463 .info = alc_ch_mode_info,
3464 .get = alc_ch_mode_get,
3465 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003466 },
3467 { } /* end */
3468};
3469
3470static struct hda_verb alc880_test_init_verbs[] = {
3471 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003480 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3483 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003485 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3489 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003490 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003495 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3497 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3500 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003501 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3504 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003506 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003508 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003510 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003512 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003513 /* Analog input/passthru */
3514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003519 { }
3520};
3521#endif
3522
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523/*
3524 */
3525
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003526static const char *alc880_models[ALC880_MODEL_LAST] = {
3527 [ALC880_3ST] = "3stack",
3528 [ALC880_TCL_S700] = "tcl",
3529 [ALC880_3ST_DIG] = "3stack-digout",
3530 [ALC880_CLEVO] = "clevo",
3531 [ALC880_5ST] = "5stack",
3532 [ALC880_5ST_DIG] = "5stack-digout",
3533 [ALC880_W810] = "w810",
3534 [ALC880_Z71V] = "z71v",
3535 [ALC880_6ST] = "6stack",
3536 [ALC880_6ST_DIG] = "6stack-digout",
3537 [ALC880_ASUS] = "asus",
3538 [ALC880_ASUS_W1V] = "asus-w1v",
3539 [ALC880_ASUS_DIG] = "asus-dig",
3540 [ALC880_ASUS_DIG2] = "asus-dig2",
3541 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003542 [ALC880_UNIWILL_P53] = "uniwill-p53",
3543 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003544 [ALC880_F1734] = "F1734",
3545 [ALC880_LG] = "lg",
3546 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003547 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003548#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003549 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003550#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003551 [ALC880_AUTO] = "auto",
3552};
3553
3554static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003555 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003556 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3557 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3558 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3559 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3560 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3561 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3562 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3563 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003564 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3565 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003566 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3567 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3568 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3569 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3570 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3571 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3572 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3573 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3574 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3575 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003576 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003577 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3578 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3579 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003580 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003581 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003582 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3583 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003584 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3585 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003586 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3587 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3588 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3589 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003590 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3591 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003592 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003593 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003594 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003595 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003596 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3597 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003598 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003599 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003600 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003602 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003603 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003604 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003605 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003606 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3608 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003609 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003610 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3611 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3612 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3613 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003614 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3615 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003616 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003617 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003618 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3619 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003620 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3621 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3622 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003623 /* default Intel */
3624 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003625 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3626 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003627 {}
3628};
3629
Takashi Iwai16ded522005-06-10 19:58:24 +02003630/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003631 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003632 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003633static struct alc_config_preset alc880_presets[] = {
3634 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003635 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003636 .init_verbs = { alc880_volume_init_verbs,
3637 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003638 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003639 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003640 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3641 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003642 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003643 .input_mux = &alc880_capture_source,
3644 },
3645 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003646 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003647 .init_verbs = { alc880_volume_init_verbs,
3648 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003649 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003650 .dac_nids = alc880_dac_nids,
3651 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003652 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3653 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003654 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003655 .input_mux = &alc880_capture_source,
3656 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003657 [ALC880_TCL_S700] = {
3658 .mixers = { alc880_tcl_s700_mixer },
3659 .init_verbs = { alc880_volume_init_verbs,
3660 alc880_pin_tcl_S700_init_verbs,
3661 alc880_gpio2_init_verbs },
3662 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3663 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003664 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3665 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003666 .hp_nid = 0x03,
3667 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3668 .channel_mode = alc880_2_jack_modes,
3669 .input_mux = &alc880_capture_source,
3670 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003672 .mixers = { alc880_three_stack_mixer,
3673 alc880_five_stack_mixer},
3674 .init_verbs = { alc880_volume_init_verbs,
3675 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003676 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3677 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003678 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3679 .channel_mode = alc880_fivestack_modes,
3680 .input_mux = &alc880_capture_source,
3681 },
3682 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003683 .mixers = { alc880_three_stack_mixer,
3684 alc880_five_stack_mixer },
3685 .init_verbs = { alc880_volume_init_verbs,
3686 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003687 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3688 .dac_nids = alc880_dac_nids,
3689 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3691 .channel_mode = alc880_fivestack_modes,
3692 .input_mux = &alc880_capture_source,
3693 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003694 [ALC880_6ST] = {
3695 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003696 .init_verbs = { alc880_volume_init_verbs,
3697 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003698 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3699 .dac_nids = alc880_6st_dac_nids,
3700 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3701 .channel_mode = alc880_sixstack_modes,
3702 .input_mux = &alc880_6stack_capture_source,
3703 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003704 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003705 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003706 .init_verbs = { alc880_volume_init_verbs,
3707 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3709 .dac_nids = alc880_6st_dac_nids,
3710 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3712 .channel_mode = alc880_sixstack_modes,
3713 .input_mux = &alc880_6stack_capture_source,
3714 },
3715 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003717 .init_verbs = { alc880_volume_init_verbs,
3718 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003719 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003720 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3721 .dac_nids = alc880_w810_dac_nids,
3722 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003723 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3724 .channel_mode = alc880_w810_modes,
3725 .input_mux = &alc880_capture_source,
3726 },
3727 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003728 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003729 .init_verbs = { alc880_volume_init_verbs,
3730 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003731 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3732 .dac_nids = alc880_z71v_dac_nids,
3733 .dig_out_nid = ALC880_DIGOUT_NID,
3734 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003735 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3736 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003737 .input_mux = &alc880_capture_source,
3738 },
3739 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003740 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003741 .init_verbs = { alc880_volume_init_verbs,
3742 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003743 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3744 .dac_nids = alc880_f1734_dac_nids,
3745 .hp_nid = 0x02,
3746 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3747 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003748 .input_mux = &alc880_f1734_capture_source,
3749 .unsol_event = alc880_uniwill_p53_unsol_event,
3750 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003751 },
3752 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003754 .init_verbs = { alc880_volume_init_verbs,
3755 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003756 alc880_gpio1_init_verbs },
3757 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3758 .dac_nids = alc880_asus_dac_nids,
3759 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3760 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003761 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003762 .input_mux = &alc880_capture_source,
3763 },
3764 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003765 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003766 .init_verbs = { alc880_volume_init_verbs,
3767 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003768 alc880_gpio1_init_verbs },
3769 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3770 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003771 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3773 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003774 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003775 .input_mux = &alc880_capture_source,
3776 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003777 [ALC880_ASUS_DIG2] = {
3778 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003779 .init_verbs = { alc880_volume_init_verbs,
3780 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003781 alc880_gpio2_init_verbs }, /* use GPIO2 */
3782 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3783 .dac_nids = alc880_asus_dac_nids,
3784 .dig_out_nid = ALC880_DIGOUT_NID,
3785 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3786 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003787 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003788 .input_mux = &alc880_capture_source,
3789 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003790 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003792 .init_verbs = { alc880_volume_init_verbs,
3793 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003794 alc880_gpio1_init_verbs },
3795 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3796 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003797 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3799 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003800 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003801 .input_mux = &alc880_capture_source,
3802 },
3803 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003804 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003805 .init_verbs = { alc880_volume_init_verbs,
3806 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3808 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003809 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3811 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003812 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003813 .input_mux = &alc880_capture_source,
3814 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003815 [ALC880_UNIWILL] = {
3816 .mixers = { alc880_uniwill_mixer },
3817 .init_verbs = { alc880_volume_init_verbs,
3818 alc880_uniwill_init_verbs },
3819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3820 .dac_nids = alc880_asus_dac_nids,
3821 .dig_out_nid = ALC880_DIGOUT_NID,
3822 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3823 .channel_mode = alc880_threestack_modes,
3824 .need_dac_fix = 1,
3825 .input_mux = &alc880_capture_source,
3826 .unsol_event = alc880_uniwill_unsol_event,
3827 .init_hook = alc880_uniwill_automute,
3828 },
3829 [ALC880_UNIWILL_P53] = {
3830 .mixers = { alc880_uniwill_p53_mixer },
3831 .init_verbs = { alc880_volume_init_verbs,
3832 alc880_uniwill_p53_init_verbs },
3833 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3834 .dac_nids = alc880_asus_dac_nids,
3835 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003836 .channel_mode = alc880_threestack_modes,
3837 .input_mux = &alc880_capture_source,
3838 .unsol_event = alc880_uniwill_p53_unsol_event,
3839 .init_hook = alc880_uniwill_p53_hp_automute,
3840 },
3841 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003842 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003843 .init_verbs = { alc880_volume_init_verbs,
3844 alc880_uniwill_p53_init_verbs,
3845 alc880_beep_init_verbs },
3846 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3847 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003848 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003849 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3850 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003851 .input_mux = &alc880_capture_source,
3852 .unsol_event = alc880_uniwill_p53_unsol_event,
3853 .init_hook = alc880_uniwill_p53_hp_automute,
3854 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003855 [ALC880_CLEVO] = {
3856 .mixers = { alc880_three_stack_mixer },
3857 .init_verbs = { alc880_volume_init_verbs,
3858 alc880_pin_clevo_init_verbs },
3859 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3860 .dac_nids = alc880_dac_nids,
3861 .hp_nid = 0x03,
3862 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3863 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003864 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003865 .input_mux = &alc880_capture_source,
3866 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003867 [ALC880_LG] = {
3868 .mixers = { alc880_lg_mixer },
3869 .init_verbs = { alc880_volume_init_verbs,
3870 alc880_lg_init_verbs },
3871 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3872 .dac_nids = alc880_lg_dac_nids,
3873 .dig_out_nid = ALC880_DIGOUT_NID,
3874 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3875 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003876 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003877 .input_mux = &alc880_lg_capture_source,
3878 .unsol_event = alc880_lg_unsol_event,
3879 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003880#ifdef CONFIG_SND_HDA_POWER_SAVE
3881 .loopbacks = alc880_lg_loopbacks,
3882#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003883 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003884 [ALC880_LG_LW] = {
3885 .mixers = { alc880_lg_lw_mixer },
3886 .init_verbs = { alc880_volume_init_verbs,
3887 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003889 .dac_nids = alc880_dac_nids,
3890 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003891 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3892 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003893 .input_mux = &alc880_lg_lw_capture_source,
3894 .unsol_event = alc880_lg_lw_unsol_event,
3895 .init_hook = alc880_lg_lw_automute,
3896 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003897 [ALC880_MEDION_RIM] = {
3898 .mixers = { alc880_medion_rim_mixer },
3899 .init_verbs = { alc880_volume_init_verbs,
3900 alc880_medion_rim_init_verbs,
3901 alc_gpio2_init_verbs },
3902 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3903 .dac_nids = alc880_dac_nids,
3904 .dig_out_nid = ALC880_DIGOUT_NID,
3905 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3906 .channel_mode = alc880_2_jack_modes,
3907 .input_mux = &alc880_medion_rim_capture_source,
3908 .unsol_event = alc880_medion_rim_unsol_event,
3909 .init_hook = alc880_medion_rim_automute,
3910 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003911#ifdef CONFIG_SND_DEBUG
3912 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003913 .mixers = { alc880_test_mixer },
3914 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003915 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3916 .dac_nids = alc880_test_dac_nids,
3917 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003918 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3919 .channel_mode = alc880_test_modes,
3920 .input_mux = &alc880_test_capture_source,
3921 },
3922#endif
3923};
3924
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925/*
3926 * Automatic parse of I/O pins from the BIOS configuration
3927 */
3928
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003929enum {
3930 ALC_CTL_WIDGET_VOL,
3931 ALC_CTL_WIDGET_MUTE,
3932 ALC_CTL_BIND_MUTE,
3933};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003934static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3936 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003937 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003938};
3939
3940/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003941static int add_control(struct alc_spec *spec, int type, const char *name,
3942 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003943{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003944 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003945
Takashi Iwai603c4012008-07-30 15:01:44 +02003946 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3947 knew = snd_array_new(&spec->kctls);
3948 if (!knew)
3949 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003950 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003951 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003952 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003953 return -ENOMEM;
3954 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003955 return 0;
3956}
3957
3958#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3959#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3960#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3961#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3962#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3963#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3964#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3965#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3966#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3967#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3968#define ALC880_PIN_CD_NID 0x1c
3969
3970/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003971static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3972 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973{
3974 hda_nid_t nid;
3975 int assigned[4];
3976 int i, j;
3977
3978 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003979 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980
3981 /* check the pins hardwired to audio widget */
3982 for (i = 0; i < cfg->line_outs; i++) {
3983 nid = cfg->line_out_pins[i];
3984 if (alc880_is_fixed_pin(nid)) {
3985 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003986 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003987 assigned[idx] = 1;
3988 }
3989 }
3990 /* left pins can be connect to any audio widget */
3991 for (i = 0; i < cfg->line_outs; i++) {
3992 nid = cfg->line_out_pins[i];
3993 if (alc880_is_fixed_pin(nid))
3994 continue;
3995 /* search for an empty channel */
3996 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997 if (!assigned[j]) {
3998 spec->multiout.dac_nids[i] =
3999 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000 assigned[j] = 1;
4001 break;
4002 }
4003 }
4004 }
4005 spec->multiout.num_dacs = cfg->line_outs;
4006 return 0;
4007}
4008
4009/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004010static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4011 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004012{
4013 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004014 static const char *chname[4] = {
4015 "Front", "Surround", NULL /*CLFE*/, "Side"
4016 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 hda_nid_t nid;
4018 int i, err;
4019
4020 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004021 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004022 continue;
4023 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4024 if (i == 2) {
4025 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004026 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4027 "Center Playback Volume",
4028 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4029 HDA_OUTPUT));
4030 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004031 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004032 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4033 "LFE Playback Volume",
4034 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4035 HDA_OUTPUT));
4036 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004038 err = add_control(spec, ALC_CTL_BIND_MUTE,
4039 "Center Playback Switch",
4040 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4041 HDA_INPUT));
4042 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004044 err = add_control(spec, ALC_CTL_BIND_MUTE,
4045 "LFE Playback Switch",
4046 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4047 HDA_INPUT));
4048 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004049 return err;
4050 } else {
4051 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4053 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4054 HDA_OUTPUT));
4055 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 return err;
4057 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004058 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4059 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4060 HDA_INPUT));
4061 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004062 return err;
4063 }
4064 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004065 return 0;
4066}
4067
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004068/* add playback controls for speaker and HP outputs */
4069static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4070 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004071{
4072 hda_nid_t nid;
4073 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004074 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004075
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004076 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 return 0;
4078
4079 if (alc880_is_fixed_pin(pin)) {
4080 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004081 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004082 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004084 else
4085 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 /* control HP volume/switch on the output mixer amp */
4087 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004088 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4090 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004093 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004094 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4095 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4096 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097 return err;
4098 } else if (alc880_is_multi_pin(pin)) {
4099 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004101 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004102 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4103 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4104 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105 return err;
4106 }
4107 return 0;
4108}
4109
4110/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004111static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4112 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004113 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114{
4115 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004116 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117
4118 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004119 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4120 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122 return err;
4123 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004124 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4125 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4126 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127 return err;
4128 return 0;
4129}
4130
4131/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004132static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4133 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004135 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004136 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137
4138 for (i = 0; i < AUTO_PIN_LAST; i++) {
4139 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004140 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004141 err = new_analog_input(spec, cfg->input_pins[i],
4142 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004143 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 if (err < 0)
4145 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004146 imux->items[imux->num_items].label =
4147 auto_pin_cfg_labels[i];
4148 imux->items[imux->num_items].index =
4149 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004150 imux->num_items++;
4151 }
4152 }
4153 return 0;
4154}
4155
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004156static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4157 unsigned int pin_type)
4158{
4159 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4160 pin_type);
4161 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004162 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4163 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004164}
4165
Kailang Yangdf694da2005-12-05 19:42:22 +01004166static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4167 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 int dac_idx)
4169{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004170 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 /* need the manual connection? */
4172 if (alc880_is_multi_pin(nid)) {
4173 struct alc_spec *spec = codec->spec;
4174 int idx = alc880_multi_pin_idx(nid);
4175 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4176 AC_VERB_SET_CONNECT_SEL,
4177 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4178 }
4179}
4180
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004181static int get_pin_type(int line_out_type)
4182{
4183 if (line_out_type == AUTO_PIN_HP_OUT)
4184 return PIN_HP;
4185 else
4186 return PIN_OUT;
4187}
4188
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189static void alc880_auto_init_multi_out(struct hda_codec *codec)
4190{
4191 struct alc_spec *spec = codec->spec;
4192 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004193
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004194 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004195 for (i = 0; i < spec->autocfg.line_outs; i++) {
4196 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004197 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4198 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199 }
4200}
4201
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004202static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004203{
4204 struct alc_spec *spec = codec->spec;
4205 hda_nid_t pin;
4206
Takashi Iwai82bc9552006-03-21 11:24:42 +01004207 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004208 if (pin) /* connect to front */
4209 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004210 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004211 if (pin) /* connect to front */
4212 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4213}
4214
4215static void alc880_auto_init_analog_input(struct hda_codec *codec)
4216{
4217 struct alc_spec *spec = codec->spec;
4218 int i;
4219
4220 for (i = 0; i < AUTO_PIN_LAST; i++) {
4221 hda_nid_t nid = spec->autocfg.input_pins[i];
4222 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004223 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004224 if (nid != ALC880_PIN_CD_NID &&
4225 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
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;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004240 int i, 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
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004271 /* check multiple SPDIF-out (for recent codecs) */
4272 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4273 hda_nid_t dig_nid;
4274 err = snd_hda_get_connections(codec,
4275 spec->autocfg.dig_out_pins[i],
4276 &dig_nid, 1);
4277 if (err < 0)
4278 continue;
4279 if (!i)
4280 spec->multiout.dig_out_nid = dig_nid;
4281 else {
4282 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4283 spec->slave_dig_outs[i - 1] = dig_nid;
4284 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4285 break;
4286 }
4287 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288 if (spec->autocfg.dig_in_pin)
4289 spec->dig_in_nid = ALC880_DIGIN_NID;
4290
Takashi Iwai603c4012008-07-30 15:01:44 +02004291 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004292 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293
Takashi Iwaid88897e2008-10-31 15:01:37 +01004294 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004296 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004297 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298
4299 return 1;
4300}
4301
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004302/* additional initialization for auto-configuration model */
4303static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004305 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004307 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004309 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004310 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311}
4312
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004313static void set_capture_mixer(struct alc_spec *spec)
4314{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004315 static struct snd_kcontrol_new *caps[2][3] = {
4316 { alc_capture_mixer_nosrc1,
4317 alc_capture_mixer_nosrc2,
4318 alc_capture_mixer_nosrc3 },
4319 { alc_capture_mixer1,
4320 alc_capture_mixer2,
4321 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004322 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004323 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4324 int mux;
4325 if (spec->input_mux && spec->input_mux->num_items > 1)
4326 mux = 1;
4327 else
4328 mux = 0;
4329 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4330 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004331}
4332
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004333#define set_beep_amp(spec, nid, idx, dir) \
4334 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4335
4336/*
4337 * OK, here we have finally the patch for ALC880
4338 */
4339
Linus Torvalds1da177e2005-04-16 15:20:36 -07004340static int patch_alc880(struct hda_codec *codec)
4341{
4342 struct alc_spec *spec;
4343 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004344 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004345
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004346 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004347 if (spec == NULL)
4348 return -ENOMEM;
4349
4350 codec->spec = spec;
4351
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004352 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4353 alc880_models,
4354 alc880_cfg_tbl);
4355 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004356 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4357 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004358 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 }
4360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361 if (board_config == ALC880_AUTO) {
4362 /* automatic parse from the BIOS config */
4363 err = alc880_parse_auto_config(codec);
4364 if (err < 0) {
4365 alc_free(codec);
4366 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004367 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004368 printk(KERN_INFO
4369 "hda_codec: Cannot set up configuration "
4370 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004371 board_config = ALC880_3ST;
4372 }
4373 }
4374
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004375 err = snd_hda_attach_beep_device(codec, 0x1);
4376 if (err < 0) {
4377 alc_free(codec);
4378 return err;
4379 }
4380
Kailang Yangdf694da2005-12-05 19:42:22 +01004381 if (board_config != ALC880_AUTO)
4382 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004383
4384 spec->stream_name_analog = "ALC880 Analog";
4385 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4386 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004387 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004388
4389 spec->stream_name_digital = "ALC880 Digital";
4390 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4391 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4392
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004393 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004395 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004396 /* get type */
4397 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 if (wcap != AC_WID_AUD_IN) {
4399 spec->adc_nids = alc880_adc_nids_alt;
4400 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 } else {
4402 spec->adc_nids = alc880_adc_nids;
4403 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 }
4405 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004406 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004408
Takashi Iwai2134ea42008-01-10 16:53:55 +01004409 spec->vmaster_nid = 0x0c;
4410
Linus Torvalds1da177e2005-04-16 15:20:36 -07004411 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004413 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004414#ifdef CONFIG_SND_HDA_POWER_SAVE
4415 if (!spec->loopback.amplist)
4416 spec->loopback.amplist = alc880_loopbacks;
4417#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004418 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004419
4420 return 0;
4421}
4422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423
Linus Torvalds1da177e2005-04-16 15:20:36 -07004424/*
4425 * ALC260 support
4426 */
4427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428static hda_nid_t alc260_dac_nids[1] = {
4429 /* front */
4430 0x02,
4431};
4432
4433static hda_nid_t alc260_adc_nids[1] = {
4434 /* ADC0 */
4435 0x04,
4436};
4437
Kailang Yangdf694da2005-12-05 19:42:22 +01004438static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004439 /* ADC1 */
4440 0x05,
4441};
4442
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004443/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4444 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4445 */
4446static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004447 /* ADC0, ADC1 */
4448 0x04, 0x05
4449};
4450
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451#define ALC260_DIGOUT_NID 0x03
4452#define ALC260_DIGIN_NID 0x06
4453
4454static struct hda_input_mux alc260_capture_source = {
4455 .num_items = 4,
4456 .items = {
4457 { "Mic", 0x0 },
4458 { "Front Mic", 0x1 },
4459 { "Line", 0x2 },
4460 { "CD", 0x4 },
4461 },
4462};
4463
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004464/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004465 * headphone jack and the internal CD lines since these are the only pins at
4466 * which audio can appear. For flexibility, also allow the option of
4467 * recording the mixer output on the second ADC (ADC0 doesn't have a
4468 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004469 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004470static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4471 {
4472 .num_items = 3,
4473 .items = {
4474 { "Mic/Line", 0x0 },
4475 { "CD", 0x4 },
4476 { "Headphone", 0x2 },
4477 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004478 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004479 {
4480 .num_items = 4,
4481 .items = {
4482 { "Mic/Line", 0x0 },
4483 { "CD", 0x4 },
4484 { "Headphone", 0x2 },
4485 { "Mixer", 0x5 },
4486 },
4487 },
4488
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004489};
4490
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004491/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4492 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004493 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004494static struct hda_input_mux alc260_acer_capture_sources[2] = {
4495 {
4496 .num_items = 4,
4497 .items = {
4498 { "Mic", 0x0 },
4499 { "Line", 0x2 },
4500 { "CD", 0x4 },
4501 { "Headphone", 0x5 },
4502 },
4503 },
4504 {
4505 .num_items = 5,
4506 .items = {
4507 { "Mic", 0x0 },
4508 { "Line", 0x2 },
4509 { "CD", 0x4 },
4510 { "Headphone", 0x6 },
4511 { "Mixer", 0x5 },
4512 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004513 },
4514};
Michael Schwingencc959482009-02-22 18:58:45 +01004515
4516/* Maxdata Favorit 100XS */
4517static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4518 {
4519 .num_items = 2,
4520 .items = {
4521 { "Line/Mic", 0x0 },
4522 { "CD", 0x4 },
4523 },
4524 },
4525 {
4526 .num_items = 3,
4527 .items = {
4528 { "Line/Mic", 0x0 },
4529 { "CD", 0x4 },
4530 { "Mixer", 0x5 },
4531 },
4532 },
4533};
4534
Linus Torvalds1da177e2005-04-16 15:20:36 -07004535/*
4536 * This is just place-holder, so there's something for alc_build_pcms to look
4537 * at when it calculates the maximum number of channels. ALC260 has no mixer
4538 * element which allows changing the channel mode, so the verb list is
4539 * never used.
4540 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004541static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004542 { 2, NULL },
4543};
4544
Kailang Yangdf694da2005-12-05 19:42:22 +01004545
4546/* Mixer combinations
4547 *
4548 * basic: base_output + input + pc_beep + capture
4549 * HP: base_output + input + capture_alt
4550 * HP_3013: hp_3013 + input + capture
4551 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004552 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004553 */
4554
4555static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004556 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004557 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004558 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4559 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4560 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4561 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4562 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004563};
Kailang Yangdf694da2005-12-05 19:42:22 +01004564
4565static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004566 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4567 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4568 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4569 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4571 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4572 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4573 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004574 { } /* end */
4575};
4576
Takashi Iwaibec15c32008-01-28 18:16:30 +01004577/* update HP, line and mono out pins according to the master switch */
4578static void alc260_hp_master_update(struct hda_codec *codec,
4579 hda_nid_t hp, hda_nid_t line,
4580 hda_nid_t mono)
4581{
4582 struct alc_spec *spec = codec->spec;
4583 unsigned int val = spec->master_sw ? PIN_HP : 0;
4584 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004585 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004586 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004587 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004588 val);
4589 /* mono (speaker) depending on the HP jack sense */
4590 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004591 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004592 val);
4593}
4594
4595static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4596 struct snd_ctl_elem_value *ucontrol)
4597{
4598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4599 struct alc_spec *spec = codec->spec;
4600 *ucontrol->value.integer.value = spec->master_sw;
4601 return 0;
4602}
4603
4604static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4605 struct snd_ctl_elem_value *ucontrol)
4606{
4607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4608 struct alc_spec *spec = codec->spec;
4609 int val = !!*ucontrol->value.integer.value;
4610 hda_nid_t hp, line, mono;
4611
4612 if (val == spec->master_sw)
4613 return 0;
4614 spec->master_sw = val;
4615 hp = (kcontrol->private_value >> 16) & 0xff;
4616 line = (kcontrol->private_value >> 8) & 0xff;
4617 mono = kcontrol->private_value & 0xff;
4618 alc260_hp_master_update(codec, hp, line, mono);
4619 return 1;
4620}
4621
4622static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4623 {
4624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4625 .name = "Master Playback Switch",
4626 .info = snd_ctl_boolean_mono_info,
4627 .get = alc260_hp_master_sw_get,
4628 .put = alc260_hp_master_sw_put,
4629 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4630 },
4631 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4632 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4633 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4634 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4635 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4636 HDA_OUTPUT),
4637 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4638 { } /* end */
4639};
4640
4641static struct hda_verb alc260_hp_unsol_verbs[] = {
4642 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4643 {},
4644};
4645
4646static void alc260_hp_automute(struct hda_codec *codec)
4647{
4648 struct alc_spec *spec = codec->spec;
4649 unsigned int present;
4650
4651 present = snd_hda_codec_read(codec, 0x10, 0,
4652 AC_VERB_GET_PIN_SENSE, 0);
4653 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4654 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4655}
4656
4657static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4658{
4659 if ((res >> 26) == ALC880_HP_EVENT)
4660 alc260_hp_automute(codec);
4661}
4662
Kailang Yangdf694da2005-12-05 19:42:22 +01004663static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004664 {
4665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4666 .name = "Master Playback Switch",
4667 .info = snd_ctl_boolean_mono_info,
4668 .get = alc260_hp_master_sw_get,
4669 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004670 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004671 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004672 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4673 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4674 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4675 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4676 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004678 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4679 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 { } /* end */
4681};
4682
Kailang Yang3f878302008-08-26 13:02:23 +02004683static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4684 .ops = &snd_hda_bind_vol,
4685 .values = {
4686 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4687 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4688 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4689 0
4690 },
4691};
4692
4693static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4694 .ops = &snd_hda_bind_sw,
4695 .values = {
4696 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4697 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4698 0
4699 },
4700};
4701
4702static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4703 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4704 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4705 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4707 { } /* end */
4708};
4709
Takashi Iwaibec15c32008-01-28 18:16:30 +01004710static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4711 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4712 {},
4713};
4714
4715static void alc260_hp_3013_automute(struct hda_codec *codec)
4716{
4717 struct alc_spec *spec = codec->spec;
4718 unsigned int present;
4719
4720 present = snd_hda_codec_read(codec, 0x15, 0,
4721 AC_VERB_GET_PIN_SENSE, 0);
4722 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004723 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004724}
4725
4726static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4727 unsigned int res)
4728{
4729 if ((res >> 26) == ALC880_HP_EVENT)
4730 alc260_hp_3013_automute(codec);
4731}
4732
Kailang Yang3f878302008-08-26 13:02:23 +02004733static void alc260_hp_3012_automute(struct hda_codec *codec)
4734{
4735 unsigned int present, bits;
4736
4737 present = snd_hda_codec_read(codec, 0x10, 0,
4738 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4739
4740 bits = present ? 0 : PIN_OUT;
4741 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4742 bits);
4743 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4744 bits);
4745 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4746 bits);
4747}
4748
4749static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4750 unsigned int res)
4751{
4752 if ((res >> 26) == ALC880_HP_EVENT)
4753 alc260_hp_3012_automute(codec);
4754}
4755
4756/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004757 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4758 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004759static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004761 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004762 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004763 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4764 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4765 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4766 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004767 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4769 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004770 { } /* end */
4771};
4772
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004773/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4774 * versions of the ALC260 don't act on requests to enable mic bias from NID
4775 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4776 * datasheet doesn't mention this restriction. At this stage it's not clear
4777 * whether this behaviour is intentional or is a hardware bug in chip
4778 * revisions available in early 2006. Therefore for now allow the
4779 * "Headphone Jack Mode" control to span all choices, but if it turns out
4780 * that the lack of mic bias for this NID is intentional we could change the
4781 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4782 *
4783 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4784 * don't appear to make the mic bias available from the "line" jack, even
4785 * though the NID used for this jack (0x14) can supply it. The theory is
4786 * that perhaps Acer have included blocking capacitors between the ALC260
4787 * and the output jack. If this turns out to be the case for all such
4788 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4789 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004790 *
4791 * The C20x Tablet series have a mono internal speaker which is controlled
4792 * via the chip's Mono sum widget and pin complex, so include the necessary
4793 * controls for such models. On models without a "mono speaker" the control
4794 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004795 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004796static struct snd_kcontrol_new alc260_acer_mixer[] = {
4797 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4798 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004799 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004800 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004801 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004802 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004803 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004804 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4805 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4807 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4808 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4809 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4810 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4811 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004812 { } /* end */
4813};
4814
Michael Schwingencc959482009-02-22 18:58:45 +01004815/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4816 */
4817static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4818 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4819 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4820 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4821 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4823 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4824 { } /* end */
4825};
4826
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004827/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4828 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4829 */
4830static struct snd_kcontrol_new alc260_will_mixer[] = {
4831 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4832 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4834 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4835 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4836 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4837 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4838 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4839 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4840 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004841 { } /* end */
4842};
4843
4844/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4845 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4846 */
4847static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4848 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4849 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4851 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4852 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4853 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4854 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4856 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4857 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4858 { } /* end */
4859};
4860
Kailang Yangdf694da2005-12-05 19:42:22 +01004861/*
4862 * initialization verbs
4863 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864static struct hda_verb alc260_init_verbs[] = {
4865 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004867 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004869 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004870 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004871 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004872 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004873 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004875 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004876 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004877 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004878 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004879 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004880 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004881 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004882 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4883 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004884 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004885 /* set connection select to line in (default select for this ADC) */
4886 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004887 /* mute capture amp left and right */
4888 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4889 /* set connection select to line in (default select for this ADC) */
4890 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004891 /* set vol=0 Line-Out mixer amp left and right */
4892 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4893 /* unmute pin widget amp left and right (no gain on this amp) */
4894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4895 /* set vol=0 HP mixer amp left and right */
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897 /* unmute pin widget amp left and right (no gain on this amp) */
4898 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4899 /* set vol=0 Mono mixer amp left and right */
4900 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4901 /* unmute pin widget amp left and right (no gain on this amp) */
4902 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4903 /* unmute LINE-2 out pin */
4904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004905 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4906 * Line In 2 = 0x03
4907 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004908 /* mute analog inputs */
4909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004914 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004915 /* mute Front out path */
4916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4918 /* mute Headphone out path */
4919 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4921 /* mute Mono out path */
4922 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4923 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924 { }
4925};
4926
Takashi Iwai474167d2006-05-17 17:17:43 +02004927#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004928static struct hda_verb alc260_hp_init_verbs[] = {
4929 /* Headphone and output */
4930 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4931 /* mono output */
4932 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4933 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4934 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4935 /* Mic2 (front panel) pin widget for input and vref at 80% */
4936 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4937 /* Line In pin widget for input */
4938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4939 /* Line-2 pin widget for output */
4940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4941 /* CD pin widget for input */
4942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4943 /* unmute amp left and right */
4944 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4945 /* set connection select to line in (default select for this ADC) */
4946 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4947 /* unmute Line-Out mixer amp left and right (volume = 0) */
4948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4949 /* mute pin widget amp left and right (no gain on this amp) */
4950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4951 /* unmute HP mixer amp left and right (volume = 0) */
4952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4953 /* mute pin widget amp left and right (no gain on this amp) */
4954 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004955 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4956 * Line In 2 = 0x03
4957 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004958 /* mute analog inputs */
4959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004964 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4965 /* Unmute Front out path */
4966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4968 /* Unmute Headphone out path */
4969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4971 /* Unmute Mono out path */
4972 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4973 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4974 { }
4975};
Takashi Iwai474167d2006-05-17 17:17:43 +02004976#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004977
4978static struct hda_verb alc260_hp_3013_init_verbs[] = {
4979 /* Line out and output */
4980 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4981 /* mono output */
4982 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4983 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4984 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4985 /* Mic2 (front panel) pin widget for input and vref at 80% */
4986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4987 /* Line In pin widget for input */
4988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4989 /* Headphone pin widget for output */
4990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4991 /* CD pin widget for input */
4992 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4993 /* unmute amp left and right */
4994 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4995 /* set connection select to line in (default select for this ADC) */
4996 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4997 /* unmute Line-Out mixer amp left and right (volume = 0) */
4998 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4999 /* mute pin widget amp left and right (no gain on this amp) */
5000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5001 /* unmute HP mixer amp left and right (volume = 0) */
5002 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5003 /* mute pin widget amp left and right (no gain on this amp) */
5004 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005005 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5006 * Line In 2 = 0x03
5007 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005008 /* mute analog inputs */
5009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005014 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5015 /* Unmute Front out path */
5016 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5018 /* Unmute Headphone out path */
5019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5021 /* Unmute Mono out path */
5022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5024 { }
5025};
5026
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005027/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005028 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5029 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005030 */
5031static struct hda_verb alc260_fujitsu_init_verbs[] = {
5032 /* Disable all GPIOs */
5033 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5034 /* Internal speaker is connected to headphone pin */
5035 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5036 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005038 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5039 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5040 /* Ensure all other unused pins are disabled and muted. */
5041 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005043 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005044 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005045 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005046 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005049
Jonathan Woithef7ace402006-02-28 11:46:14 +01005050 /* Disable digital (SPDIF) pins */
5051 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5052 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005053
Kailang Yangea1fb292008-08-26 12:58:38 +02005054 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005055 * when acting as an output.
5056 */
5057 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5058
5059 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5065 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5066 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5067 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5068 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005069
Jonathan Woithef7ace402006-02-28 11:46:14 +01005070 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5071 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5072 /* Unmute Line1 pin widget output buffer since it starts as an output.
5073 * If the pin mode is changed by the user the pin mode control will
5074 * take care of enabling the pin's input/output buffers as needed.
5075 * Therefore there's no need to enable the input buffer at this
5076 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005077 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005078 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005079 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005080 * mixer ctrl)
5081 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005082 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005083
Jonathan Woithef7ace402006-02-28 11:46:14 +01005084 /* Mute capture amp left and right */
5085 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005086 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005087 * in (on mic1 pin)
5088 */
5089 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005090
Jonathan Woithef7ace402006-02-28 11:46:14 +01005091 /* Do the same for the second ADC: mute capture input amp and
5092 * set ADC connection to line in (on mic1 pin)
5093 */
5094 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5095 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005096
Jonathan Woithef7ace402006-02-28 11:46:14 +01005097 /* Mute all inputs to mixer widget (even unconnected ones) */
5098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5102 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005106
5107 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005108};
5109
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005110/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5111 * similar laptops (adapted from Fujitsu init verbs).
5112 */
5113static struct hda_verb alc260_acer_init_verbs[] = {
5114 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5115 * the headphone jack. Turn this on and rely on the standard mute
5116 * methods whenever the user wants to turn these outputs off.
5117 */
5118 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5119 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5120 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5121 /* Internal speaker/Headphone jack is connected to Line-out pin */
5122 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5123 /* Internal microphone/Mic jack is connected to Mic1 pin */
5124 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5125 /* Line In jack is connected to Line1 pin */
5126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005127 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5128 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005129 /* Ensure all other unused pins are disabled and muted. */
5130 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5131 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005132 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5133 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5136 /* Disable digital (SPDIF) pins */
5137 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5138 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5139
Kailang Yangea1fb292008-08-26 12:58:38 +02005140 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005141 * bus when acting as outputs.
5142 */
5143 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5144 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5145
5146 /* Start with output sum widgets muted and their output gains at min */
5147 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5149 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5150 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5153 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5154 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5155 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5156
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005157 /* Unmute Line-out pin widget amp left and right
5158 * (no equiv mixer ctrl)
5159 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005160 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005161 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5162 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005163 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5164 * inputs. If the pin mode is changed by the user the pin mode control
5165 * will take care of enabling the pin's input/output buffers as needed.
5166 * Therefore there's no need to enable the input buffer at this
5167 * stage.
5168 */
5169 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5171
5172 /* Mute capture amp left and right */
5173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5174 /* Set ADC connection select to match default mixer setting - mic
5175 * (on mic1 pin)
5176 */
5177 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5178
5179 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005180 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005181 */
5182 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005183 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005184
5185 /* Mute all inputs to mixer widget (even unconnected ones) */
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5194
5195 { }
5196};
5197
Michael Schwingencc959482009-02-22 18:58:45 +01005198/* Initialisation sequence for Maxdata Favorit 100XS
5199 * (adapted from Acer init verbs).
5200 */
5201static struct hda_verb alc260_favorit100_init_verbs[] = {
5202 /* GPIO 0 enables the output jack.
5203 * Turn this on and rely on the standard mute
5204 * methods whenever the user wants to turn these outputs off.
5205 */
5206 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5207 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5208 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5209 /* Line/Mic input jack is connected to Mic1 pin */
5210 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5211 /* Ensure all other unused pins are disabled and muted. */
5212 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5213 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5214 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5215 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5217 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5222 /* Disable digital (SPDIF) pins */
5223 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5224 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5225
5226 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5227 * bus when acting as outputs.
5228 */
5229 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5230 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5231
5232 /* Start with output sum widgets muted and their output gains at min */
5233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5242
5243 /* Unmute Line-out pin widget amp left and right
5244 * (no equiv mixer ctrl)
5245 */
5246 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5247 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5248 * inputs. If the pin mode is changed by the user the pin mode control
5249 * will take care of enabling the pin's input/output buffers as needed.
5250 * Therefore there's no need to enable the input buffer at this
5251 * stage.
5252 */
5253 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5254
5255 /* Mute capture amp left and right */
5256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5257 /* Set ADC connection select to match default mixer setting - mic
5258 * (on mic1 pin)
5259 */
5260 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5261
5262 /* Do similar with the second ADC: mute capture input amp and
5263 * set ADC connection to mic to match ALSA's default state.
5264 */
5265 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5266 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5267
5268 /* Mute all inputs to mixer widget (even unconnected ones) */
5269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5277
5278 { }
5279};
5280
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005281static struct hda_verb alc260_will_verbs[] = {
5282 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5283 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5284 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5285 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5286 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5287 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5288 {}
5289};
5290
5291static struct hda_verb alc260_replacer_672v_verbs[] = {
5292 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5293 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5294 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5295
5296 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5297 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5298 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5299
5300 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5301 {}
5302};
5303
5304/* toggle speaker-output according to the hp-jack state */
5305static void alc260_replacer_672v_automute(struct hda_codec *codec)
5306{
5307 unsigned int present;
5308
5309 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5310 present = snd_hda_codec_read(codec, 0x0f, 0,
5311 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5312 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005313 snd_hda_codec_write_cache(codec, 0x01, 0,
5314 AC_VERB_SET_GPIO_DATA, 1);
5315 snd_hda_codec_write_cache(codec, 0x0f, 0,
5316 AC_VERB_SET_PIN_WIDGET_CONTROL,
5317 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005318 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005319 snd_hda_codec_write_cache(codec, 0x01, 0,
5320 AC_VERB_SET_GPIO_DATA, 0);
5321 snd_hda_codec_write_cache(codec, 0x0f, 0,
5322 AC_VERB_SET_PIN_WIDGET_CONTROL,
5323 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005324 }
5325}
5326
5327static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5328 unsigned int res)
5329{
5330 if ((res >> 26) == ALC880_HP_EVENT)
5331 alc260_replacer_672v_automute(codec);
5332}
5333
Kailang Yang3f878302008-08-26 13:02:23 +02005334static struct hda_verb alc260_hp_dc7600_verbs[] = {
5335 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5337 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5338 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5339 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5341 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5342 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5343 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5345 {}
5346};
5347
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005348/* Test configuration for debugging, modelled after the ALC880 test
5349 * configuration.
5350 */
5351#ifdef CONFIG_SND_DEBUG
5352static hda_nid_t alc260_test_dac_nids[1] = {
5353 0x02,
5354};
5355static hda_nid_t alc260_test_adc_nids[2] = {
5356 0x04, 0x05,
5357};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005358/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005359 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005360 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005361 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005362static struct hda_input_mux alc260_test_capture_sources[2] = {
5363 {
5364 .num_items = 7,
5365 .items = {
5366 { "MIC1 pin", 0x0 },
5367 { "MIC2 pin", 0x1 },
5368 { "LINE1 pin", 0x2 },
5369 { "LINE2 pin", 0x3 },
5370 { "CD pin", 0x4 },
5371 { "LINE-OUT pin", 0x5 },
5372 { "HP-OUT pin", 0x6 },
5373 },
5374 },
5375 {
5376 .num_items = 8,
5377 .items = {
5378 { "MIC1 pin", 0x0 },
5379 { "MIC2 pin", 0x1 },
5380 { "LINE1 pin", 0x2 },
5381 { "LINE2 pin", 0x3 },
5382 { "CD pin", 0x4 },
5383 { "Mixer", 0x5 },
5384 { "LINE-OUT pin", 0x6 },
5385 { "HP-OUT pin", 0x7 },
5386 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005387 },
5388};
5389static struct snd_kcontrol_new alc260_test_mixer[] = {
5390 /* Output driver widgets */
5391 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5392 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5393 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5394 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5395 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5396 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5397
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005398 /* Modes for retasking pin widgets
5399 * Note: the ALC260 doesn't seem to act on requests to enable mic
5400 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5401 * mention this restriction. At this stage it's not clear whether
5402 * this behaviour is intentional or is a hardware bug in chip
5403 * revisions available at least up until early 2006. Therefore for
5404 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5405 * choices, but if it turns out that the lack of mic bias for these
5406 * NIDs is intentional we could change their modes from
5407 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5408 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005409 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5410 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5411 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5412 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5413 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5414 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5415
5416 /* Loopback mixer controls */
5417 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5418 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5419 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5420 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5421 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5422 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5423 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5424 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5425 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5426 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005427 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5428 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5429 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5430 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005431
5432 /* Controls for GPIO pins, assuming they are configured as outputs */
5433 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5434 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5435 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5436 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5437
Jonathan Woithe92621f12006-02-28 11:47:47 +01005438 /* Switches to allow the digital IO pins to be enabled. The datasheet
5439 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005440 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005441 */
5442 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5443 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5444
Jonathan Woithef8225f62008-01-08 12:16:54 +01005445 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5446 * this output to turn on an external amplifier.
5447 */
5448 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5449 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5450
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005451 { } /* end */
5452};
5453static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005454 /* Enable all GPIOs as outputs with an initial value of 0 */
5455 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5456 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5457 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5458
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005459 /* Enable retasking pins as output, initially without power amp */
5460 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5461 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5464 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5466
Jonathan Woithe92621f12006-02-28 11:47:47 +01005467 /* Disable digital (SPDIF) pins initially, but users can enable
5468 * them via a mixer switch. In the case of SPDIF-out, this initverb
5469 * payload also sets the generation to 0, output to be in "consumer"
5470 * PCM format, copyright asserted, no pre-emphasis and no validity
5471 * control.
5472 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005473 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5474 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5475
Kailang Yangea1fb292008-08-26 12:58:38 +02005476 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005477 * OUT1 sum bus when acting as an output.
5478 */
5479 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5480 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5481 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5482 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5483
5484 /* Start with output sum widgets muted and their output gains at min */
5485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005495 /* Unmute retasking pin widget output buffers since the default
5496 * state appears to be output. As the pin mode is changed by the
5497 * user the pin mode control will take care of enabling the pin's
5498 * input/output buffers as needed.
5499 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005500 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5504 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5505 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5506 /* Also unmute the mono-out pin widget */
5507 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5508
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005509 /* Mute capture amp left and right */
5510 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005511 /* Set ADC connection select to match default mixer setting (mic1
5512 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005513 */
5514 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5515
5516 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005517 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005518 */
5519 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5520 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5521
5522 /* Mute all inputs to mixer widget (even unconnected ones) */
5523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5531
5532 { }
5533};
5534#endif
5535
Takashi Iwai63300792008-01-24 15:31:36 +01005536#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5537#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005538
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005539#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5540#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5541
Kailang Yangdf694da2005-12-05 19:42:22 +01005542/*
5543 * for BIOS auto-configuration
5544 */
5545
5546static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005547 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005548{
5549 hda_nid_t nid_vol;
5550 unsigned long vol_val, sw_val;
5551 char name[32];
5552 int err;
5553
5554 if (nid >= 0x0f && nid < 0x11) {
5555 nid_vol = nid - 0x7;
5556 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5557 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5558 } else if (nid == 0x11) {
5559 nid_vol = nid - 0x7;
5560 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5561 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5562 } else if (nid >= 0x12 && nid <= 0x15) {
5563 nid_vol = 0x08;
5564 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5565 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5566 } else
5567 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005568
Takashi Iwai863b4512008-10-21 17:01:47 +02005569 if (!(*vol_bits & (1 << nid_vol))) {
5570 /* first control for the volume widget */
5571 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5572 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5573 if (err < 0)
5574 return err;
5575 *vol_bits |= (1 << nid_vol);
5576 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005577 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005578 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5579 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005580 return err;
5581 return 1;
5582}
5583
5584/* add playback controls from the parsed DAC table */
5585static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5586 const struct auto_pin_cfg *cfg)
5587{
5588 hda_nid_t nid;
5589 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005590 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005591
5592 spec->multiout.num_dacs = 1;
5593 spec->multiout.dac_nids = spec->private_dac_nids;
5594 spec->multiout.dac_nids[0] = 0x02;
5595
5596 nid = cfg->line_out_pins[0];
5597 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005598 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005599 if (err < 0)
5600 return err;
5601 }
5602
Takashi Iwai82bc9552006-03-21 11:24:42 +01005603 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005604 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005605 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 if (err < 0)
5607 return err;
5608 }
5609
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005610 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005612 err = alc260_add_playback_controls(spec, nid, "Headphone",
5613 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005614 if (err < 0)
5615 return err;
5616 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005617 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005618}
5619
5620/* create playback/capture controls for input pins */
5621static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5622 const struct auto_pin_cfg *cfg)
5623{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005624 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005625 int i, err, idx;
5626
5627 for (i = 0; i < AUTO_PIN_LAST; i++) {
5628 if (cfg->input_pins[i] >= 0x12) {
5629 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005630 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005631 auto_pin_cfg_labels[i], idx,
5632 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 if (err < 0)
5634 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005635 imux->items[imux->num_items].label =
5636 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 imux->items[imux->num_items].index = idx;
5638 imux->num_items++;
5639 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005640 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005641 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005642 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005643 auto_pin_cfg_labels[i], idx,
5644 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005645 if (err < 0)
5646 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005647 imux->items[imux->num_items].label =
5648 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005649 imux->items[imux->num_items].index = idx;
5650 imux->num_items++;
5651 }
5652 }
5653 return 0;
5654}
5655
5656static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5657 hda_nid_t nid, int pin_type,
5658 int sel_idx)
5659{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005660 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 /* need the manual connection? */
5662 if (nid >= 0x12) {
5663 int idx = nid - 0x12;
5664 snd_hda_codec_write(codec, idx + 0x0b, 0,
5665 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 }
5667}
5668
5669static void alc260_auto_init_multi_out(struct hda_codec *codec)
5670{
5671 struct alc_spec *spec = codec->spec;
5672 hda_nid_t nid;
5673
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005674 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005675 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005676 if (nid) {
5677 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5678 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5679 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005680
Takashi Iwai82bc9552006-03-21 11:24:42 +01005681 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 if (nid)
5683 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5684
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005685 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005686 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005687 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005688}
Kailang Yangdf694da2005-12-05 19:42:22 +01005689
5690#define ALC260_PIN_CD_NID 0x16
5691static void alc260_auto_init_analog_input(struct hda_codec *codec)
5692{
5693 struct alc_spec *spec = codec->spec;
5694 int i;
5695
5696 for (i = 0; i < AUTO_PIN_LAST; i++) {
5697 hda_nid_t nid = spec->autocfg.input_pins[i];
5698 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005699 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005700 if (nid != ALC260_PIN_CD_NID &&
5701 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005702 snd_hda_codec_write(codec, nid, 0,
5703 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 AMP_OUT_MUTE);
5705 }
5706 }
5707}
5708
5709/*
5710 * generic initialization of ADC, input mixers and output mixers
5711 */
5712static struct hda_verb alc260_volume_init_verbs[] = {
5713 /*
5714 * Unmute ADC0-1 and set the default input to mic-in
5715 */
5716 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5717 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5718 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5719 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005720
Kailang Yangdf694da2005-12-05 19:42:22 +01005721 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5722 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005723 * Note: PASD motherboards uses the Line In 2 as the input for
5724 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 */
5726 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005727 /* mute analog inputs */
5728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005733
5734 /*
5735 * Set up output mixers (0x08 - 0x0a)
5736 */
5737 /* set vol=0 to output mixers */
5738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5740 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5741 /* set up input amps for analog loopback */
5742 /* Amp Indices: DAC = 0, mixer = 1 */
5743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5747 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5748 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005749
Kailang Yangdf694da2005-12-05 19:42:22 +01005750 { }
5751};
5752
5753static int alc260_parse_auto_config(struct hda_codec *codec)
5754{
5755 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005756 int err;
5757 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005759 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5760 alc260_ignore);
5761 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005762 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005763 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5764 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005765 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005766 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005767 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005768 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5769 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005770 return err;
5771
5772 spec->multiout.max_channels = 2;
5773
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005774 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005775 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005776 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005777 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005778
Takashi Iwaid88897e2008-10-31 15:01:37 +01005779 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005780
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005781 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005782 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005783
Kailang Yangdf694da2005-12-05 19:42:22 +01005784 return 1;
5785}
5786
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005787/* additional initialization for auto-configuration model */
5788static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005789{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005790 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005791 alc260_auto_init_multi_out(codec);
5792 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005793 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005794 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005795}
5796
Takashi Iwaicb53c622007-08-10 17:21:45 +02005797#ifdef CONFIG_SND_HDA_POWER_SAVE
5798static struct hda_amp_list alc260_loopbacks[] = {
5799 { 0x07, HDA_INPUT, 0 },
5800 { 0x07, HDA_INPUT, 1 },
5801 { 0x07, HDA_INPUT, 2 },
5802 { 0x07, HDA_INPUT, 3 },
5803 { 0x07, HDA_INPUT, 4 },
5804 { } /* end */
5805};
5806#endif
5807
Kailang Yangdf694da2005-12-05 19:42:22 +01005808/*
5809 * ALC260 configurations
5810 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005811static const char *alc260_models[ALC260_MODEL_LAST] = {
5812 [ALC260_BASIC] = "basic",
5813 [ALC260_HP] = "hp",
5814 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005815 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005816 [ALC260_FUJITSU_S702X] = "fujitsu",
5817 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005818 [ALC260_WILL] = "will",
5819 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005820 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005821#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005822 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005823#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005824 [ALC260_AUTO] = "auto",
5825};
5826
5827static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005828 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005829 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005830 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005831 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005832 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005833 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005834 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005835 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005836 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5837 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5838 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5839 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5840 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5841 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5842 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5843 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5844 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005845 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005846 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005847 {}
5848};
5849
Kailang Yangdf694da2005-12-05 19:42:22 +01005850static struct alc_config_preset alc260_presets[] = {
5851 [ALC260_BASIC] = {
5852 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005853 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 .init_verbs = { alc260_init_verbs },
5855 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5856 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005857 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005858 .adc_nids = alc260_adc_nids,
5859 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5860 .channel_mode = alc260_modes,
5861 .input_mux = &alc260_capture_source,
5862 },
5863 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005864 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005865 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005866 .init_verbs = { alc260_init_verbs,
5867 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005868 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5869 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005870 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5871 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005872 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5873 .channel_mode = alc260_modes,
5874 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005875 .unsol_event = alc260_hp_unsol_event,
5876 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005877 },
Kailang Yang3f878302008-08-26 13:02:23 +02005878 [ALC260_HP_DC7600] = {
5879 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005880 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005881 .init_verbs = { alc260_init_verbs,
5882 alc260_hp_dc7600_verbs },
5883 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5884 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005885 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5886 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005887 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5888 .channel_mode = alc260_modes,
5889 .input_mux = &alc260_capture_source,
5890 .unsol_event = alc260_hp_3012_unsol_event,
5891 .init_hook = alc260_hp_3012_automute,
5892 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005893 [ALC260_HP_3013] = {
5894 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005895 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005896 .init_verbs = { alc260_hp_3013_init_verbs,
5897 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005898 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5899 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005900 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5901 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005902 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5903 .channel_mode = alc260_modes,
5904 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005905 .unsol_event = alc260_hp_3013_unsol_event,
5906 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005907 },
5908 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005909 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 .init_verbs = { alc260_fujitsu_init_verbs },
5911 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5912 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005913 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5914 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5916 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005917 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5918 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005919 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005920 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005921 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005922 .init_verbs = { alc260_acer_init_verbs },
5923 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5924 .dac_nids = alc260_dac_nids,
5925 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5926 .adc_nids = alc260_dual_adc_nids,
5927 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5928 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005929 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5930 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005931 },
Michael Schwingencc959482009-02-22 18:58:45 +01005932 [ALC260_FAVORIT100] = {
5933 .mixers = { alc260_favorit100_mixer },
5934 .init_verbs = { alc260_favorit100_init_verbs },
5935 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5936 .dac_nids = alc260_dac_nids,
5937 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5938 .adc_nids = alc260_dual_adc_nids,
5939 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5940 .channel_mode = alc260_modes,
5941 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5942 .input_mux = alc260_favorit100_capture_sources,
5943 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005944 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005945 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005946 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5947 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5948 .dac_nids = alc260_dac_nids,
5949 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5950 .adc_nids = alc260_adc_nids,
5951 .dig_out_nid = ALC260_DIGOUT_NID,
5952 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5953 .channel_mode = alc260_modes,
5954 .input_mux = &alc260_capture_source,
5955 },
5956 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005957 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005958 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5959 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5960 .dac_nids = alc260_dac_nids,
5961 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5962 .adc_nids = alc260_adc_nids,
5963 .dig_out_nid = ALC260_DIGOUT_NID,
5964 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5965 .channel_mode = alc260_modes,
5966 .input_mux = &alc260_capture_source,
5967 .unsol_event = alc260_replacer_672v_unsol_event,
5968 .init_hook = alc260_replacer_672v_automute,
5969 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005970#ifdef CONFIG_SND_DEBUG
5971 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005972 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005973 .init_verbs = { alc260_test_init_verbs },
5974 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5975 .dac_nids = alc260_test_dac_nids,
5976 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5977 .adc_nids = alc260_test_adc_nids,
5978 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5979 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005980 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5981 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005982 },
5983#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005984};
5985
Linus Torvalds1da177e2005-04-16 15:20:36 -07005986static int patch_alc260(struct hda_codec *codec)
5987{
5988 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005989 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005990
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005991 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005992 if (spec == NULL)
5993 return -ENOMEM;
5994
5995 codec->spec = spec;
5996
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005997 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5998 alc260_models,
5999 alc260_cfg_tbl);
6000 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006001 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
6002 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006003 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006004 }
6005
Kailang Yangdf694da2005-12-05 19:42:22 +01006006 if (board_config == ALC260_AUTO) {
6007 /* automatic parse from the BIOS config */
6008 err = alc260_parse_auto_config(codec);
6009 if (err < 0) {
6010 alc_free(codec);
6011 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006012 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006013 printk(KERN_INFO
6014 "hda_codec: Cannot set up configuration "
6015 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006016 board_config = ALC260_BASIC;
6017 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006018 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006019
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006020 err = snd_hda_attach_beep_device(codec, 0x1);
6021 if (err < 0) {
6022 alc_free(codec);
6023 return err;
6024 }
6025
Kailang Yangdf694da2005-12-05 19:42:22 +01006026 if (board_config != ALC260_AUTO)
6027 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006028
6029 spec->stream_name_analog = "ALC260 Analog";
6030 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6031 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6032
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006033 spec->stream_name_digital = "ALC260 Digital";
6034 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6035 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6036
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006037 if (!spec->adc_nids && spec->input_mux) {
6038 /* check whether NID 0x04 is valid */
6039 unsigned int wcap = get_wcaps(codec, 0x04);
6040 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6041 /* get type */
6042 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6043 spec->adc_nids = alc260_adc_nids_alt;
6044 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6045 } else {
6046 spec->adc_nids = alc260_adc_nids;
6047 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6048 }
6049 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006050 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006051 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006052
Takashi Iwai2134ea42008-01-10 16:53:55 +01006053 spec->vmaster_nid = 0x08;
6054
Linus Torvalds1da177e2005-04-16 15:20:36 -07006055 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006056 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006057 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006058#ifdef CONFIG_SND_HDA_POWER_SAVE
6059 if (!spec->loopback.amplist)
6060 spec->loopback.amplist = alc260_loopbacks;
6061#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006062 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006063
6064 return 0;
6065}
6066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006067
Linus Torvalds1da177e2005-04-16 15:20:36 -07006068/*
6069 * ALC882 support
6070 *
6071 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6072 * configuration. Each pin widget can choose any input DACs and a mixer.
6073 * Each ADC is connected from a mixer of all inputs. This makes possible
6074 * 6-channel independent captures.
6075 *
6076 * In addition, an independent DAC for the multi-playback (not used in this
6077 * driver yet).
6078 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006079#define ALC882_DIGOUT_NID 0x06
6080#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006081
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006082static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006083 { 8, NULL }
6084};
6085
6086static hda_nid_t alc882_dac_nids[4] = {
6087 /* front, rear, clfe, rear_surr */
6088 0x02, 0x03, 0x04, 0x05
6089};
6090
Kailang Yangdf694da2005-12-05 19:42:22 +01006091/* identical with ALC880 */
6092#define alc882_adc_nids alc880_adc_nids
6093#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006094
Takashi Iwaie1406342008-02-11 18:32:32 +01006095static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6096static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6097
Linus Torvalds1da177e2005-04-16 15:20:36 -07006098/* input MUX */
6099/* FIXME: should be a matrix-type input source selection */
6100
6101static struct hda_input_mux alc882_capture_source = {
6102 .num_items = 4,
6103 .items = {
6104 { "Mic", 0x0 },
6105 { "Front Mic", 0x1 },
6106 { "Line", 0x2 },
6107 { "CD", 0x4 },
6108 },
6109};
Kailang Yangdf694da2005-12-05 19:42:22 +01006110/*
Kailang Yang272a5272007-05-14 11:00:38 +02006111 * 2ch mode
6112 */
6113static struct hda_verb alc882_3ST_ch2_init[] = {
6114 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6115 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6116 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6117 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6118 { } /* end */
6119};
6120
6121/*
6122 * 6ch mode
6123 */
6124static struct hda_verb alc882_3ST_ch6_init[] = {
6125 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6126 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6127 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6128 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6129 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6130 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6131 { } /* end */
6132};
6133
6134static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6135 { 2, alc882_3ST_ch2_init },
6136 { 6, alc882_3ST_ch6_init },
6137};
6138
6139/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006140 * 6ch mode
6141 */
6142static struct hda_verb alc882_sixstack_ch6_init[] = {
6143 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6144 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6145 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6146 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6147 { } /* end */
6148};
6149
6150/*
6151 * 8ch mode
6152 */
6153static struct hda_verb alc882_sixstack_ch8_init[] = {
6154 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6155 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6156 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6157 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6158 { } /* end */
6159};
6160
6161static struct hda_channel_mode alc882_sixstack_modes[2] = {
6162 { 6, alc882_sixstack_ch6_init },
6163 { 8, alc882_sixstack_ch8_init },
6164};
6165
Takashi Iwai87350ad2007-08-16 18:19:38 +02006166/*
6167 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6168 */
6169
6170/*
6171 * 2ch mode
6172 */
6173static struct hda_verb alc885_mbp_ch2_init[] = {
6174 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6175 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6176 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6177 { } /* end */
6178};
6179
6180/*
6181 * 6ch mode
6182 */
6183static struct hda_verb alc885_mbp_ch6_init[] = {
6184 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6185 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6186 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6187 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6189 { } /* end */
6190};
6191
6192static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6193 { 2, alc885_mbp_ch2_init },
6194 { 6, alc885_mbp_ch6_init },
6195};
6196
6197
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6199 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6200 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006201static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006204 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006205 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006206 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6207 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006208 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6209 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006210 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006211 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6213 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6214 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006218 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6220 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006221 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006223 { } /* end */
6224};
6225
Takashi Iwai87350ad2007-08-16 18:19:38 +02006226static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6228 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6229 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6230 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6232 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6234 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006235 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006236 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6237 { } /* end */
6238};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006239static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006249 { } /* end */
6250};
6251
Kailang Yang272a5272007-05-14 11:00:38 +02006252static struct snd_kcontrol_new alc882_targa_mixer[] = {
6253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6254 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6256 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6257 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6258 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6259 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006263 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6264 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006265 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006266 { } /* end */
6267};
6268
6269/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6270 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6271 */
6272static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6274 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6276 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6277 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6278 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6280 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6281 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6282 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6284 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006285 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006286 { } /* end */
6287};
6288
Takashi Iwai914759b2007-09-06 14:52:04 +02006289static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6294 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6295 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6296 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6298 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006300 { } /* end */
6301};
6302
Kailang Yangdf694da2005-12-05 19:42:22 +01006303static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6304 {
6305 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6306 .name = "Channel Mode",
6307 .info = alc_ch_mode_info,
6308 .get = alc_ch_mode_get,
6309 .put = alc_ch_mode_put,
6310 },
6311 { } /* end */
6312};
6313
Linus Torvalds1da177e2005-04-16 15:20:36 -07006314static struct hda_verb alc882_init_verbs[] = {
6315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006319 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006323 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006327 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006331
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006332 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006334 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006336 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006340 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006341 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006342 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006343 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006344 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006347 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006348 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6351 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6354 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6357 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6360 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006361 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006362 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006363
6364 /* FIXME: use matrix-type input source selection */
6365 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6366 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006371 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006376 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6381 /* ADC1: mute amp left and right */
6382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006383 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006384 /* ADC2: mute amp left and right */
6385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006387 /* ADC3: mute amp left and right */
6388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006389 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390
6391 { }
6392};
6393
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006394static struct hda_verb alc882_eapd_verbs[] = {
6395 /* change to EAPD mode */
6396 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006397 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006398 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006399};
6400
Tobin Davis9102cd12006-12-15 10:02:12 +01006401/* Mac Pro test */
6402static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6403 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6404 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6405 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6406 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6407 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006408 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006409 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6410 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006411 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006412 { } /* end */
6413};
6414
6415static struct hda_verb alc882_macpro_init_verbs[] = {
6416 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6420 /* Front Pin: output 0 (0x0c) */
6421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6423 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6424 /* Front Mic pin: input vref at 80% */
6425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6427 /* Speaker: output */
6428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6430 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6431 /* Headphone output (output 0 - 0x0c) */
6432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6434 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6435
6436 /* FIXME: use matrix-type input source selection */
6437 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6438 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6442 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6443 /* Input mixer2 */
6444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6447 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6448 /* Input mixer3 */
6449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6453 /* ADC1: mute amp left and right */
6454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6455 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6456 /* ADC2: mute amp left and right */
6457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6458 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6459 /* ADC3: mute amp left and right */
6460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6461 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6462
6463 { }
6464};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006465
Takashi Iwai87350ad2007-08-16 18:19:38 +02006466/* Macbook Pro rev3 */
6467static struct hda_verb alc885_mbp3_init_verbs[] = {
6468 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6472 /* Rear mixer */
6473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6476 /* Front Pin: output 0 (0x0c) */
6477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6479 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6480 /* HP Pin: output 0 (0x0d) */
6481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6482 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6485 /* Mic (rear) pin: input vref at 80% */
6486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6488 /* Front Mic pin: input vref at 80% */
6489 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6491 /* Line In pin: use output 1 when in LineOut mode */
6492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6494 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6495
6496 /* FIXME: use matrix-type input source selection */
6497 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6498 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6503 /* Input mixer2 */
6504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6508 /* Input mixer3 */
6509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6513 /* ADC1: mute amp left and right */
6514 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6516 /* ADC2: mute amp left and right */
6517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6519 /* ADC3: mute amp left and right */
6520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6521 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6522
6523 { }
6524};
6525
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006526/* iMac 24 mixer. */
6527static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6528 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6529 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6530 { } /* end */
6531};
6532
6533/* iMac 24 init verbs. */
6534static struct hda_verb alc885_imac24_init_verbs[] = {
6535 /* Internal speakers: output 0 (0x0c) */
6536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6538 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6539 /* Internal speakers: output 0 (0x0c) */
6540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6542 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6543 /* Headphone: output 0 (0x0c) */
6544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6545 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6546 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6547 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6548 /* Front Mic: input vref at 80% */
6549 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6551 { }
6552};
6553
6554/* Toggle speaker-output according to the hp-jack state */
6555static void alc885_imac24_automute(struct hda_codec *codec)
6556{
6557 unsigned int present;
6558
6559 present = snd_hda_codec_read(codec, 0x14, 0,
6560 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006561 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6562 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6563 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6564 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006565}
6566
6567/* Processes unsolicited events. */
6568static void alc885_imac24_unsol_event(struct hda_codec *codec,
6569 unsigned int res)
6570{
6571 /* Headphone insertion or removal. */
6572 if ((res >> 26) == ALC880_HP_EVENT)
6573 alc885_imac24_automute(codec);
6574}
6575
Takashi Iwai87350ad2007-08-16 18:19:38 +02006576static void alc885_mbp3_automute(struct hda_codec *codec)
6577{
6578 unsigned int present;
6579
6580 present = snd_hda_codec_read(codec, 0x15, 0,
6581 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6582 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6583 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6584 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6585 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6586
6587}
6588static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6589 unsigned int res)
6590{
6591 /* Headphone insertion or removal. */
6592 if ((res >> 26) == ALC880_HP_EVENT)
6593 alc885_mbp3_automute(codec);
6594}
6595
6596
Kailang Yang272a5272007-05-14 11:00:38 +02006597static struct hda_verb alc882_targa_verbs[] = {
6598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6599 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6600
6601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6602 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006603
Kailang Yang272a5272007-05-14 11:00:38 +02006604 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6605 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6606 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6607
6608 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6609 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6610 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6611 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6612 { } /* end */
6613};
6614
6615/* toggle speaker-output according to the hp-jack state */
6616static void alc882_targa_automute(struct hda_codec *codec)
6617{
6618 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006619
Kailang Yang272a5272007-05-14 11:00:38 +02006620 present = snd_hda_codec_read(codec, 0x14, 0,
6621 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006622 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6623 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006624 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6625 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006626}
6627
6628static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6629{
6630 /* Looks like the unsol event is incompatible with the standard
6631 * definition. 4bit tag is placed at 26 bit!
6632 */
6633 if (((res >> 26) == ALC880_HP_EVENT)) {
6634 alc882_targa_automute(codec);
6635 }
6636}
6637
6638static struct hda_verb alc882_asus_a7j_verbs[] = {
6639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6641
6642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006645
Kailang Yang272a5272007-05-14 11:00:38 +02006646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6648 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6649
6650 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6651 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6653 { } /* end */
6654};
6655
Takashi Iwai914759b2007-09-06 14:52:04 +02006656static struct hda_verb alc882_asus_a7m_verbs[] = {
6657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6659
6660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006663
Takashi Iwai914759b2007-09-06 14:52:04 +02006664 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6666 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6667
6668 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6669 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6670 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6671 { } /* end */
6672};
6673
Tobin Davis9102cd12006-12-15 10:02:12 +01006674static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6675{
6676 unsigned int gpiostate, gpiomask, gpiodir;
6677
6678 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6679 AC_VERB_GET_GPIO_DATA, 0);
6680
6681 if (!muted)
6682 gpiostate |= (1 << pin);
6683 else
6684 gpiostate &= ~(1 << pin);
6685
6686 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6687 AC_VERB_GET_GPIO_MASK, 0);
6688 gpiomask |= (1 << pin);
6689
6690 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6691 AC_VERB_GET_GPIO_DIRECTION, 0);
6692 gpiodir |= (1 << pin);
6693
6694
6695 snd_hda_codec_write(codec, codec->afg, 0,
6696 AC_VERB_SET_GPIO_MASK, gpiomask);
6697 snd_hda_codec_write(codec, codec->afg, 0,
6698 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6699
6700 msleep(1);
6701
6702 snd_hda_codec_write(codec, codec->afg, 0,
6703 AC_VERB_SET_GPIO_DATA, gpiostate);
6704}
6705
Takashi Iwai7debbe52007-08-16 15:01:03 +02006706/* set up GPIO at initialization */
6707static void alc885_macpro_init_hook(struct hda_codec *codec)
6708{
6709 alc882_gpio_mute(codec, 0, 0);
6710 alc882_gpio_mute(codec, 1, 0);
6711}
6712
6713/* set up GPIO and update auto-muting at initialization */
6714static void alc885_imac24_init_hook(struct hda_codec *codec)
6715{
6716 alc885_macpro_init_hook(codec);
6717 alc885_imac24_automute(codec);
6718}
6719
Kailang Yangdf694da2005-12-05 19:42:22 +01006720/*
6721 * generic initialization of ADC, input mixers and output mixers
6722 */
6723static struct hda_verb alc882_auto_init_verbs[] = {
6724 /*
6725 * Unmute ADC0-2 and set the default input to mic-in
6726 */
6727 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6729 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6731 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6732 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6733
Takashi Iwaicb53c622007-08-10 17:21:45 +02006734 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006735 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006736 * Note: PASD motherboards uses the Line In 2 as the input for
6737 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006738 */
6739 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006745
6746 /*
6747 * Set up output mixers (0x0c - 0x0f)
6748 */
6749 /* set vol=0 to output mixers */
6750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6754 /* set up input amps for analog loopback */
6755 /* Amp Indices: DAC = 0, mixer = 1 */
6756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6762 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6764 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6765 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6766
6767 /* FIXME: use matrix-type input source selection */
6768 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6769 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6774 /* Input mixer2 */
6775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6779 /* Input mixer3 */
6780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6784
6785 { }
6786};
6787
Takashi Iwaicb53c622007-08-10 17:21:45 +02006788#ifdef CONFIG_SND_HDA_POWER_SAVE
6789#define alc882_loopbacks alc880_loopbacks
6790#endif
6791
Kailang Yangdf694da2005-12-05 19:42:22 +01006792/* pcm configuration: identiacal with ALC880 */
6793#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6794#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6795#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6796#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6797
6798/*
6799 * configuration and preset
6800 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006801static const char *alc882_models[ALC882_MODEL_LAST] = {
6802 [ALC882_3ST_DIG] = "3stack-dig",
6803 [ALC882_6ST_DIG] = "6stack-dig",
6804 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006805 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006806 [ALC882_TARGA] = "targa",
6807 [ALC882_ASUS_A7J] = "asus-a7j",
6808 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006809 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006810 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006811 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006812 [ALC882_AUTO] = "auto",
6813};
6814
6815static struct snd_pci_quirk alc882_cfg_tbl[] = {
6816 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006817 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006818 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006819 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006820 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006821 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006822 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006823 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006824 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006825 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6826 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6827 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006828 {}
6829};
6830
6831static struct alc_config_preset alc882_presets[] = {
6832 [ALC882_3ST_DIG] = {
6833 .mixers = { alc882_base_mixer },
6834 .init_verbs = { alc882_init_verbs },
6835 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6836 .dac_nids = alc882_dac_nids,
6837 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 .dig_in_nid = ALC882_DIGIN_NID,
6839 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6840 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006841 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006842 .input_mux = &alc882_capture_source,
6843 },
6844 [ALC882_6ST_DIG] = {
6845 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6846 .init_verbs = { alc882_init_verbs },
6847 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6848 .dac_nids = alc882_dac_nids,
6849 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006850 .dig_in_nid = ALC882_DIGIN_NID,
6851 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6852 .channel_mode = alc882_sixstack_modes,
6853 .input_mux = &alc882_capture_source,
6854 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006855 [ALC882_ARIMA] = {
6856 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6857 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6858 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6859 .dac_nids = alc882_dac_nids,
6860 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6861 .channel_mode = alc882_sixstack_modes,
6862 .input_mux = &alc882_capture_source,
6863 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006864 [ALC882_W2JC] = {
6865 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6866 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6867 alc880_gpio1_init_verbs },
6868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6869 .dac_nids = alc882_dac_nids,
6870 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6871 .channel_mode = alc880_threestack_modes,
6872 .need_dac_fix = 1,
6873 .input_mux = &alc882_capture_source,
6874 .dig_out_nid = ALC882_DIGOUT_NID,
6875 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006876 [ALC885_MBP3] = {
6877 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6878 .init_verbs = { alc885_mbp3_init_verbs,
6879 alc880_gpio1_init_verbs },
6880 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6881 .dac_nids = alc882_dac_nids,
6882 .channel_mode = alc885_mbp_6ch_modes,
6883 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6884 .input_mux = &alc882_capture_source,
6885 .dig_out_nid = ALC882_DIGOUT_NID,
6886 .dig_in_nid = ALC882_DIGIN_NID,
6887 .unsol_event = alc885_mbp3_unsol_event,
6888 .init_hook = alc885_mbp3_automute,
6889 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006890 [ALC885_MACPRO] = {
6891 .mixers = { alc882_macpro_mixer },
6892 .init_verbs = { alc882_macpro_init_verbs },
6893 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6894 .dac_nids = alc882_dac_nids,
6895 .dig_out_nid = ALC882_DIGOUT_NID,
6896 .dig_in_nid = ALC882_DIGIN_NID,
6897 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6898 .channel_mode = alc882_ch_modes,
6899 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006900 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006901 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006902 [ALC885_IMAC24] = {
6903 .mixers = { alc885_imac24_mixer },
6904 .init_verbs = { alc885_imac24_init_verbs },
6905 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6906 .dac_nids = alc882_dac_nids,
6907 .dig_out_nid = ALC882_DIGOUT_NID,
6908 .dig_in_nid = ALC882_DIGIN_NID,
6909 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6910 .channel_mode = alc882_ch_modes,
6911 .input_mux = &alc882_capture_source,
6912 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006913 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006914 },
Kailang Yang272a5272007-05-14 11:00:38 +02006915 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006916 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006917 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6919 .dac_nids = alc882_dac_nids,
6920 .dig_out_nid = ALC882_DIGOUT_NID,
6921 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6922 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006923 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006924 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6925 .channel_mode = alc882_3ST_6ch_modes,
6926 .need_dac_fix = 1,
6927 .input_mux = &alc882_capture_source,
6928 .unsol_event = alc882_targa_unsol_event,
6929 .init_hook = alc882_targa_automute,
6930 },
6931 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006932 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006933 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6934 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6935 .dac_nids = alc882_dac_nids,
6936 .dig_out_nid = ALC882_DIGOUT_NID,
6937 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6938 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006939 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006940 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6941 .channel_mode = alc882_3ST_6ch_modes,
6942 .need_dac_fix = 1,
6943 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006944 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006945 [ALC882_ASUS_A7M] = {
6946 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6947 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6948 alc880_gpio1_init_verbs,
6949 alc882_asus_a7m_verbs },
6950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6951 .dac_nids = alc882_dac_nids,
6952 .dig_out_nid = ALC882_DIGOUT_NID,
6953 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6954 .channel_mode = alc880_threestack_modes,
6955 .need_dac_fix = 1,
6956 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006957 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006958};
6959
6960
6961/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006962 * Pin config fixes
6963 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006964enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006965 PINFIX_ABIT_AW9D_MAX
6966};
6967
6968static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6969 { 0x15, 0x01080104 }, /* side */
6970 { 0x16, 0x01011012 }, /* rear */
6971 { 0x17, 0x01016011 }, /* clfe */
6972 { }
6973};
6974
6975static const struct alc_pincfg *alc882_pin_fixes[] = {
6976 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6977};
6978
6979static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6980 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6981 {}
6982};
6983
6984/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006985 * BIOS auto configuration
6986 */
6987static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6988 hda_nid_t nid, int pin_type,
6989 int dac_idx)
6990{
6991 /* set as output */
6992 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006993 int idx;
6994
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006995 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006996 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6997 idx = 4;
6998 else
6999 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7001
7002}
7003
7004static void alc882_auto_init_multi_out(struct hda_codec *codec)
7005{
7006 struct alc_spec *spec = codec->spec;
7007 int i;
7008
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007009 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01007010 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007011 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007012 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007013 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007014 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007015 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007016 }
7017}
7018
7019static void alc882_auto_init_hp_out(struct hda_codec *codec)
7020{
7021 struct alc_spec *spec = codec->spec;
7022 hda_nid_t pin;
7023
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007024 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007026 /* use dac 0 */
7027 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007028 pin = spec->autocfg.speaker_pins[0];
7029 if (pin)
7030 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007031}
7032
7033#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7034#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7035
7036static void alc882_auto_init_analog_input(struct hda_codec *codec)
7037{
7038 struct alc_spec *spec = codec->spec;
7039 int i;
7040
7041 for (i = 0; i < AUTO_PIN_LAST; i++) {
7042 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007043 if (!nid)
7044 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007045 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007046 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7047 snd_hda_codec_write(codec, nid, 0,
7048 AC_VERB_SET_AMP_GAIN_MUTE,
7049 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 }
7051}
7052
Takashi Iwaif511b012008-08-15 16:46:42 +02007053static void alc882_auto_init_input_src(struct hda_codec *codec)
7054{
7055 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007056 int c;
7057
7058 for (c = 0; c < spec->num_adc_nids; c++) {
7059 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7060 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007061 unsigned int mux_idx;
7062 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007063 int conns, mute, idx, item;
7064
7065 conns = snd_hda_get_connections(codec, nid, conn_list,
7066 ARRAY_SIZE(conn_list));
7067 if (conns < 0)
7068 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007069 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7070 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007071 for (idx = 0; idx < conns; idx++) {
7072 /* if the current connection is the selected one,
7073 * unmute it as default - otherwise mute it
7074 */
7075 mute = AMP_IN_MUTE(idx);
7076 for (item = 0; item < imux->num_items; item++) {
7077 if (imux->items[item].index == idx) {
7078 if (spec->cur_mux[c] == item)
7079 mute = AMP_IN_UNMUTE(idx);
7080 break;
7081 }
7082 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007083 /* check if we have a selector or mixer
7084 * we could check for the widget type instead, but
7085 * just check for Amp-In presence (in case of mixer
7086 * without amp-in there is something wrong, this
7087 * function shouldn't be used or capsrc nid is wrong)
7088 */
7089 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7090 snd_hda_codec_write(codec, nid, 0,
7091 AC_VERB_SET_AMP_GAIN_MUTE,
7092 mute);
7093 else if (mute != AMP_IN_MUTE(idx))
7094 snd_hda_codec_write(codec, nid, 0,
7095 AC_VERB_SET_CONNECT_SEL,
7096 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007097 }
7098 }
7099}
7100
Takashi Iwai776e1842007-08-29 15:07:11 +02007101/* add mic boosts if needed */
7102static int alc_auto_add_mic_boost(struct hda_codec *codec)
7103{
7104 struct alc_spec *spec = codec->spec;
7105 int err;
7106 hda_nid_t nid;
7107
7108 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007109 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007110 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7111 "Mic Boost",
7112 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7113 if (err < 0)
7114 return err;
7115 }
7116 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007117 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007118 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7119 "Front Mic Boost",
7120 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7121 if (err < 0)
7122 return err;
7123 }
7124 return 0;
7125}
7126
Kailang Yangdf694da2005-12-05 19:42:22 +01007127/* almost identical with ALC880 parser... */
7128static int alc882_parse_auto_config(struct hda_codec *codec)
7129{
7130 struct alc_spec *spec = codec->spec;
7131 int err = alc880_parse_auto_config(codec);
7132
7133 if (err < 0)
7134 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007135 else if (!err)
7136 return 0; /* no config found */
7137
7138 err = alc_auto_add_mic_boost(codec);
7139 if (err < 0)
7140 return err;
7141
7142 /* hack - override the init verbs */
7143 spec->init_verbs[0] = alc882_auto_init_verbs;
7144
7145 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007146}
7147
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007148/* additional initialization for auto-configuration model */
7149static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007150{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007151 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 alc882_auto_init_multi_out(codec);
7153 alc882_auto_init_hp_out(codec);
7154 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007155 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007156 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007157 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007158}
7159
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007160static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7161
Linus Torvalds1da177e2005-04-16 15:20:36 -07007162static int patch_alc882(struct hda_codec *codec)
7163{
7164 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007165 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007166
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007167 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007168 if (spec == NULL)
7169 return -ENOMEM;
7170
Linus Torvalds1da177e2005-04-16 15:20:36 -07007171 codec->spec = spec;
7172
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007173 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7174 alc882_models,
7175 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007176
Kailang Yangdf694da2005-12-05 19:42:22 +01007177 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007178 /* Pick up systems that don't supply PCI SSID */
7179 switch (codec->subsystem_id) {
7180 case 0x106b0c00: /* Mac Pro */
7181 board_config = ALC885_MACPRO;
7182 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007183 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007184 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007185 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007186 board_config = ALC885_IMAC24;
7187 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007188 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007189 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007190 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007191 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007192 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007193 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007194 board_config = ALC885_MBP3;
7195 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007196 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007197 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007198 if (codec->revision_id == 0x100101 ||
7199 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007200 alc_free(codec);
7201 return patch_alc883(codec);
7202 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007203 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7204 "trying auto-probe from BIOS...\n");
7205 board_config = ALC882_AUTO;
7206 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007207 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007208
Takashi Iwaif95474e2007-07-10 00:47:43 +02007209 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7210
Kailang Yangdf694da2005-12-05 19:42:22 +01007211 if (board_config == ALC882_AUTO) {
7212 /* automatic parse from the BIOS config */
7213 err = alc882_parse_auto_config(codec);
7214 if (err < 0) {
7215 alc_free(codec);
7216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007217 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007218 printk(KERN_INFO
7219 "hda_codec: Cannot set up configuration "
7220 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 board_config = ALC882_3ST_DIG;
7222 }
7223 }
7224
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007225 err = snd_hda_attach_beep_device(codec, 0x1);
7226 if (err < 0) {
7227 alc_free(codec);
7228 return err;
7229 }
7230
Kailang Yangdf694da2005-12-05 19:42:22 +01007231 if (board_config != ALC882_AUTO)
7232 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007233
Kailang Yang2f893282008-05-27 12:14:47 +02007234 if (codec->vendor_id == 0x10ec0885) {
7235 spec->stream_name_analog = "ALC885 Analog";
7236 spec->stream_name_digital = "ALC885 Digital";
7237 } else {
7238 spec->stream_name_analog = "ALC882 Analog";
7239 spec->stream_name_digital = "ALC882 Digital";
7240 }
7241
Kailang Yangdf694da2005-12-05 19:42:22 +01007242 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7243 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007244 /* FIXME: setup DAC5 */
7245 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7246 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007247
Kailang Yangdf694da2005-12-05 19:42:22 +01007248 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7249 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007250
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007251 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007252 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007253 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007254 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007255 /* get type */
7256 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007257 if (wcap != AC_WID_AUD_IN) {
7258 spec->adc_nids = alc882_adc_nids_alt;
7259 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007260 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007261 } else {
7262 spec->adc_nids = alc882_adc_nids;
7263 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007264 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007265 }
7266 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007267 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007268 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007269
Takashi Iwai2134ea42008-01-10 16:53:55 +01007270 spec->vmaster_nid = 0x0c;
7271
Linus Torvalds1da177e2005-04-16 15:20:36 -07007272 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007273 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007274 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007275#ifdef CONFIG_SND_HDA_POWER_SAVE
7276 if (!spec->loopback.amplist)
7277 spec->loopback.amplist = alc882_loopbacks;
7278#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007279 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007280
7281 return 0;
7282}
7283
7284/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007285 * ALC883 support
7286 *
7287 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7288 * configuration. Each pin widget can choose any input DACs and a mixer.
7289 * Each ADC is connected from a mixer of all inputs. This makes possible
7290 * 6-channel independent captures.
7291 *
7292 * In addition, an independent DAC for the multi-playback (not used in this
7293 * driver yet).
7294 */
7295#define ALC883_DIGOUT_NID 0x06
7296#define ALC883_DIGIN_NID 0x0a
7297
Wu Fengguang3ab90932008-11-17 09:51:09 +01007298#define ALC1200_DIGOUT_NID 0x10
7299
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007300static hda_nid_t alc883_dac_nids[4] = {
7301 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007302 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007303};
7304
7305static hda_nid_t alc883_adc_nids[2] = {
7306 /* ADC1-2 */
7307 0x08, 0x09,
7308};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007309
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007310static hda_nid_t alc883_adc_nids_alt[1] = {
7311 /* ADC1 */
7312 0x08,
7313};
7314
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007315static hda_nid_t alc883_adc_nids_rev[2] = {
7316 /* ADC2-1 */
7317 0x09, 0x08
7318};
7319
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007320#define alc889_adc_nids alc880_adc_nids
7321
Takashi Iwaie1406342008-02-11 18:32:32 +01007322static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7323
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007324static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7325
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007326#define alc889_capsrc_nids alc882_capsrc_nids
7327
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007328/* input MUX */
7329/* FIXME: should be a matrix-type input source selection */
7330
7331static struct hda_input_mux alc883_capture_source = {
7332 .num_items = 4,
7333 .items = {
7334 { "Mic", 0x0 },
7335 { "Front Mic", 0x1 },
7336 { "Line", 0x2 },
7337 { "CD", 0x4 },
7338 },
7339};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007340
Jiang zhe17bba1b2008-06-04 12:11:07 +02007341static struct hda_input_mux alc883_3stack_6ch_intel = {
7342 .num_items = 4,
7343 .items = {
7344 { "Mic", 0x1 },
7345 { "Front Mic", 0x0 },
7346 { "Line", 0x2 },
7347 { "CD", 0x4 },
7348 },
7349};
7350
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007351static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7352 .num_items = 2,
7353 .items = {
7354 { "Mic", 0x1 },
7355 { "Line", 0x2 },
7356 },
7357};
7358
Kailang Yang272a5272007-05-14 11:00:38 +02007359static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7360 .num_items = 4,
7361 .items = {
7362 { "Mic", 0x0 },
7363 { "iMic", 0x1 },
7364 { "Line", 0x2 },
7365 { "CD", 0x4 },
7366 },
7367};
7368
Jiang zhefb97dc62008-03-06 11:07:11 +01007369static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7370 .num_items = 2,
7371 .items = {
7372 { "Mic", 0x0 },
7373 { "Int Mic", 0x1 },
7374 },
7375};
7376
Kailang Yange2757d52008-08-26 13:17:46 +02007377static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7378 .num_items = 3,
7379 .items = {
7380 { "Mic", 0x0 },
7381 { "Front Mic", 0x1 },
7382 { "Line", 0x4 },
7383 },
7384};
7385
7386static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7387 .num_items = 2,
7388 .items = {
7389 { "Mic", 0x0 },
7390 { "Line", 0x2 },
7391 },
7392};
7393
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007394/*
7395 * 2ch mode
7396 */
7397static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7398 { 2, NULL }
7399};
7400
7401/*
7402 * 2ch mode
7403 */
7404static struct hda_verb alc883_3ST_ch2_init[] = {
7405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7407 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7408 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7409 { } /* end */
7410};
7411
7412/*
Tobin Davisb2011312007-09-17 12:45:11 +02007413 * 4ch mode
7414 */
7415static struct hda_verb alc883_3ST_ch4_init[] = {
7416 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7417 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7418 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7419 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7420 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7421 { } /* end */
7422};
7423
7424/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007425 * 6ch mode
7426 */
7427static struct hda_verb alc883_3ST_ch6_init[] = {
7428 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7429 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7430 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7431 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7432 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7433 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7434 { } /* end */
7435};
7436
Tobin Davisb2011312007-09-17 12:45:11 +02007437static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007438 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007439 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007440 { 6, alc883_3ST_ch6_init },
7441};
7442
7443/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007444 * 2ch mode
7445 */
7446static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7447 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7448 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7449 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7450 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7451 { } /* end */
7452};
7453
7454/*
7455 * 4ch mode
7456 */
7457static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7458 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7459 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7462 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7463 { } /* end */
7464};
7465
7466/*
7467 * 6ch mode
7468 */
7469static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7470 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7471 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7472 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7475 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7476 { } /* end */
7477};
7478
7479static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7480 { 2, alc883_3ST_ch2_intel_init },
7481 { 4, alc883_3ST_ch4_intel_init },
7482 { 6, alc883_3ST_ch6_intel_init },
7483};
7484
7485/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007486 * 6ch mode
7487 */
7488static struct hda_verb alc883_sixstack_ch6_init[] = {
7489 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7490 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7491 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7492 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7493 { } /* end */
7494};
7495
7496/*
7497 * 8ch mode
7498 */
7499static struct hda_verb alc883_sixstack_ch8_init[] = {
7500 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7501 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7502 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7503 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7504 { } /* end */
7505};
7506
7507static struct hda_channel_mode alc883_sixstack_modes[2] = {
7508 { 6, alc883_sixstack_ch6_init },
7509 { 8, alc883_sixstack_ch8_init },
7510};
7511
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007512static struct hda_verb alc883_medion_eapd_verbs[] = {
7513 /* eanable EAPD on medion laptop */
7514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7515 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7516 { }
7517};
7518
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007519/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7520 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7521 */
7522
7523static struct snd_kcontrol_new alc883_base_mixer[] = {
7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7526 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7527 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7528 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7529 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7530 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7531 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7533 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7534 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7535 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7536 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7537 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7538 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7542 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007543 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007544 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007545 { } /* end */
7546};
7547
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007548static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7550 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7552 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7553 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7554 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007562 { } /* end */
7563};
7564
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007565static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7567 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7568 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7569 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7573 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7575 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007576 { } /* end */
7577};
7578
Jiang zhefb97dc62008-03-06 11:07:11 +01007579static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7580 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7581 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7583 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7585 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7587 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7588 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7589 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007590 { } /* end */
7591};
7592
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007593static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7594 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7595 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007602 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007605 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007607 { } /* end */
7608};
7609
7610static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7611 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7614 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7619 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7620 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7621 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7622 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7623 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007625 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7627 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007628 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007630 { } /* end */
7631};
7632
Jiang zhe17bba1b2008-06-04 12:11:07 +02007633static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7637 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7639 HDA_OUTPUT),
7640 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7641 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7642 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7649 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7653 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007654 { } /* end */
7655};
7656
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007657static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007658 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007659 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007660 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007661 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007662 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7663 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007664 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7665 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7674 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007675 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007677 { } /* end */
7678};
7679
Kailang Yangccc656c2006-10-17 12:32:26 +02007680static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7681 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7683 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7684 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7685 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7687 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7688 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7689 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7690 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7691 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007695 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007697 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007698};
Kailang Yangccc656c2006-10-17 12:32:26 +02007699
7700static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7703 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007709 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7710 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7711 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007712 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007713};
Kailang Yangccc656c2006-10-17 12:32:26 +02007714
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007715static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007718 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7719 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007724 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007725};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007726
Kailang Yang272a5272007-05-14 11:00:38 +02007727static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7729 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7735 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7736 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007737 { } /* end */
7738};
7739
7740static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7743 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7744 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7745 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7749 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007750 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007751};
Kailang Yang272a5272007-05-14 11:00:38 +02007752
Tobin Davis2880a862007-08-07 11:50:26 +02007753static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007762 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007763};
Tobin Davis2880a862007-08-07 11:50:26 +02007764
Kailang Yange2757d52008-08-26 13:17:46 +02007765static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7769 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7770 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7771 0x0d, 1, 0x0, HDA_OUTPUT),
7772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7773 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7774 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7776 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7778 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7786 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7787 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007789 { } /* end */
7790};
7791
7792static struct hda_bind_ctls alc883_bind_cap_vol = {
7793 .ops = &snd_hda_bind_vol,
7794 .values = {
7795 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7796 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7797 0
7798 },
7799};
7800
7801static struct hda_bind_ctls alc883_bind_cap_switch = {
7802 .ops = &snd_hda_bind_sw,
7803 .values = {
7804 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7805 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7806 0
7807 },
7808};
7809
7810static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7811 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7812 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7815 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007819 { } /* end */
7820};
7821
7822static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007823 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7824 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7825 {
7826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7827 /* .name = "Capture Source", */
7828 .name = "Input Source",
7829 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007830 .info = alc_mux_enum_info,
7831 .get = alc_mux_enum_get,
7832 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007833 },
7834 { } /* end */
7835};
7836
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007837static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7838 {
7839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7840 .name = "Channel Mode",
7841 .info = alc_ch_mode_info,
7842 .get = alc_ch_mode_get,
7843 .put = alc_ch_mode_put,
7844 },
7845 { } /* end */
7846};
7847
7848static struct hda_verb alc883_init_verbs[] = {
7849 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007851 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7852 /* ADC2: mute amp left and right */
7853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7854 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7855 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7859 /* Rear mixer */
7860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7862 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7863 /* CLFE mixer */
7864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7867 /* Side mixer */
7868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7869 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7871
Takashi Iwaicb53c622007-08-10 17:21:45 +02007872 /* mute analog input loopbacks */
7873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007878
7879 /* Front Pin: output 0 (0x0c) */
7880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7882 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 /* Rear Pin: output 1 (0x0d) */
7884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7887 /* CLFE Pin: output 2 (0x0e) */
7888 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7890 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7891 /* Side Pin: output 3 (0x0f) */
7892 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7894 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7895 /* Mic (rear) pin: input vref at 80% */
7896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7897 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7898 /* Front Mic pin: input vref at 80% */
7899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7901 /* Line In pin: input */
7902 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7904 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7905 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7906 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7907 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7908 /* CD pin widget for input */
7909 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7910
7911 /* FIXME: use matrix-type input source selection */
7912 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7913 /* Input mixer2 */
7914 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7917 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007918 /* Input mixer3 */
7919 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007920 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007923 { }
7924};
7925
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007926/* toggle speaker-output according to the hp-jack state */
7927static void alc883_mitac_hp_automute(struct hda_codec *codec)
7928{
7929 unsigned int present;
7930
7931 present = snd_hda_codec_read(codec, 0x15, 0,
7932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7933 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7934 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7935 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7936 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7937}
7938
7939/* auto-toggle front mic */
7940/*
7941static void alc883_mitac_mic_automute(struct hda_codec *codec)
7942{
7943 unsigned int present;
7944 unsigned char bits;
7945
7946 present = snd_hda_codec_read(codec, 0x18, 0,
7947 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7948 bits = present ? HDA_AMP_MUTE : 0;
7949 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7950}
7951*/
7952
7953static void alc883_mitac_automute(struct hda_codec *codec)
7954{
7955 alc883_mitac_hp_automute(codec);
7956 /* alc883_mitac_mic_automute(codec); */
7957}
7958
7959static void alc883_mitac_unsol_event(struct hda_codec *codec,
7960 unsigned int res)
7961{
7962 switch (res >> 26) {
7963 case ALC880_HP_EVENT:
7964 alc883_mitac_hp_automute(codec);
7965 break;
7966 case ALC880_MIC_EVENT:
7967 /* alc883_mitac_mic_automute(codec); */
7968 break;
7969 }
7970}
7971
7972static struct hda_verb alc883_mitac_verbs[] = {
7973 /* HP */
7974 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7976 /* Subwoofer */
7977 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7978 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7979
7980 /* enable unsolicited event */
7981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7982 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7983
7984 { } /* end */
7985};
7986
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007987static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007988 /* HP */
7989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7991 /* Int speaker */
7992 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7994
7995 /* enable unsolicited event */
7996 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007997 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007998
7999 { } /* end */
8000};
8001
Jiang zhefb97dc62008-03-06 11:07:11 +01008002static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8003 /* HP */
8004 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8006 /* Subwoofer */
8007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8009
8010 /* enable unsolicited event */
8011 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8012
8013 { } /* end */
8014};
8015
Kailang Yangccc656c2006-10-17 12:32:26 +02008016static struct hda_verb alc883_tagra_verbs[] = {
8017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8019
8020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8021 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008022
Kailang Yangccc656c2006-10-17 12:32:26 +02008023 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8024 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8025 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8026
8027 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008028 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8029 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8030 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008031
8032 { } /* end */
8033};
8034
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008035static struct hda_verb alc883_lenovo_101e_verbs[] = {
8036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8037 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8038 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8039 { } /* end */
8040};
8041
Kailang Yang272a5272007-05-14 11:00:38 +02008042static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8043 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8044 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8045 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8047 { } /* end */
8048};
8049
8050static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8053 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8054 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8056 { } /* end */
8057};
8058
Kailang Yang189609a2007-08-20 11:31:23 +02008059static struct hda_verb alc883_haier_w66_verbs[] = {
8060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8062
8063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8064
8065 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8066 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8069 { } /* end */
8070};
8071
Kailang Yange2757d52008-08-26 13:17:46 +02008072static struct hda_verb alc888_lenovo_sky_verbs[] = {
8073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8079 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8080 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8081 { } /* end */
8082};
8083
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008084static struct hda_verb alc888_6st_dell_verbs[] = {
8085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8086 { }
8087};
8088
8089static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8090{
8091 unsigned int present, bits;
8092
8093 present = snd_hda_codec_read(codec, 0x1b, 0,
8094 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8095 bits = present ? HDA_AMP_MUTE : 0;
8096 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8097 HDA_AMP_MUTE, bits);
8098 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8099 HDA_AMP_MUTE, bits);
8100 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8101 HDA_AMP_MUTE, bits);
8102}
8103
8104static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8105 unsigned int res)
8106{
8107 switch (res >> 26) {
8108 case ALC880_HP_EVENT:
8109 alc888_3st_hp_front_automute(codec);
8110 break;
8111 }
8112}
8113
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008114static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008115 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008116 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8117 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008118 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008119 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008120};
8121
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008122/*
8123 * 2ch mode
8124 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008125static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008126 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8127 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8128 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8129 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008130 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008131};
8132
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008133/*
8134 * 4ch mode
8135 */
8136static struct hda_verb alc888_3st_hp_4ch_init[] = {
8137 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8138 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8139 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8140 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8141 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8142 { } /* end */
8143};
8144
8145/*
8146 * 6ch mode
8147 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008148static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008149 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8150 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008151 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008152 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8153 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008154 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8155 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008156};
8157
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008158static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008159 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008160 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008161 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008162};
8163
Kailang Yang272a5272007-05-14 11:00:38 +02008164/* toggle front-jack and RCA according to the hp-jack state */
8165static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8166{
8167 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008168
Kailang Yang272a5272007-05-14 11:00:38 +02008169 present = snd_hda_codec_read(codec, 0x1b, 0,
8170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008171 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8172 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8173 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8174 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008175}
8176
8177/* toggle RCA according to the front-jack state */
8178static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8179{
8180 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008181
Kailang Yang272a5272007-05-14 11:00:38 +02008182 present = snd_hda_codec_read(codec, 0x14, 0,
8183 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008184 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8185 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008186}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008187
Kailang Yang272a5272007-05-14 11:00:38 +02008188static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8189 unsigned int res)
8190{
8191 if ((res >> 26) == ALC880_HP_EVENT)
8192 alc888_lenovo_ms7195_front_automute(codec);
8193 if ((res >> 26) == ALC880_FRONT_EVENT)
8194 alc888_lenovo_ms7195_rca_automute(codec);
8195}
8196
8197static struct hda_verb alc883_medion_md2_verbs[] = {
8198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8200
8201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8202
8203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8204 { } /* end */
8205};
8206
8207/* toggle speaker-output according to the hp-jack state */
8208static void alc883_medion_md2_automute(struct hda_codec *codec)
8209{
8210 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008211
Kailang Yang272a5272007-05-14 11:00:38 +02008212 present = snd_hda_codec_read(codec, 0x14, 0,
8213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008214 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8215 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008216}
8217
8218static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8219 unsigned int res)
8220{
8221 if ((res >> 26) == ALC880_HP_EVENT)
8222 alc883_medion_md2_automute(codec);
8223}
8224
Kailang Yangccc656c2006-10-17 12:32:26 +02008225/* toggle speaker-output according to the hp-jack state */
8226static void alc883_tagra_automute(struct hda_codec *codec)
8227{
8228 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008229 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008230
8231 present = snd_hda_codec_read(codec, 0x14, 0,
8232 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008233 bits = present ? HDA_AMP_MUTE : 0;
8234 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8235 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008236 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8237 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008238}
8239
8240static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8241{
8242 if ((res >> 26) == ALC880_HP_EVENT)
8243 alc883_tagra_automute(codec);
8244}
8245
Jiang zhe368c7a92008-03-04 11:20:33 +01008246/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008247static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008248{
8249 unsigned int present;
8250 unsigned char bits;
8251
8252 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8253 & AC_PINSENSE_PRESENCE;
8254 bits = present ? HDA_AMP_MUTE : 0;
8255 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8256 HDA_AMP_MUTE, bits);
8257}
8258
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008259static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8260{
8261 unsigned int present;
8262
8263 present = snd_hda_codec_read(codec, 0x18, 0,
8264 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8265 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8266 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8267}
8268
8269static void alc883_clevo_m720_automute(struct hda_codec *codec)
8270{
8271 alc883_clevo_m720_hp_automute(codec);
8272 alc883_clevo_m720_mic_automute(codec);
8273}
8274
8275static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008276 unsigned int res)
8277{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008278 switch (res >> 26) {
8279 case ALC880_HP_EVENT:
8280 alc883_clevo_m720_hp_automute(codec);
8281 break;
8282 case ALC880_MIC_EVENT:
8283 alc883_clevo_m720_mic_automute(codec);
8284 break;
8285 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008286}
8287
Jiang zhefb97dc62008-03-06 11:07:11 +01008288/* toggle speaker-output according to the hp-jack state */
8289static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8290{
8291 unsigned int present;
8292 unsigned char bits;
8293
8294 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8295 & AC_PINSENSE_PRESENCE;
8296 bits = present ? HDA_AMP_MUTE : 0;
8297 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8298 HDA_AMP_MUTE, bits);
8299}
8300
8301static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8302 unsigned int res)
8303{
8304 if ((res >> 26) == ALC880_HP_EVENT)
8305 alc883_2ch_fujitsu_pi2515_automute(codec);
8306}
8307
Kailang Yang189609a2007-08-20 11:31:23 +02008308static void alc883_haier_w66_automute(struct hda_codec *codec)
8309{
8310 unsigned int present;
8311 unsigned char bits;
8312
8313 present = snd_hda_codec_read(codec, 0x1b, 0,
8314 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8315 bits = present ? 0x80 : 0;
8316 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8317 0x80, bits);
8318}
8319
8320static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8321 unsigned int res)
8322{
8323 if ((res >> 26) == ALC880_HP_EVENT)
8324 alc883_haier_w66_automute(codec);
8325}
8326
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008327static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8328{
8329 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008330 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008331
8332 present = snd_hda_codec_read(codec, 0x14, 0,
8333 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008334 bits = present ? HDA_AMP_MUTE : 0;
8335 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8336 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008337}
8338
8339static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8340{
8341 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008342 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008343
8344 present = snd_hda_codec_read(codec, 0x1b, 0,
8345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008346 bits = present ? HDA_AMP_MUTE : 0;
8347 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8348 HDA_AMP_MUTE, bits);
8349 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8350 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008351}
8352
8353static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8354 unsigned int res)
8355{
8356 if ((res >> 26) == ALC880_HP_EVENT)
8357 alc883_lenovo_101e_all_automute(codec);
8358 if ((res >> 26) == ALC880_FRONT_EVENT)
8359 alc883_lenovo_101e_ispeaker_automute(codec);
8360}
8361
Takashi Iwai676a9b52007-08-16 15:23:35 +02008362/* toggle speaker-output according to the hp-jack state */
8363static void alc883_acer_aspire_automute(struct hda_codec *codec)
8364{
8365 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008366
Takashi Iwai676a9b52007-08-16 15:23:35 +02008367 present = snd_hda_codec_read(codec, 0x14, 0,
8368 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8369 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8370 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8371 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8372 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8373}
8374
8375static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8376 unsigned int res)
8377{
8378 if ((res >> 26) == ALC880_HP_EVENT)
8379 alc883_acer_aspire_automute(codec);
8380}
8381
Kailang Yangd1a991a2007-08-15 16:21:59 +02008382static struct hda_verb alc883_acer_eapd_verbs[] = {
8383 /* HP Pin: output 0 (0x0c) */
8384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8387 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008391 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8392 /* eanable EAPD on medion laptop */
8393 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8394 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008395 /* enable unsolicited event */
8396 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008397 { }
8398};
8399
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008400static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8401{
8402 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008403
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008404 present = snd_hda_codec_read(codec, 0x1b, 0,
8405 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8406 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8407 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8408 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8409 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8410 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8411 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8412 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8413 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8414}
8415
8416static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8417 unsigned int res)
8418{
8419 switch (res >> 26) {
8420 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008421 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008422 alc888_6st_dell_front_automute(codec);
8423 break;
8424 }
8425}
8426
Kailang Yange2757d52008-08-26 13:17:46 +02008427static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8428{
8429 unsigned int mute;
8430 unsigned int present;
8431
8432 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8433 present = snd_hda_codec_read(codec, 0x1b, 0,
8434 AC_VERB_GET_PIN_SENSE, 0);
8435 present = (present & 0x80000000) != 0;
8436 if (present) {
8437 /* mute internal speaker */
8438 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8439 HDA_AMP_MUTE, HDA_AMP_MUTE);
8440 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8441 HDA_AMP_MUTE, HDA_AMP_MUTE);
8442 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8443 HDA_AMP_MUTE, HDA_AMP_MUTE);
8444 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8445 HDA_AMP_MUTE, HDA_AMP_MUTE);
8446 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8447 HDA_AMP_MUTE, HDA_AMP_MUTE);
8448 } else {
8449 /* unmute internal speaker if necessary */
8450 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8451 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8452 HDA_AMP_MUTE, mute);
8453 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8454 HDA_AMP_MUTE, mute);
8455 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8456 HDA_AMP_MUTE, mute);
8457 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8458 HDA_AMP_MUTE, mute);
8459 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8460 HDA_AMP_MUTE, mute);
8461 }
8462}
8463
8464static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8465 unsigned int res)
8466{
8467 if ((res >> 26) == ALC880_HP_EVENT)
8468 alc888_lenovo_sky_front_automute(codec);
8469}
8470
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008471/*
8472 * generic initialization of ADC, input mixers and output mixers
8473 */
8474static struct hda_verb alc883_auto_init_verbs[] = {
8475 /*
8476 * Unmute ADC0-2 and set the default input to mic-in
8477 */
8478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8481 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8482
Takashi Iwaicb53c622007-08-10 17:21:45 +02008483 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008484 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008485 * Note: PASD motherboards uses the Line In 2 as the input for
8486 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008487 */
8488 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8493 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008494
8495 /*
8496 * Set up output mixers (0x0c - 0x0f)
8497 */
8498 /* set vol=0 to output mixers */
8499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8503 /* set up input amps for analog loopback */
8504 /* Amp Indices: DAC = 0, mixer = 1 */
8505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8511 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8513 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8514 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8515
8516 /* FIXME: use matrix-type input source selection */
8517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8518 /* Input mixer1 */
8519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008522 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8524 /* Input mixer2 */
8525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008528 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008530
8531 { }
8532};
8533
Kailang Yange2757d52008-08-26 13:17:46 +02008534static struct hda_verb alc888_asus_m90v_verbs[] = {
8535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8538 /* enable unsolicited event */
8539 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8540 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8541 { } /* end */
8542};
8543
8544static void alc883_nb_mic_automute(struct hda_codec *codec)
8545{
8546 unsigned int present;
8547
8548 present = snd_hda_codec_read(codec, 0x18, 0,
8549 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8550 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8551 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8552 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8553 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8554}
8555
8556static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8557{
8558 unsigned int present;
8559 unsigned char bits;
8560
8561 present = snd_hda_codec_read(codec, 0x1b, 0,
8562 AC_VERB_GET_PIN_SENSE, 0)
8563 & AC_PINSENSE_PRESENCE;
8564 bits = present ? 0 : PIN_OUT;
8565 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8566 bits);
8567 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8568 bits);
8569 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8570 bits);
8571}
8572
8573static void alc883_mode2_unsol_event(struct hda_codec *codec,
8574 unsigned int res)
8575{
8576 switch (res >> 26) {
8577 case ALC880_HP_EVENT:
8578 alc883_M90V_speaker_automute(codec);
8579 break;
8580 case ALC880_MIC_EVENT:
8581 alc883_nb_mic_automute(codec);
8582 break;
8583 }
8584}
8585
8586static void alc883_mode2_inithook(struct hda_codec *codec)
8587{
8588 alc883_M90V_speaker_automute(codec);
8589 alc883_nb_mic_automute(codec);
8590}
8591
8592static struct hda_verb alc888_asus_eee1601_verbs[] = {
8593 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8594 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8598 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8599 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8600 /* enable unsolicited event */
8601 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8602 { } /* end */
8603};
8604
8605static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8606{
8607 unsigned int present;
8608 unsigned char bits;
8609
8610 present = snd_hda_codec_read(codec, 0x14, 0,
8611 AC_VERB_GET_PIN_SENSE, 0)
8612 & AC_PINSENSE_PRESENCE;
8613 bits = present ? 0 : PIN_OUT;
8614 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8615 bits);
8616}
8617
8618static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8619 unsigned int res)
8620{
8621 switch (res >> 26) {
8622 case ALC880_HP_EVENT:
8623 alc883_eee1601_speaker_automute(codec);
8624 break;
8625 }
8626}
8627
8628static void alc883_eee1601_inithook(struct hda_codec *codec)
8629{
8630 alc883_eee1601_speaker_automute(codec);
8631}
8632
Takashi Iwaicb53c622007-08-10 17:21:45 +02008633#ifdef CONFIG_SND_HDA_POWER_SAVE
8634#define alc883_loopbacks alc880_loopbacks
8635#endif
8636
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008637/* pcm configuration: identiacal with ALC880 */
8638#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8639#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008640#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008641#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8642#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8643
8644/*
8645 * configuration and preset
8646 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008647static const char *alc883_models[ALC883_MODEL_LAST] = {
8648 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8649 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8650 [ALC883_3ST_6ch] = "3stack-6ch",
8651 [ALC883_6ST_DIG] = "6stack-dig",
8652 [ALC883_TARGA_DIG] = "targa-dig",
8653 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008654 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008655 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008656 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008657 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008658 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008659 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008660 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008661 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8662 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008663 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008664 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008665 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008666 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008667 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008668 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008669 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008670 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008671 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008672 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008673 [ALC883_AUTO] = "auto",
8674};
8675
8676static struct snd_pci_quirk alc883_cfg_tbl[] = {
8677 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008678 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008679 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008680 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008681 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8682 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008683 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008684 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8685 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008686 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8687 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008688 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008689 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008690 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8691 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008692 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8693 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008694 /* default Acer */
8695 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008696 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008697 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008698 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8699 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008700 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008701 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008702 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008703 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008704 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008705 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008706 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008707 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008708 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008709 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008710 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008711 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8712 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008713 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008714 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008715 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008716 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8717 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8718 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008719 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008720 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008721 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008722 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8723 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8724 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8725 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8726 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8727 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8728 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8729 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8730 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008731 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8732 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008733 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008734 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008735 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008736 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008737 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008738 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008739 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008740 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8741 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008742 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008743 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008744 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008745 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8746 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008747 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008748 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8749 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008750 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008751 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008752 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8753 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008754 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008755 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008756 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008757 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008758 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008759 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8760 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008761 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008762 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008763 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008764 {}
8765};
8766
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008767static hda_nid_t alc1200_slave_dig_outs[] = {
8768 ALC883_DIGOUT_NID, 0,
8769};
8770
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008771static struct alc_config_preset alc883_presets[] = {
8772 [ALC883_3ST_2ch_DIG] = {
8773 .mixers = { alc883_3ST_2ch_mixer },
8774 .init_verbs = { alc883_init_verbs },
8775 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8776 .dac_nids = alc883_dac_nids,
8777 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008778 .dig_in_nid = ALC883_DIGIN_NID,
8779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8780 .channel_mode = alc883_3ST_2ch_modes,
8781 .input_mux = &alc883_capture_source,
8782 },
8783 [ALC883_3ST_6ch_DIG] = {
8784 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8785 .init_verbs = { alc883_init_verbs },
8786 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8787 .dac_nids = alc883_dac_nids,
8788 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008789 .dig_in_nid = ALC883_DIGIN_NID,
8790 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8791 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008792 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008793 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008794 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008795 [ALC883_3ST_6ch] = {
8796 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8797 .init_verbs = { alc883_init_verbs },
8798 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8799 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8801 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008802 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008803 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008804 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008805 [ALC883_3ST_6ch_INTEL] = {
8806 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8807 .init_verbs = { alc883_init_verbs },
8808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8809 .dac_nids = alc883_dac_nids,
8810 .dig_out_nid = ALC883_DIGOUT_NID,
8811 .dig_in_nid = ALC883_DIGIN_NID,
8812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8813 .channel_mode = alc883_3ST_6ch_intel_modes,
8814 .need_dac_fix = 1,
8815 .input_mux = &alc883_3stack_6ch_intel,
8816 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008817 [ALC883_6ST_DIG] = {
8818 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8819 .init_verbs = { alc883_init_verbs },
8820 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8821 .dac_nids = alc883_dac_nids,
8822 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008823 .dig_in_nid = ALC883_DIGIN_NID,
8824 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8825 .channel_mode = alc883_sixstack_modes,
8826 .input_mux = &alc883_capture_source,
8827 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008828 [ALC883_TARGA_DIG] = {
8829 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8830 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
8833 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008834 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8835 .channel_mode = alc883_3ST_6ch_modes,
8836 .need_dac_fix = 1,
8837 .input_mux = &alc883_capture_source,
8838 .unsol_event = alc883_tagra_unsol_event,
8839 .init_hook = alc883_tagra_automute,
8840 },
8841 [ALC883_TARGA_2ch_DIG] = {
8842 .mixers = { alc883_tagra_2ch_mixer},
8843 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8845 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008846 .adc_nids = alc883_adc_nids_alt,
8847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008848 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8850 .channel_mode = alc883_3ST_2ch_modes,
8851 .input_mux = &alc883_capture_source,
8852 .unsol_event = alc883_tagra_unsol_event,
8853 .init_hook = alc883_tagra_automute,
8854 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008855 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008856 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008857 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8858 * and the headphone jack. Turn this on and rely on the
8859 * standard mute methods whenever the user wants to turn
8860 * these outputs off.
8861 */
8862 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8863 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8864 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8866 .channel_mode = alc883_3ST_2ch_modes,
8867 .input_mux = &alc883_capture_source,
8868 },
Tobin Davis2880a862007-08-07 11:50:26 +02008869 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008870 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008871 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008872 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8873 .dac_nids = alc883_dac_nids,
8874 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008875 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8876 .channel_mode = alc883_3ST_2ch_modes,
8877 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008878 .unsol_event = alc883_acer_aspire_unsol_event,
8879 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008880 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008881 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008882 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008883 alc883_chmode_mixer },
8884 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8885 alc888_acer_aspire_4930g_verbs },
8886 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8887 .dac_nids = alc883_dac_nids,
8888 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8889 .adc_nids = alc883_adc_nids_rev,
8890 .capsrc_nids = alc883_capsrc_nids_rev,
8891 .dig_out_nid = ALC883_DIGOUT_NID,
8892 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8893 .channel_mode = alc883_3ST_6ch_modes,
8894 .need_dac_fix = 1,
8895 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008896 ARRAY_SIZE(alc888_2_capture_sources),
8897 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008898 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8899 .init_hook = alc888_acer_aspire_4930g_automute,
8900 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008901 [ALC883_MEDION] = {
8902 .mixers = { alc883_fivestack_mixer,
8903 alc883_chmode_mixer },
8904 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008905 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008906 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8907 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008908 .adc_nids = alc883_adc_nids_alt,
8909 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008910 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8911 .channel_mode = alc883_sixstack_modes,
8912 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008913 },
Kailang Yang272a5272007-05-14 11:00:38 +02008914 [ALC883_MEDION_MD2] = {
8915 .mixers = { alc883_medion_md2_mixer},
8916 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8917 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8918 .dac_nids = alc883_dac_nids,
8919 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008920 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8921 .channel_mode = alc883_3ST_2ch_modes,
8922 .input_mux = &alc883_capture_source,
8923 .unsol_event = alc883_medion_md2_unsol_event,
8924 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008925 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008926 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008927 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008928 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8929 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8930 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008931 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8932 .channel_mode = alc883_3ST_2ch_modes,
8933 .input_mux = &alc883_capture_source,
8934 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008935 [ALC883_CLEVO_M720] = {
8936 .mixers = { alc883_clevo_m720_mixer },
8937 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008938 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8939 .dac_nids = alc883_dac_nids,
8940 .dig_out_nid = ALC883_DIGOUT_NID,
8941 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8942 .channel_mode = alc883_3ST_2ch_modes,
8943 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008944 .unsol_event = alc883_clevo_m720_unsol_event,
8945 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008946 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008947 [ALC883_LENOVO_101E_2ch] = {
8948 .mixers = { alc883_lenovo_101e_2ch_mixer},
8949 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8950 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8951 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008952 .adc_nids = alc883_adc_nids_alt,
8953 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008954 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8955 .channel_mode = alc883_3ST_2ch_modes,
8956 .input_mux = &alc883_lenovo_101e_capture_source,
8957 .unsol_event = alc883_lenovo_101e_unsol_event,
8958 .init_hook = alc883_lenovo_101e_all_automute,
8959 },
Kailang Yang272a5272007-05-14 11:00:38 +02008960 [ALC883_LENOVO_NB0763] = {
8961 .mixers = { alc883_lenovo_nb0763_mixer },
8962 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8964 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008965 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8966 .channel_mode = alc883_3ST_2ch_modes,
8967 .need_dac_fix = 1,
8968 .input_mux = &alc883_lenovo_nb0763_capture_source,
8969 .unsol_event = alc883_medion_md2_unsol_event,
8970 .init_hook = alc883_medion_md2_automute,
8971 },
8972 [ALC888_LENOVO_MS7195_DIG] = {
8973 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8974 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8976 .dac_nids = alc883_dac_nids,
8977 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008978 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8979 .channel_mode = alc883_3ST_6ch_modes,
8980 .need_dac_fix = 1,
8981 .input_mux = &alc883_capture_source,
8982 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8983 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008984 },
8985 [ALC883_HAIER_W66] = {
8986 .mixers = { alc883_tagra_2ch_mixer},
8987 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8988 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8989 .dac_nids = alc883_dac_nids,
8990 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8992 .channel_mode = alc883_3ST_2ch_modes,
8993 .input_mux = &alc883_capture_source,
8994 .unsol_event = alc883_haier_w66_unsol_event,
8995 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008996 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008997 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008998 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008999 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9001 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009002 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9003 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009004 .need_dac_fix = 1,
9005 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009006 .unsol_event = alc888_3st_hp_unsol_event,
9007 .init_hook = alc888_3st_hp_front_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009008 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009009 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009010 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009011 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9012 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9013 .dac_nids = alc883_dac_nids,
9014 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009015 .dig_in_nid = ALC883_DIGIN_NID,
9016 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9017 .channel_mode = alc883_sixstack_modes,
9018 .input_mux = &alc883_capture_source,
9019 .unsol_event = alc888_6st_dell_unsol_event,
9020 .init_hook = alc888_6st_dell_front_automute,
9021 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009022 [ALC883_MITAC] = {
9023 .mixers = { alc883_mitac_mixer },
9024 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9025 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9026 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009027 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9028 .channel_mode = alc883_3ST_2ch_modes,
9029 .input_mux = &alc883_capture_source,
9030 .unsol_event = alc883_mitac_unsol_event,
9031 .init_hook = alc883_mitac_automute,
9032 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009033 [ALC883_FUJITSU_PI2515] = {
9034 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9035 .init_verbs = { alc883_init_verbs,
9036 alc883_2ch_fujitsu_pi2515_verbs},
9037 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9038 .dac_nids = alc883_dac_nids,
9039 .dig_out_nid = ALC883_DIGOUT_NID,
9040 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9041 .channel_mode = alc883_3ST_2ch_modes,
9042 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9043 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9044 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9045 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009046 [ALC888_FUJITSU_XA3530] = {
9047 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9048 .init_verbs = { alc883_init_verbs,
9049 alc888_fujitsu_xa3530_verbs },
9050 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9051 .dac_nids = alc883_dac_nids,
9052 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9053 .adc_nids = alc883_adc_nids_rev,
9054 .capsrc_nids = alc883_capsrc_nids_rev,
9055 .dig_out_nid = ALC883_DIGOUT_NID,
9056 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9057 .channel_mode = alc888_4ST_8ch_intel_modes,
9058 .num_mux_defs =
9059 ARRAY_SIZE(alc888_2_capture_sources),
9060 .input_mux = alc888_2_capture_sources,
9061 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9062 .init_hook = alc888_fujitsu_xa3530_automute,
9063 },
Kailang Yange2757d52008-08-26 13:17:46 +02009064 [ALC888_LENOVO_SKY] = {
9065 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9066 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9068 .dac_nids = alc883_dac_nids,
9069 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009070 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9071 .channel_mode = alc883_sixstack_modes,
9072 .need_dac_fix = 1,
9073 .input_mux = &alc883_lenovo_sky_capture_source,
9074 .unsol_event = alc883_lenovo_sky_unsol_event,
9075 .init_hook = alc888_lenovo_sky_front_automute,
9076 },
9077 [ALC888_ASUS_M90V] = {
9078 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9079 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9080 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9081 .dac_nids = alc883_dac_nids,
9082 .dig_out_nid = ALC883_DIGOUT_NID,
9083 .dig_in_nid = ALC883_DIGIN_NID,
9084 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9085 .channel_mode = alc883_3ST_6ch_modes,
9086 .need_dac_fix = 1,
9087 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9088 .unsol_event = alc883_mode2_unsol_event,
9089 .init_hook = alc883_mode2_inithook,
9090 },
9091 [ALC888_ASUS_EEE1601] = {
9092 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009093 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009094 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9095 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9096 .dac_nids = alc883_dac_nids,
9097 .dig_out_nid = ALC883_DIGOUT_NID,
9098 .dig_in_nid = ALC883_DIGIN_NID,
9099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9100 .channel_mode = alc883_3ST_2ch_modes,
9101 .need_dac_fix = 1,
9102 .input_mux = &alc883_asus_eee1601_capture_source,
9103 .unsol_event = alc883_eee1601_unsol_event,
9104 .init_hook = alc883_eee1601_inithook,
9105 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009106 [ALC1200_ASUS_P5Q] = {
9107 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9108 .init_verbs = { alc883_init_verbs },
9109 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9110 .dac_nids = alc883_dac_nids,
9111 .dig_out_nid = ALC1200_DIGOUT_NID,
9112 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009113 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009114 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9115 .channel_mode = alc883_sixstack_modes,
9116 .input_mux = &alc883_capture_source,
9117 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118};
9119
9120
9121/*
9122 * BIOS auto configuration
9123 */
9124static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9125 hda_nid_t nid, int pin_type,
9126 int dac_idx)
9127{
9128 /* set as output */
9129 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009130 int idx;
9131
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009132 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009133 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9134 idx = 4;
9135 else
9136 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009137 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9138
9139}
9140
9141static void alc883_auto_init_multi_out(struct hda_codec *codec)
9142{
9143 struct alc_spec *spec = codec->spec;
9144 int i;
9145
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009146 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009147 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009148 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009149 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009150 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009151 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009152 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009153 }
9154}
9155
9156static void alc883_auto_init_hp_out(struct hda_codec *codec)
9157{
9158 struct alc_spec *spec = codec->spec;
9159 hda_nid_t pin;
9160
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009161 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 if (pin) /* connect to front */
9163 /* use dac 0 */
9164 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009165 pin = spec->autocfg.speaker_pins[0];
9166 if (pin)
9167 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009168}
9169
9170#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9171#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9172
9173static void alc883_auto_init_analog_input(struct hda_codec *codec)
9174{
9175 struct alc_spec *spec = codec->spec;
9176 int i;
9177
9178 for (i = 0; i < AUTO_PIN_LAST; i++) {
9179 hda_nid_t nid = spec->autocfg.input_pins[i];
9180 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009181 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009182 if (nid != ALC883_PIN_CD_NID &&
9183 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184 snd_hda_codec_write(codec, nid, 0,
9185 AC_VERB_SET_AMP_GAIN_MUTE,
9186 AMP_OUT_MUTE);
9187 }
9188 }
9189}
9190
Takashi Iwaif511b012008-08-15 16:46:42 +02009191#define alc883_auto_init_input_src alc882_auto_init_input_src
9192
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009193/* almost identical with ALC880 parser... */
9194static int alc883_parse_auto_config(struct hda_codec *codec)
9195{
9196 struct alc_spec *spec = codec->spec;
9197 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009198 struct auto_pin_cfg *cfg = &spec->autocfg;
9199 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009200
9201 if (err < 0)
9202 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009203 else if (!err)
9204 return 0; /* no config found */
9205
9206 err = alc_auto_add_mic_boost(codec);
9207 if (err < 0)
9208 return err;
9209
9210 /* hack - override the init verbs */
9211 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009212
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009213 /* setup input_mux for ALC889 */
9214 if (codec->vendor_id == 0x10ec0889) {
9215 /* digital-mic input pin is excluded in alc880_auto_create..()
9216 * because it's under 0x18
9217 */
9218 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9219 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9220 struct hda_input_mux *imux = &spec->private_imux[0];
9221 for (i = 1; i < 3; i++)
9222 memcpy(&spec->private_imux[i],
9223 &spec->private_imux[0],
9224 sizeof(spec->private_imux[0]));
9225 imux->items[imux->num_items].label = "Int DMic";
9226 imux->items[imux->num_items].index = 0x0b;
9227 imux->num_items++;
9228 spec->num_mux_defs = 3;
9229 spec->input_mux = spec->private_imux;
9230 }
9231 }
9232
Takashi Iwai776e1842007-08-29 15:07:11 +02009233 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009234}
9235
9236/* additional initialization for auto-configuration model */
9237static void alc883_auto_init(struct hda_codec *codec)
9238{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009239 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009240 alc883_auto_init_multi_out(codec);
9241 alc883_auto_init_hp_out(codec);
9242 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009243 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009244 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009245 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009246}
9247
9248static int patch_alc883(struct hda_codec *codec)
9249{
9250 struct alc_spec *spec;
9251 int err, board_config;
9252
9253 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9254 if (spec == NULL)
9255 return -ENOMEM;
9256
9257 codec->spec = spec;
9258
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009259 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9260
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009261 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9262 alc883_models,
9263 alc883_cfg_tbl);
9264 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009265 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9266 "trying auto-probe from BIOS...\n");
9267 board_config = ALC883_AUTO;
9268 }
9269
9270 if (board_config == ALC883_AUTO) {
9271 /* automatic parse from the BIOS config */
9272 err = alc883_parse_auto_config(codec);
9273 if (err < 0) {
9274 alc_free(codec);
9275 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009276 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009277 printk(KERN_INFO
9278 "hda_codec: Cannot set up configuration "
9279 "from BIOS. Using base mode...\n");
9280 board_config = ALC883_3ST_2ch_DIG;
9281 }
9282 }
9283
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009284 err = snd_hda_attach_beep_device(codec, 0x1);
9285 if (err < 0) {
9286 alc_free(codec);
9287 return err;
9288 }
9289
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009290 if (board_config != ALC883_AUTO)
9291 setup_preset(spec, &alc883_presets[board_config]);
9292
Kailang Yang2f893282008-05-27 12:14:47 +02009293 switch (codec->vendor_id) {
9294 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009295 if (codec->revision_id == 0x100101) {
9296 spec->stream_name_analog = "ALC1200 Analog";
9297 spec->stream_name_digital = "ALC1200 Digital";
9298 } else {
9299 spec->stream_name_analog = "ALC888 Analog";
9300 spec->stream_name_digital = "ALC888 Digital";
9301 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009302 if (!spec->num_adc_nids) {
9303 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9304 spec->adc_nids = alc883_adc_nids;
9305 }
9306 if (!spec->capsrc_nids)
9307 spec->capsrc_nids = alc883_capsrc_nids;
9308 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009309 break;
9310 case 0x10ec0889:
9311 spec->stream_name_analog = "ALC889 Analog";
9312 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009313 if (!spec->num_adc_nids) {
9314 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9315 spec->adc_nids = alc889_adc_nids;
9316 }
9317 if (!spec->capsrc_nids)
9318 spec->capsrc_nids = alc889_capsrc_nids;
9319 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9320 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009321 break;
9322 default:
9323 spec->stream_name_analog = "ALC883 Analog";
9324 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009325 if (!spec->num_adc_nids) {
9326 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9327 spec->adc_nids = alc883_adc_nids;
9328 }
9329 if (!spec->capsrc_nids)
9330 spec->capsrc_nids = alc883_capsrc_nids;
9331 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009332 break;
9333 }
9334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009335 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9336 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009337 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009338
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009339 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9340 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9341
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009342 if (!spec->cap_mixer)
9343 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009344 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009345
Takashi Iwai2134ea42008-01-10 16:53:55 +01009346 spec->vmaster_nid = 0x0c;
9347
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009348 codec->patch_ops = alc_patch_ops;
9349 if (board_config == ALC883_AUTO)
9350 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009351
Takashi Iwaicb53c622007-08-10 17:21:45 +02009352#ifdef CONFIG_SND_HDA_POWER_SAVE
9353 if (!spec->loopback.amplist)
9354 spec->loopback.amplist = alc883_loopbacks;
9355#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009356 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009357
9358 return 0;
9359}
9360
9361/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009362 * ALC262 support
9363 */
9364
9365#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9366#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9367
9368#define alc262_dac_nids alc260_dac_nids
9369#define alc262_adc_nids alc882_adc_nids
9370#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009371#define alc262_capsrc_nids alc882_capsrc_nids
9372#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009373
9374#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009375#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009376
Kailang Yang4e555fe2008-08-26 13:05:55 +02009377static hda_nid_t alc262_dmic_adc_nids[1] = {
9378 /* ADC0 */
9379 0x09
9380};
9381
9382static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9383
Kailang Yangdf694da2005-12-05 19:42:22 +01009384static struct snd_kcontrol_new alc262_base_mixer[] = {
9385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9386 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009394 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9395 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009396 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009397 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9399 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9400 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009401 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009402};
9403
Kailang Yangccc656c2006-10-17 12:32:26 +02009404static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9406 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009416 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009417 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9419 { } /* end */
9420};
9421
Takashi Iwaice875f02008-01-28 18:17:43 +01009422/* update HP, line and mono-out pins according to the master switch */
9423static void alc262_hp_master_update(struct hda_codec *codec)
9424{
9425 struct alc_spec *spec = codec->spec;
9426 int val = spec->master_sw;
9427
9428 /* HP & line-out */
9429 snd_hda_codec_write_cache(codec, 0x1b, 0,
9430 AC_VERB_SET_PIN_WIDGET_CONTROL,
9431 val ? PIN_HP : 0);
9432 snd_hda_codec_write_cache(codec, 0x15, 0,
9433 AC_VERB_SET_PIN_WIDGET_CONTROL,
9434 val ? PIN_HP : 0);
9435 /* mono (speaker) depending on the HP jack sense */
9436 val = val && !spec->jack_present;
9437 snd_hda_codec_write_cache(codec, 0x16, 0,
9438 AC_VERB_SET_PIN_WIDGET_CONTROL,
9439 val ? PIN_OUT : 0);
9440}
9441
9442static void alc262_hp_bpc_automute(struct hda_codec *codec)
9443{
9444 struct alc_spec *spec = codec->spec;
9445 unsigned int presence;
9446 presence = snd_hda_codec_read(codec, 0x1b, 0,
9447 AC_VERB_GET_PIN_SENSE, 0);
9448 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9449 alc262_hp_master_update(codec);
9450}
9451
9452static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9453{
9454 if ((res >> 26) != ALC880_HP_EVENT)
9455 return;
9456 alc262_hp_bpc_automute(codec);
9457}
9458
9459static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9460{
9461 struct alc_spec *spec = codec->spec;
9462 unsigned int presence;
9463 presence = snd_hda_codec_read(codec, 0x15, 0,
9464 AC_VERB_GET_PIN_SENSE, 0);
9465 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9466 alc262_hp_master_update(codec);
9467}
9468
9469static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9470 unsigned int res)
9471{
9472 if ((res >> 26) != ALC880_HP_EVENT)
9473 return;
9474 alc262_hp_wildwest_automute(codec);
9475}
9476
9477static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9478 struct snd_ctl_elem_value *ucontrol)
9479{
9480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9481 struct alc_spec *spec = codec->spec;
9482 *ucontrol->value.integer.value = spec->master_sw;
9483 return 0;
9484}
9485
9486static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9487 struct snd_ctl_elem_value *ucontrol)
9488{
9489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9490 struct alc_spec *spec = codec->spec;
9491 int val = !!*ucontrol->value.integer.value;
9492
9493 if (val == spec->master_sw)
9494 return 0;
9495 spec->master_sw = val;
9496 alc262_hp_master_update(codec);
9497 return 1;
9498}
9499
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009500static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009501 {
9502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9503 .name = "Master Playback Switch",
9504 .info = snd_ctl_boolean_mono_info,
9505 .get = alc262_hp_master_sw_get,
9506 .put = alc262_hp_master_sw_put,
9507 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009508 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9509 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009511 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9512 HDA_OUTPUT),
9513 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9514 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009517 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009520 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009521 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9522 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009525 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9526 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9527 { } /* end */
9528};
9529
Kailang Yangcd7509a2007-01-26 18:33:17 +01009530static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009531 {
9532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9533 .name = "Master Playback Switch",
9534 .info = snd_ctl_boolean_mono_info,
9535 .get = alc262_hp_master_sw_get,
9536 .put = alc262_hp_master_sw_put,
9537 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009538 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9539 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9540 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009542 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9543 HDA_OUTPUT),
9544 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9545 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009548 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009549 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9550 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009553 { } /* end */
9554};
9555
9556static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9557 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9558 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009559 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009560 { } /* end */
9561};
9562
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009563/* mute/unmute internal speaker according to the hp jack and mute state */
9564static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9565{
9566 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009567
9568 if (force || !spec->sense_updated) {
9569 unsigned int present;
9570 present = snd_hda_codec_read(codec, 0x15, 0,
9571 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009572 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009573 spec->sense_updated = 1;
9574 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009575 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9576 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009577}
9578
9579static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9580 unsigned int res)
9581{
9582 if ((res >> 26) != ALC880_HP_EVENT)
9583 return;
9584 alc262_hp_t5735_automute(codec, 1);
9585}
9586
9587static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9588{
9589 alc262_hp_t5735_automute(codec, 1);
9590}
9591
9592static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009593 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9594 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009595 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9599 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9600 { } /* end */
9601};
9602
9603static struct hda_verb alc262_hp_t5735_verbs[] = {
9604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9606
9607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9608 { }
9609};
9610
Kailang Yang8c427222008-01-10 13:03:59 +01009611static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009612 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009614 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9615 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009616 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9617 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9618 { } /* end */
9619};
9620
9621static struct hda_verb alc262_hp_rp5700_verbs[] = {
9622 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9623 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9624 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9627 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9632 {}
9633};
9634
9635static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9636 .num_items = 1,
9637 .items = {
9638 { "Line", 0x1 },
9639 },
9640};
9641
Takashi Iwai0724ea22007-08-23 00:31:43 +02009642/* bind hp and internal speaker mute (with plug check) */
9643static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9644 struct snd_ctl_elem_value *ucontrol)
9645{
9646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9647 long *valp = ucontrol->value.integer.value;
9648 int change;
9649
9650 /* change hp mute */
9651 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9652 HDA_AMP_MUTE,
9653 valp[0] ? 0 : HDA_AMP_MUTE);
9654 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9655 HDA_AMP_MUTE,
9656 valp[1] ? 0 : HDA_AMP_MUTE);
9657 if (change) {
9658 /* change speaker according to HP jack state */
9659 struct alc_spec *spec = codec->spec;
9660 unsigned int mute;
9661 if (spec->jack_present)
9662 mute = HDA_AMP_MUTE;
9663 else
9664 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9665 HDA_OUTPUT, 0);
9666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9667 HDA_AMP_MUTE, mute);
9668 }
9669 return change;
9670}
Takashi Iwai5b319542007-07-26 11:49:22 +02009671
Kailang Yang272a5272007-05-14 11:00:38 +02009672static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009673 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9674 {
9675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9676 .name = "Master Playback Switch",
9677 .info = snd_hda_mixer_amp_switch_info,
9678 .get = snd_hda_mixer_amp_switch_get,
9679 .put = alc262_sony_master_sw_put,
9680 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9681 },
Kailang Yang272a5272007-05-14 11:00:38 +02009682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9684 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9685 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9686 { } /* end */
9687};
9688
Kailang Yang83c34212007-07-05 11:43:05 +02009689static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9691 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9695 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9696 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9697 { } /* end */
9698};
Kailang Yang272a5272007-05-14 11:00:38 +02009699
Tony Vroonba340e82009-02-02 19:01:30 +00009700static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9701 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9702 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9703 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9704 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9712 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9713 { } /* end */
9714};
9715
9716static struct hda_verb alc262_tyan_verbs[] = {
9717 /* Headphone automute */
9718 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9719 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9721
9722 /* P11 AUX_IN, white 4-pin connector */
9723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9724 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9725 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9726 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9727
9728 {}
9729};
9730
9731/* unsolicited event for HP jack sensing */
9732static void alc262_tyan_automute(struct hda_codec *codec)
9733{
9734 unsigned int mute;
9735 unsigned int present;
9736
9737 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9738 present = snd_hda_codec_read(codec, 0x1b, 0,
9739 AC_VERB_GET_PIN_SENSE, 0);
9740 present = (present & 0x80000000) != 0;
9741 if (present) {
9742 /* mute line output on ATX panel */
9743 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9744 HDA_AMP_MUTE, HDA_AMP_MUTE);
9745 } else {
9746 /* unmute line output if necessary */
9747 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9748 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9749 HDA_AMP_MUTE, mute);
9750 }
9751}
9752
9753static void alc262_tyan_unsol_event(struct hda_codec *codec,
9754 unsigned int res)
9755{
9756 if ((res >> 26) != ALC880_HP_EVENT)
9757 return;
9758 alc262_tyan_automute(codec);
9759}
9760
Kailang Yangdf694da2005-12-05 19:42:22 +01009761#define alc262_capture_mixer alc882_capture_mixer
9762#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9763
9764/*
9765 * generic initialization of ADC, input mixers and output mixers
9766 */
9767static struct hda_verb alc262_init_verbs[] = {
9768 /*
9769 * Unmute ADC0-2 and set the default input to mic-in
9770 */
9771 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9772 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9773 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9775 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9776 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9777
Takashi Iwaicb53c622007-08-10 17:21:45 +02009778 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009779 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009780 * Note: PASD motherboards uses the Line In 2 as the input for
9781 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009782 */
9783 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009789
9790 /*
9791 * Set up output mixers (0x0c - 0x0e)
9792 */
9793 /* set vol=0 to output mixers */
9794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9797 /* set up input amps for analog loopback */
9798 /* Amp Indices: DAC = 0, mixer = 1 */
9799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9805
9806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9809 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9811 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9812
9813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009818
Kailang Yangdf694da2005-12-05 19:42:22 +01009819 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009821
Kailang Yangdf694da2005-12-05 19:42:22 +01009822 /* FIXME: use matrix-type input source selection */
9823 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9824 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9825 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9826 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9829 /* Input mixer2 */
9830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9831 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9833 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9834 /* Input mixer3 */
9835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009839
9840 { }
9841};
9842
Kailang Yang4e555fe2008-08-26 13:05:55 +02009843static struct hda_verb alc262_eapd_verbs[] = {
9844 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9845 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9846 { }
9847};
9848
Kailang Yangccc656c2006-10-17 12:32:26 +02009849static struct hda_verb alc262_hippo_unsol_verbs[] = {
9850 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9852 {}
9853};
9854
9855static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9857 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9859
9860 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9862 {}
9863};
9864
Kailang Yang272a5272007-05-14 11:00:38 +02009865static struct hda_verb alc262_sony_unsol_verbs[] = {
9866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9867 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9869
9870 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009872 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009873};
9874
Kailang Yang4e555fe2008-08-26 13:05:55 +02009875static struct hda_input_mux alc262_dmic_capture_source = {
9876 .num_items = 2,
9877 .items = {
9878 { "Int DMic", 0x9 },
9879 { "Mic", 0x0 },
9880 },
9881};
9882
9883static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9884 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9885 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9886 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009889 { } /* end */
9890};
9891
9892static struct hda_verb alc262_toshiba_s06_verbs[] = {
9893 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9896 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9897 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9898 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9899 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9900 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9901 {}
9902};
9903
9904static void alc262_dmic_automute(struct hda_codec *codec)
9905{
9906 unsigned int present;
9907
9908 present = snd_hda_codec_read(codec, 0x18, 0,
9909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9910 snd_hda_codec_write(codec, 0x22, 0,
9911 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9912}
9913
9914/* toggle speaker-output according to the hp-jack state */
9915static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9916{
9917 unsigned int present;
9918 unsigned char bits;
9919
9920 present = snd_hda_codec_read(codec, 0x15, 0,
9921 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9922 bits = present ? 0 : PIN_OUT;
9923 snd_hda_codec_write(codec, 0x14, 0,
9924 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9925}
9926
9927
9928
9929/* unsolicited event for HP jack sensing */
9930static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9931 unsigned int res)
9932{
9933 if ((res >> 26) == ALC880_HP_EVENT)
9934 alc262_toshiba_s06_speaker_automute(codec);
9935 if ((res >> 26) == ALC880_MIC_EVENT)
9936 alc262_dmic_automute(codec);
9937
9938}
9939
9940static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9941{
9942 alc262_toshiba_s06_speaker_automute(codec);
9943 alc262_dmic_automute(codec);
9944}
9945
Kailang Yangccc656c2006-10-17 12:32:26 +02009946/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009947static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009948{
9949 struct alc_spec *spec = codec->spec;
9950 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009951 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009952
Takashi Iwai5b319542007-07-26 11:49:22 +02009953 /* need to execute and sync at first */
9954 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9955 present = snd_hda_codec_read(codec, 0x15, 0,
9956 AC_VERB_GET_PIN_SENSE, 0);
9957 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009958 if (spec->jack_present) {
9959 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009960 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9961 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009962 } else {
9963 /* unmute internal speaker if necessary */
9964 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009965 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9966 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009967 }
9968}
9969
9970/* unsolicited event for HP jack sensing */
9971static void alc262_hippo_unsol_event(struct hda_codec *codec,
9972 unsigned int res)
9973{
9974 if ((res >> 26) != ALC880_HP_EVENT)
9975 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009976 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009977}
9978
Takashi Iwai5b319542007-07-26 11:49:22 +02009979static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009980{
Kailang Yangccc656c2006-10-17 12:32:26 +02009981 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009982 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009983
Takashi Iwai5b319542007-07-26 11:49:22 +02009984 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9985 present = snd_hda_codec_read(codec, 0x1b, 0,
9986 AC_VERB_GET_PIN_SENSE, 0);
9987 present = (present & 0x80000000) != 0;
9988 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009989 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009990 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9991 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009992 } else {
9993 /* unmute internal speaker if necessary */
9994 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009995 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9996 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009997 }
9998}
9999
10000/* unsolicited event for HP jack sensing */
10001static void alc262_hippo1_unsol_event(struct hda_codec *codec,
10002 unsigned int res)
10003{
10004 if ((res >> 26) != ALC880_HP_EVENT)
10005 return;
Takashi Iwai5b319542007-07-26 11:49:22 +020010006 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +020010007}
10008
Takashi Iwai834be882006-03-01 14:16:17 +010010009/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010010 * nec model
10011 * 0x15 = headphone
10012 * 0x16 = internal speaker
10013 * 0x18 = external mic
10014 */
10015
10016static struct snd_kcontrol_new alc262_nec_mixer[] = {
10017 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10018 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10019
10020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10023
10024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10026 { } /* end */
10027};
10028
10029static struct hda_verb alc262_nec_verbs[] = {
10030 /* Unmute Speaker */
10031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10032
10033 /* Headphone */
10034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10036
10037 /* External mic to headphone */
10038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10039 /* External mic to speaker */
10040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10041 {}
10042};
10043
10044/*
Takashi Iwai834be882006-03-01 14:16:17 +010010045 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010046 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10047 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010048 */
10049
10050#define ALC_HP_EVENT 0x37
10051
10052static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10053 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010057 {}
10058};
10059
Jiang zhe0e31daf2008-03-20 12:12:39 +010010060static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10063 {}
10064};
10065
Takashi Iwai834be882006-03-01 14:16:17 +010010066static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010067 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010068 .items = {
10069 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010070 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010071 { "CD", 0x4 },
10072 },
10073};
10074
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010075static struct hda_input_mux alc262_HP_capture_source = {
10076 .num_items = 5,
10077 .items = {
10078 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010079 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010080 { "Line", 0x2 },
10081 { "CD", 0x4 },
10082 { "AUX IN", 0x6 },
10083 },
10084};
10085
zhejiangaccbe492007-08-31 12:36:05 +020010086static struct hda_input_mux alc262_HP_D7000_capture_source = {
10087 .num_items = 4,
10088 .items = {
10089 { "Mic", 0x0 },
10090 { "Front Mic", 0x2 },
10091 { "Line", 0x1 },
10092 { "CD", 0x4 },
10093 },
10094};
10095
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010096/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010097static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10098{
10099 struct alc_spec *spec = codec->spec;
10100 unsigned int mute;
10101
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010102 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010103 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010104 /* need to execute and sync at first */
10105 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010106 /* check laptop HP jack */
10107 present = snd_hda_codec_read(codec, 0x14, 0,
10108 AC_VERB_GET_PIN_SENSE, 0);
10109 /* need to execute and sync at first */
10110 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10111 /* check docking HP jack */
10112 present |= snd_hda_codec_read(codec, 0x1b, 0,
10113 AC_VERB_GET_PIN_SENSE, 0);
10114 if (present & AC_PINSENSE_PRESENCE)
10115 spec->jack_present = 1;
10116 else
10117 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010118 spec->sense_updated = 1;
10119 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010120 /* unmute internal speaker only if both HPs are unplugged and
10121 * master switch is on
10122 */
10123 if (spec->jack_present)
10124 mute = HDA_AMP_MUTE;
10125 else
Takashi Iwai834be882006-03-01 14:16:17 +010010126 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010127 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10128 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010129}
10130
10131/* unsolicited event for HP jack sensing */
10132static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10133 unsigned int res)
10134{
10135 if ((res >> 26) != ALC_HP_EVENT)
10136 return;
10137 alc262_fujitsu_automute(codec, 1);
10138}
10139
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010140static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10141{
10142 alc262_fujitsu_automute(codec, 1);
10143}
10144
Takashi Iwai834be882006-03-01 14:16:17 +010010145/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010146static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10147 .ops = &snd_hda_bind_vol,
10148 .values = {
10149 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10150 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10151 0
10152 },
10153};
Takashi Iwai834be882006-03-01 14:16:17 +010010154
Jiang zhe0e31daf2008-03-20 12:12:39 +010010155/* mute/unmute internal speaker according to the hp jack and mute state */
10156static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10157{
10158 struct alc_spec *spec = codec->spec;
10159 unsigned int mute;
10160
10161 if (force || !spec->sense_updated) {
10162 unsigned int present_int_hp;
10163 /* need to execute and sync at first */
10164 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10165 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10166 AC_VERB_GET_PIN_SENSE, 0);
10167 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10168 spec->sense_updated = 1;
10169 }
10170 if (spec->jack_present) {
10171 /* mute internal speaker */
10172 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10173 HDA_AMP_MUTE, HDA_AMP_MUTE);
10174 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10175 HDA_AMP_MUTE, HDA_AMP_MUTE);
10176 } else {
10177 /* unmute internal speaker if necessary */
10178 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10179 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10180 HDA_AMP_MUTE, mute);
10181 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10182 HDA_AMP_MUTE, mute);
10183 }
10184}
10185
10186/* unsolicited event for HP jack sensing */
10187static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10188 unsigned int res)
10189{
10190 if ((res >> 26) != ALC_HP_EVENT)
10191 return;
10192 alc262_lenovo_3000_automute(codec, 1);
10193}
10194
Takashi Iwai834be882006-03-01 14:16:17 +010010195/* bind hp and internal speaker mute (with plug check) */
10196static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10197 struct snd_ctl_elem_value *ucontrol)
10198{
10199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10200 long *valp = ucontrol->value.integer.value;
10201 int change;
10202
Tony Vroon5d9fab22008-03-14 17:09:18 +010010203 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10204 HDA_AMP_MUTE,
10205 valp ? 0 : HDA_AMP_MUTE);
10206 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10207 HDA_AMP_MUTE,
10208 valp ? 0 : HDA_AMP_MUTE);
10209
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010210 if (change)
10211 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010212 return change;
10213}
10214
10215static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010216 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010217 {
10218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10219 .name = "Master Playback Switch",
10220 .info = snd_hda_mixer_amp_switch_info,
10221 .get = snd_hda_mixer_amp_switch_get,
10222 .put = alc262_fujitsu_master_sw_put,
10223 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10224 },
10225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010230 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10232 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010233 { } /* end */
10234};
10235
Jiang zhe0e31daf2008-03-20 12:12:39 +010010236/* bind hp and internal speaker mute (with plug check) */
10237static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10238 struct snd_ctl_elem_value *ucontrol)
10239{
10240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10241 long *valp = ucontrol->value.integer.value;
10242 int change;
10243
10244 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10245 HDA_AMP_MUTE,
10246 valp ? 0 : HDA_AMP_MUTE);
10247
10248 if (change)
10249 alc262_lenovo_3000_automute(codec, 0);
10250 return change;
10251}
10252
10253static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10254 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10255 {
10256 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10257 .name = "Master Playback Switch",
10258 .info = snd_hda_mixer_amp_switch_info,
10259 .get = snd_hda_mixer_amp_switch_get,
10260 .put = alc262_lenovo_3000_master_sw_put,
10261 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10262 },
10263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10268 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10269 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10270 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10271 { } /* end */
10272};
10273
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010274static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10275 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10276 {
10277 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10278 .name = "Master Playback Switch",
10279 .info = snd_hda_mixer_amp_switch_info,
10280 .get = snd_hda_mixer_amp_switch_get,
10281 .put = alc262_sony_master_sw_put,
10282 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10283 },
10284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10287 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10288 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10289 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10290 { } /* end */
10291};
10292
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010293/* additional init verbs for Benq laptops */
10294static struct hda_verb alc262_EAPD_verbs[] = {
10295 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10296 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10297 {}
10298};
10299
Kailang Yang83c34212007-07-05 11:43:05 +020010300static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10301 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10303
10304 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10305 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10306 {}
10307};
10308
Tobin Davisf651b502007-10-26 12:40:47 +020010309/* Samsung Q1 Ultra Vista model setup */
10310static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010311 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10312 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10315 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010316 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010317 { } /* end */
10318};
10319
10320static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010321 /* output mixer */
10322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10325 /* speaker */
10326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10330 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10335 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10336 /* internal mic */
10337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10339 /* ADC, choose mic */
10340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010350 {}
10351};
10352
Tobin Davisf651b502007-10-26 12:40:47 +020010353/* mute/unmute internal speaker according to the hp jack and mute state */
10354static void alc262_ultra_automute(struct hda_codec *codec)
10355{
10356 struct alc_spec *spec = codec->spec;
10357 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010358
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010359 mute = 0;
10360 /* auto-mute only when HP is used as HP */
10361 if (!spec->cur_mux[0]) {
10362 unsigned int present;
10363 /* need to execute and sync at first */
10364 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10365 present = snd_hda_codec_read(codec, 0x15, 0,
10366 AC_VERB_GET_PIN_SENSE, 0);
10367 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10368 if (spec->jack_present)
10369 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010370 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010371 /* mute/unmute internal speaker */
10372 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10373 HDA_AMP_MUTE, mute);
10374 /* mute/unmute HP */
10375 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10376 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010377}
10378
10379/* unsolicited event for HP jack sensing */
10380static void alc262_ultra_unsol_event(struct hda_codec *codec,
10381 unsigned int res)
10382{
10383 if ((res >> 26) != ALC880_HP_EVENT)
10384 return;
10385 alc262_ultra_automute(codec);
10386}
10387
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010388static struct hda_input_mux alc262_ultra_capture_source = {
10389 .num_items = 2,
10390 .items = {
10391 { "Mic", 0x1 },
10392 { "Headphone", 0x7 },
10393 },
10394};
10395
10396static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10397 struct snd_ctl_elem_value *ucontrol)
10398{
10399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10400 struct alc_spec *spec = codec->spec;
10401 int ret;
10402
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010403 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010404 if (!ret)
10405 return 0;
10406 /* reprogram the HP pin as mic or HP according to the input source */
10407 snd_hda_codec_write_cache(codec, 0x15, 0,
10408 AC_VERB_SET_PIN_WIDGET_CONTROL,
10409 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10410 alc262_ultra_automute(codec); /* mute/unmute HP */
10411 return ret;
10412}
10413
10414static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10415 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10416 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10417 {
10418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10419 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010420 .info = alc_mux_enum_info,
10421 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010422 .put = alc262_ultra_mux_enum_put,
10423 },
10424 { } /* end */
10425};
10426
Kailang Yangdf694da2005-12-05 19:42:22 +010010427/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010428static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10429 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010430{
10431 hda_nid_t nid;
10432 int err;
10433
10434 spec->multiout.num_dacs = 1; /* only use one dac */
10435 spec->multiout.dac_nids = spec->private_dac_nids;
10436 spec->multiout.dac_nids[0] = 2;
10437
10438 nid = cfg->line_out_pins[0];
10439 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010440 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10441 "Front Playback Volume",
10442 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10443 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010444 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010445 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10446 "Front Playback Switch",
10447 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10448 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010449 return err;
10450 }
10451
Takashi Iwai82bc9552006-03-21 11:24:42 +010010452 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010453 if (nid) {
10454 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010455 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10456 "Speaker Playback Volume",
10457 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10458 HDA_OUTPUT));
10459 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010460 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010461 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10462 "Speaker Playback Switch",
10463 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10464 HDA_OUTPUT));
10465 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010466 return err;
10467 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010468 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10469 "Speaker Playback Switch",
10470 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10471 HDA_OUTPUT));
10472 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010473 return err;
10474 }
10475 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010476 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010477 if (nid) {
10478 /* spec->multiout.hp_nid = 2; */
10479 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010480 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10481 "Headphone Playback Volume",
10482 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10483 HDA_OUTPUT));
10484 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010486 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10487 "Headphone Playback Switch",
10488 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10489 HDA_OUTPUT));
10490 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010491 return err;
10492 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010493 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10494 "Headphone Playback Switch",
10495 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10496 HDA_OUTPUT));
10497 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010498 return err;
10499 }
10500 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010501 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010502}
10503
10504/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010505#define alc262_auto_create_analog_input_ctls \
10506 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010507
10508/*
10509 * generic initialization of ADC, input mixers and output mixers
10510 */
10511static struct hda_verb alc262_volume_init_verbs[] = {
10512 /*
10513 * Unmute ADC0-2 and set the default input to mic-in
10514 */
10515 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10519 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10521
Takashi Iwaicb53c622007-08-10 17:21:45 +020010522 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010523 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010524 * Note: PASD motherboards uses the Line In 2 as the input for
10525 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010526 */
10527 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010533
10534 /*
10535 * Set up output mixers (0x0c - 0x0f)
10536 */
10537 /* set vol=0 to output mixers */
10538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010541
Kailang Yangdf694da2005-12-05 19:42:22 +010010542 /* set up input amps for analog loopback */
10543 /* Amp Indices: DAC = 0, mixer = 1 */
10544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10550
10551 /* FIXME: use matrix-type input source selection */
10552 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10553 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10558 /* Input mixer2 */
10559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10563 /* Input mixer3 */
10564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10568
10569 { }
10570};
10571
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010572static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10573 /*
10574 * Unmute ADC0-2 and set the default input to mic-in
10575 */
10576 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10578 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10579 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10580 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10582
Takashi Iwaicb53c622007-08-10 17:21:45 +020010583 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010584 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010585 * Note: PASD motherboards uses the Line In 2 as the input for
10586 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010587 */
10588 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010596
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010597 /*
10598 * Set up output mixers (0x0c - 0x0e)
10599 */
10600 /* set vol=0 to output mixers */
10601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10603 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10604
10605 /* set up input amps for analog loopback */
10606 /* Amp Indices: DAC = 0, mixer = 1 */
10607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10609 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10613
Takashi Iwaice875f02008-01-28 18:17:43 +010010614 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10617
10618 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10620
10621 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10622 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10623
10624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10628 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10629
10630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10632 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10633 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10634 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10635 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10636
10637
10638 /* FIXME: use matrix-type input source selection */
10639 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10640 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10641 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10645 /* Input mixer2 */
10646 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10650 /* Input mixer3 */
10651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10655
Takashi Iwaice875f02008-01-28 18:17:43 +010010656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10657
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010658 { }
10659};
10660
Kailang Yangcd7509a2007-01-26 18:33:17 +010010661static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10662 /*
10663 * Unmute ADC0-2 and set the default input to mic-in
10664 */
10665 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10667 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10668 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10669 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10670 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10671
Takashi Iwaicb53c622007-08-10 17:21:45 +020010672 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010673 * mixer widget
10674 * Note: PASD motherboards uses the Line In 2 as the input for front
10675 * panel mic (mic 2)
10676 */
10677 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010686 /*
10687 * Set up output mixers (0x0c - 0x0e)
10688 */
10689 /* set vol=0 to output mixers */
10690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10692 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10693
10694 /* set up input amps for analog loopback */
10695 /* Amp Indices: DAC = 0, mixer = 1 */
10696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10702
10703
10704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10710 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10711
10712 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10714
10715 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10717
10718 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10722 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10723 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10724
10725 /* FIXME: use matrix-type input source selection */
10726 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10727 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10733 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10735 /* Input mixer2 */
10736 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10737 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10741 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10742 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10743 /* Input mixer3 */
10744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10749 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10751
Takashi Iwaice875f02008-01-28 18:17:43 +010010752 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10753
Kailang Yangcd7509a2007-01-26 18:33:17 +010010754 { }
10755};
10756
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010757static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10758
10759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10761 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10762
10763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10767
10768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10770 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10771 {}
10772};
10773
10774
Takashi Iwaicb53c622007-08-10 17:21:45 +020010775#ifdef CONFIG_SND_HDA_POWER_SAVE
10776#define alc262_loopbacks alc880_loopbacks
10777#endif
10778
Kailang Yangdf694da2005-12-05 19:42:22 +010010779/* pcm configuration: identiacal with ALC880 */
10780#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10781#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10782#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10783#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10784
10785/*
10786 * BIOS auto configuration
10787 */
10788static int alc262_parse_auto_config(struct hda_codec *codec)
10789{
10790 struct alc_spec *spec = codec->spec;
10791 int err;
10792 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10793
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010794 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10795 alc262_ignore);
10796 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010797 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010798 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010799 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010800 spec->multiout.max_channels = 2;
10801 spec->no_analog = 1;
10802 goto dig_only;
10803 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010804 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010805 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010806 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10807 if (err < 0)
10808 return err;
10809 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10810 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010811 return err;
10812
10813 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10814
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010815 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010816 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010817 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010818 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010819 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010820 if (spec->autocfg.dig_in_pin)
10821 spec->dig_in_nid = ALC262_DIGIN_NID;
10822
Takashi Iwai603c4012008-07-30 15:01:44 +020010823 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010824 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010825
Takashi Iwaid88897e2008-10-31 15:01:37 +010010826 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010827 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010828 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010829
Takashi Iwai776e1842007-08-29 15:07:11 +020010830 err = alc_auto_add_mic_boost(codec);
10831 if (err < 0)
10832 return err;
10833
Kailang Yangdf694da2005-12-05 19:42:22 +010010834 return 1;
10835}
10836
10837#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10838#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10839#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010840#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010841
10842
10843/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010844static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010845{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010846 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010847 alc262_auto_init_multi_out(codec);
10848 alc262_auto_init_hp_out(codec);
10849 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010850 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010851 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010852 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010853}
10854
10855/*
10856 * configuration and preset
10857 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010858static const char *alc262_models[ALC262_MODEL_LAST] = {
10859 [ALC262_BASIC] = "basic",
10860 [ALC262_HIPPO] = "hippo",
10861 [ALC262_HIPPO_1] = "hippo_1",
10862 [ALC262_FUJITSU] = "fujitsu",
10863 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010864 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010865 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010866 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010867 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010868 [ALC262_BENQ_T31] = "benq-t31",
10869 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010870 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010871 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010872 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010873 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010874 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010875 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010876 [ALC262_AUTO] = "auto",
10877};
10878
10879static struct snd_pci_quirk alc262_cfg_tbl[] = {
10880 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010881 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010882 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10883 ALC262_HP_BPC),
10884 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10885 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010886 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10887 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010888 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010889 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010890 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010891 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010892 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010893 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010894 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010895 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010896 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10897 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10898 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010899 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10900 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010901 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010902 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010903 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010904 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010905 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010906 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10907 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010908 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010909 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010910 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010911 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010912 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010913 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010914 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10915 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010916 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010917 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010918 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010919 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010920 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010921 {}
10922};
10923
10924static struct alc_config_preset alc262_presets[] = {
10925 [ALC262_BASIC] = {
10926 .mixers = { alc262_base_mixer },
10927 .init_verbs = { alc262_init_verbs },
10928 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10929 .dac_nids = alc262_dac_nids,
10930 .hp_nid = 0x03,
10931 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10932 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010933 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010934 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010935 [ALC262_HIPPO] = {
10936 .mixers = { alc262_base_mixer },
10937 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10939 .dac_nids = alc262_dac_nids,
10940 .hp_nid = 0x03,
10941 .dig_out_nid = ALC262_DIGOUT_NID,
10942 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10943 .channel_mode = alc262_modes,
10944 .input_mux = &alc262_capture_source,
10945 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010946 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010947 },
10948 [ALC262_HIPPO_1] = {
10949 .mixers = { alc262_hippo1_mixer },
10950 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10951 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10952 .dac_nids = alc262_dac_nids,
10953 .hp_nid = 0x02,
10954 .dig_out_nid = ALC262_DIGOUT_NID,
10955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10956 .channel_mode = alc262_modes,
10957 .input_mux = &alc262_capture_source,
10958 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010959 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010960 },
Takashi Iwai834be882006-03-01 14:16:17 +010010961 [ALC262_FUJITSU] = {
10962 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010963 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10964 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .dac_nids = alc262_dac_nids,
10967 .hp_nid = 0x03,
10968 .dig_out_nid = ALC262_DIGOUT_NID,
10969 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10970 .channel_mode = alc262_modes,
10971 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010972 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010973 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010974 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010975 [ALC262_HP_BPC] = {
10976 .mixers = { alc262_HP_BPC_mixer },
10977 .init_verbs = { alc262_HP_BPC_init_verbs },
10978 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10979 .dac_nids = alc262_dac_nids,
10980 .hp_nid = 0x03,
10981 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10982 .channel_mode = alc262_modes,
10983 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010984 .unsol_event = alc262_hp_bpc_unsol_event,
10985 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010986 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010987 [ALC262_HP_BPC_D7000_WF] = {
10988 .mixers = { alc262_HP_BPC_WildWest_mixer },
10989 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10990 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10991 .dac_nids = alc262_dac_nids,
10992 .hp_nid = 0x03,
10993 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10994 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010995 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010996 .unsol_event = alc262_hp_wildwest_unsol_event,
10997 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010998 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010999 [ALC262_HP_BPC_D7000_WL] = {
11000 .mixers = { alc262_HP_BPC_WildWest_mixer,
11001 alc262_HP_BPC_WildWest_option_mixer },
11002 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11003 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11004 .dac_nids = alc262_dac_nids,
11005 .hp_nid = 0x03,
11006 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11007 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011008 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011009 .unsol_event = alc262_hp_wildwest_unsol_event,
11010 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011011 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011012 [ALC262_HP_TC_T5735] = {
11013 .mixers = { alc262_hp_t5735_mixer },
11014 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11015 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11016 .dac_nids = alc262_dac_nids,
11017 .hp_nid = 0x03,
11018 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11019 .channel_mode = alc262_modes,
11020 .input_mux = &alc262_capture_source,
11021 .unsol_event = alc262_hp_t5735_unsol_event,
11022 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011023 },
11024 [ALC262_HP_RP5700] = {
11025 .mixers = { alc262_hp_rp5700_mixer },
11026 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11027 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11028 .dac_nids = alc262_dac_nids,
11029 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11030 .channel_mode = alc262_modes,
11031 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011032 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011033 [ALC262_BENQ_ED8] = {
11034 .mixers = { alc262_base_mixer },
11035 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11036 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11037 .dac_nids = alc262_dac_nids,
11038 .hp_nid = 0x03,
11039 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11040 .channel_mode = alc262_modes,
11041 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011042 },
Kailang Yang272a5272007-05-14 11:00:38 +020011043 [ALC262_SONY_ASSAMD] = {
11044 .mixers = { alc262_sony_mixer },
11045 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11047 .dac_nids = alc262_dac_nids,
11048 .hp_nid = 0x02,
11049 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11050 .channel_mode = alc262_modes,
11051 .input_mux = &alc262_capture_source,
11052 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011053 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011054 },
11055 [ALC262_BENQ_T31] = {
11056 .mixers = { alc262_benq_t31_mixer },
11057 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11059 .dac_nids = alc262_dac_nids,
11060 .hp_nid = 0x03,
11061 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11062 .channel_mode = alc262_modes,
11063 .input_mux = &alc262_capture_source,
11064 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020011065 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011066 },
Tobin Davisf651b502007-10-26 12:40:47 +020011067 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011068 .mixers = { alc262_ultra_mixer },
11069 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011070 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011071 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11072 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011073 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11074 .channel_mode = alc262_modes,
11075 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011076 .adc_nids = alc262_adc_nids, /* ADC0 */
11077 .capsrc_nids = alc262_capsrc_nids,
11078 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011079 .unsol_event = alc262_ultra_unsol_event,
11080 .init_hook = alc262_ultra_automute,
11081 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011082 [ALC262_LENOVO_3000] = {
11083 .mixers = { alc262_lenovo_3000_mixer },
11084 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11085 alc262_lenovo_3000_unsol_verbs },
11086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11087 .dac_nids = alc262_dac_nids,
11088 .hp_nid = 0x03,
11089 .dig_out_nid = ALC262_DIGOUT_NID,
11090 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11091 .channel_mode = alc262_modes,
11092 .input_mux = &alc262_fujitsu_capture_source,
11093 .unsol_event = alc262_lenovo_3000_unsol_event,
11094 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011095 [ALC262_NEC] = {
11096 .mixers = { alc262_nec_mixer },
11097 .init_verbs = { alc262_nec_verbs },
11098 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11099 .dac_nids = alc262_dac_nids,
11100 .hp_nid = 0x03,
11101 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11102 .channel_mode = alc262_modes,
11103 .input_mux = &alc262_capture_source,
11104 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011105 [ALC262_TOSHIBA_S06] = {
11106 .mixers = { alc262_toshiba_s06_mixer },
11107 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11108 alc262_eapd_verbs },
11109 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11110 .capsrc_nids = alc262_dmic_capsrc_nids,
11111 .dac_nids = alc262_dac_nids,
11112 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11113 .dig_out_nid = ALC262_DIGOUT_NID,
11114 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11115 .channel_mode = alc262_modes,
11116 .input_mux = &alc262_dmic_capture_source,
11117 .unsol_event = alc262_toshiba_s06_unsol_event,
11118 .init_hook = alc262_toshiba_s06_init_hook,
11119 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011120 [ALC262_TOSHIBA_RX1] = {
11121 .mixers = { alc262_toshiba_rx1_mixer },
11122 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11123 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11124 .dac_nids = alc262_dac_nids,
11125 .hp_nid = 0x03,
11126 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11127 .channel_mode = alc262_modes,
11128 .input_mux = &alc262_capture_source,
11129 .unsol_event = alc262_hippo_unsol_event,
11130 .init_hook = alc262_hippo_automute,
11131 },
Tony Vroonba340e82009-02-02 19:01:30 +000011132 [ALC262_TYAN] = {
11133 .mixers = { alc262_tyan_mixer },
11134 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11135 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11136 .dac_nids = alc262_dac_nids,
11137 .hp_nid = 0x02,
11138 .dig_out_nid = ALC262_DIGOUT_NID,
11139 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11140 .channel_mode = alc262_modes,
11141 .input_mux = &alc262_capture_source,
11142 .unsol_event = alc262_tyan_unsol_event,
11143 .init_hook = alc262_tyan_automute,
11144 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011145};
11146
11147static int patch_alc262(struct hda_codec *codec)
11148{
11149 struct alc_spec *spec;
11150 int board_config;
11151 int err;
11152
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011154 if (spec == NULL)
11155 return -ENOMEM;
11156
11157 codec->spec = spec;
11158#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011159 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11160 * under-run
11161 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011162 {
11163 int tmp;
11164 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11165 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11166 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11167 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11168 }
11169#endif
11170
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011171 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11172
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011173 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11174 alc262_models,
11175 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011176
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011177 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011178 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11179 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011180 board_config = ALC262_AUTO;
11181 }
11182
11183 if (board_config == ALC262_AUTO) {
11184 /* automatic parse from the BIOS config */
11185 err = alc262_parse_auto_config(codec);
11186 if (err < 0) {
11187 alc_free(codec);
11188 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011189 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011190 printk(KERN_INFO
11191 "hda_codec: Cannot set up configuration "
11192 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011193 board_config = ALC262_BASIC;
11194 }
11195 }
11196
Takashi Iwai07eba612009-02-19 08:06:35 +010011197 if (!spec->no_analog) {
11198 err = snd_hda_attach_beep_device(codec, 0x1);
11199 if (err < 0) {
11200 alc_free(codec);
11201 return err;
11202 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011203 }
11204
Kailang Yangdf694da2005-12-05 19:42:22 +010011205 if (board_config != ALC262_AUTO)
11206 setup_preset(spec, &alc262_presets[board_config]);
11207
11208 spec->stream_name_analog = "ALC262 Analog";
11209 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11210 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011211
Kailang Yangdf694da2005-12-05 19:42:22 +010011212 spec->stream_name_digital = "ALC262 Digital";
11213 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11214 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11215
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011216 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011217 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011218 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011219 unsigned int wcap = get_wcaps(codec, 0x07);
11220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011221 /* get type */
11222 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011223 if (wcap != AC_WID_AUD_IN) {
11224 spec->adc_nids = alc262_adc_nids_alt;
11225 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011226 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011227 } else {
11228 spec->adc_nids = alc262_adc_nids;
11229 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011230 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011231 }
11232 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011233 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011234 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011235 if (!spec->no_analog)
11236 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011237
Takashi Iwai2134ea42008-01-10 16:53:55 +010011238 spec->vmaster_nid = 0x0c;
11239
Kailang Yangdf694da2005-12-05 19:42:22 +010011240 codec->patch_ops = alc_patch_ops;
11241 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011242 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011243#ifdef CONFIG_SND_HDA_POWER_SAVE
11244 if (!spec->loopback.amplist)
11245 spec->loopback.amplist = alc262_loopbacks;
11246#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011247 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011248
Kailang Yangdf694da2005-12-05 19:42:22 +010011249 return 0;
11250}
11251
Kailang Yangdf694da2005-12-05 19:42:22 +010011252/*
Kailang Yanga361d842007-06-05 12:30:55 +020011253 * ALC268 channel source setting (2 channel)
11254 */
11255#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11256#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011257
Kailang Yanga361d842007-06-05 12:30:55 +020011258static hda_nid_t alc268_dac_nids[2] = {
11259 /* front, hp */
11260 0x02, 0x03
11261};
11262
11263static hda_nid_t alc268_adc_nids[2] = {
11264 /* ADC0-1 */
11265 0x08, 0x07
11266};
11267
11268static hda_nid_t alc268_adc_nids_alt[1] = {
11269 /* ADC0 */
11270 0x08
11271};
11272
Takashi Iwaie1406342008-02-11 18:32:32 +010011273static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11274
Kailang Yanga361d842007-06-05 12:30:55 +020011275static struct snd_kcontrol_new alc268_base_mixer[] = {
11276 /* output mixer control */
11277 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11278 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11279 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011281 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11282 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11283 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011284 { }
11285};
11286
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011287/* bind Beep switches of both NID 0x0f and 0x10 */
11288static struct hda_bind_ctls alc268_bind_beep_sw = {
11289 .ops = &snd_hda_bind_sw,
11290 .values = {
11291 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11292 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11293 0
11294 },
11295};
11296
11297static struct snd_kcontrol_new alc268_beep_mixer[] = {
11298 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11299 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11300 { }
11301};
11302
Kailang Yangd1a991a2007-08-15 16:21:59 +020011303static struct hda_verb alc268_eapd_verbs[] = {
11304 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11305 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11306 { }
11307};
11308
Takashi Iwaid2738092007-08-16 14:59:45 +020011309/* Toshiba specific */
11310#define alc268_toshiba_automute alc262_hippo_automute
11311
11312static struct hda_verb alc268_toshiba_verbs[] = {
11313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11314 { } /* end */
11315};
11316
Kailang Yang8ef355d2008-08-26 13:10:22 +020011317static struct hda_input_mux alc268_acer_lc_capture_source = {
11318 .num_items = 2,
11319 .items = {
11320 { "i-Mic", 0x6 },
11321 { "E-Mic", 0x0 },
11322 },
11323};
11324
Takashi Iwaid2738092007-08-16 14:59:45 +020011325/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011326/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011327static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11328 .ops = &snd_hda_bind_vol,
11329 .values = {
11330 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11331 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11332 0
11333 },
11334};
11335
Takashi Iwai889c4392007-08-23 18:56:52 +020011336/* mute/unmute internal speaker according to the hp jack and mute state */
11337static void alc268_acer_automute(struct hda_codec *codec, int force)
11338{
11339 struct alc_spec *spec = codec->spec;
11340 unsigned int mute;
11341
11342 if (force || !spec->sense_updated) {
11343 unsigned int present;
11344 present = snd_hda_codec_read(codec, 0x14, 0,
11345 AC_VERB_GET_PIN_SENSE, 0);
11346 spec->jack_present = (present & 0x80000000) != 0;
11347 spec->sense_updated = 1;
11348 }
11349 if (spec->jack_present)
11350 mute = HDA_AMP_MUTE; /* mute internal speaker */
11351 else /* unmute internal speaker if necessary */
11352 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11353 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11354 HDA_AMP_MUTE, mute);
11355}
11356
11357
11358/* bind hp and internal speaker mute (with plug check) */
11359static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11360 struct snd_ctl_elem_value *ucontrol)
11361{
11362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11363 long *valp = ucontrol->value.integer.value;
11364 int change;
11365
11366 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11367 HDA_AMP_MUTE,
11368 valp[0] ? 0 : HDA_AMP_MUTE);
11369 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11370 HDA_AMP_MUTE,
11371 valp[1] ? 0 : HDA_AMP_MUTE);
11372 if (change)
11373 alc268_acer_automute(codec, 0);
11374 return change;
11375}
Takashi Iwaid2738092007-08-16 14:59:45 +020011376
Kailang Yang8ef355d2008-08-26 13:10:22 +020011377static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11378 /* output mixer control */
11379 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11380 {
11381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11382 .name = "Master Playback Switch",
11383 .info = snd_hda_mixer_amp_switch_info,
11384 .get = snd_hda_mixer_amp_switch_get,
11385 .put = alc268_acer_master_sw_put,
11386 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11387 },
11388 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11389 { }
11390};
11391
Takashi Iwaid2738092007-08-16 14:59:45 +020011392static struct snd_kcontrol_new alc268_acer_mixer[] = {
11393 /* output mixer control */
11394 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11395 {
11396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11397 .name = "Master Playback Switch",
11398 .info = snd_hda_mixer_amp_switch_info,
11399 .get = snd_hda_mixer_amp_switch_get,
11400 .put = alc268_acer_master_sw_put,
11401 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11402 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011403 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11404 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011406 { }
11407};
11408
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011409static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11410 /* output mixer control */
11411 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11412 {
11413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11414 .name = "Master Playback Switch",
11415 .info = snd_hda_mixer_amp_switch_info,
11416 .get = snd_hda_mixer_amp_switch_get,
11417 .put = alc268_acer_master_sw_put,
11418 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11419 },
11420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11421 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11422 { }
11423};
11424
Kailang Yang8ef355d2008-08-26 13:10:22 +020011425static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11426 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11428 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11429 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11430 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11431 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11432 { }
11433};
11434
Takashi Iwaid2738092007-08-16 14:59:45 +020011435static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011436 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11437 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011442 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11443 { }
11444};
11445
11446/* unsolicited event for HP jack sensing */
11447static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11448 unsigned int res)
11449{
Takashi Iwai889c4392007-08-23 18:56:52 +020011450 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011451 return;
11452 alc268_toshiba_automute(codec);
11453}
11454
11455static void alc268_acer_unsol_event(struct hda_codec *codec,
11456 unsigned int res)
11457{
Takashi Iwai889c4392007-08-23 18:56:52 +020011458 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011459 return;
11460 alc268_acer_automute(codec, 1);
11461}
11462
Takashi Iwai889c4392007-08-23 18:56:52 +020011463static void alc268_acer_init_hook(struct hda_codec *codec)
11464{
11465 alc268_acer_automute(codec, 1);
11466}
11467
Kailang Yang8ef355d2008-08-26 13:10:22 +020011468/* toggle speaker-output according to the hp-jack state */
11469static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11470{
11471 unsigned int present;
11472 unsigned char bits;
11473
11474 present = snd_hda_codec_read(codec, 0x15, 0,
11475 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11476 bits = present ? AMP_IN_MUTE(0) : 0;
11477 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11478 AMP_IN_MUTE(0), bits);
11479 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11480 AMP_IN_MUTE(0), bits);
11481}
11482
11483
11484static void alc268_acer_mic_automute(struct hda_codec *codec)
11485{
11486 unsigned int present;
11487
11488 present = snd_hda_codec_read(codec, 0x18, 0,
11489 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11490 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11491 present ? 0x0 : 0x6);
11492}
11493
11494static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11495 unsigned int res)
11496{
11497 if ((res >> 26) == ALC880_HP_EVENT)
11498 alc268_aspire_one_speaker_automute(codec);
11499 if ((res >> 26) == ALC880_MIC_EVENT)
11500 alc268_acer_mic_automute(codec);
11501}
11502
11503static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11504{
11505 alc268_aspire_one_speaker_automute(codec);
11506 alc268_acer_mic_automute(codec);
11507}
11508
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011509static struct snd_kcontrol_new alc268_dell_mixer[] = {
11510 /* output mixer control */
11511 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11512 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11513 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11516 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11517 { }
11518};
11519
11520static struct hda_verb alc268_dell_verbs[] = {
11521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11523 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11524 { }
11525};
11526
11527/* mute/unmute internal speaker according to the hp jack and mute state */
11528static void alc268_dell_automute(struct hda_codec *codec)
11529{
11530 unsigned int present;
11531 unsigned int mute;
11532
11533 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11534 if (present & 0x80000000)
11535 mute = HDA_AMP_MUTE;
11536 else
11537 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11538 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11539 HDA_AMP_MUTE, mute);
11540}
11541
11542static void alc268_dell_unsol_event(struct hda_codec *codec,
11543 unsigned int res)
11544{
11545 if ((res >> 26) != ALC880_HP_EVENT)
11546 return;
11547 alc268_dell_automute(codec);
11548}
11549
11550#define alc268_dell_init_hook alc268_dell_automute
11551
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011552static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11553 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11554 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11557 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11558 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11559 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11560 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11561 { }
11562};
11563
11564static struct hda_verb alc267_quanta_il1_verbs[] = {
11565 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11566 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11567 { }
11568};
11569
11570static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11571{
11572 unsigned int present;
11573
11574 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11575 & AC_PINSENSE_PRESENCE;
11576 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11577 present ? 0 : PIN_OUT);
11578}
11579
11580static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11581{
11582 unsigned int present;
11583
11584 present = snd_hda_codec_read(codec, 0x18, 0,
11585 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11586 snd_hda_codec_write(codec, 0x23, 0,
11587 AC_VERB_SET_CONNECT_SEL,
11588 present ? 0x00 : 0x01);
11589}
11590
11591static void alc267_quanta_il1_automute(struct hda_codec *codec)
11592{
11593 alc267_quanta_il1_hp_automute(codec);
11594 alc267_quanta_il1_mic_automute(codec);
11595}
11596
11597static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11598 unsigned int res)
11599{
11600 switch (res >> 26) {
11601 case ALC880_HP_EVENT:
11602 alc267_quanta_il1_hp_automute(codec);
11603 break;
11604 case ALC880_MIC_EVENT:
11605 alc267_quanta_il1_mic_automute(codec);
11606 break;
11607 }
11608}
11609
Kailang Yanga361d842007-06-05 12:30:55 +020011610/*
11611 * generic initialization of ADC, input mixers and output mixers
11612 */
11613static struct hda_verb alc268_base_init_verbs[] = {
11614 /* Unmute DAC0-1 and set vol = 0 */
11615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011616 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011617
11618 /*
11619 * Set up output mixers (0x0c - 0x0e)
11620 */
11621 /* set vol=0 to output mixers */
11622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011623 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11624
11625 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11626 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11627
11628 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11631 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11632 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11633 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11635 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11636
11637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011642
11643 /* set PCBEEP vol = 0, mute connections */
11644 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011647
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011648 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011649
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011650 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11652 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011654
Kailang Yanga361d842007-06-05 12:30:55 +020011655 { }
11656};
11657
11658/*
11659 * generic initialization of ADC, input mixers and output mixers
11660 */
11661static struct hda_verb alc268_volume_init_verbs[] = {
11662 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011663 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11664 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011665
11666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11669 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11670 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11671
Kailang Yanga361d842007-06-05 12:30:55 +020011672 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11674 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11675
11676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011678
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011679 /* set PCBEEP vol = 0, mute connections */
11680 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11682 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011683
11684 { }
11685};
11686
Kailang Yanga361d842007-06-05 12:30:55 +020011687static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11688 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11689 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11690 {
11691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11692 /* The multiple "Capture Source" controls confuse alsamixer
11693 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011694 */
11695 /* .name = "Capture Source", */
11696 .name = "Input Source",
11697 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011698 .info = alc_mux_enum_info,
11699 .get = alc_mux_enum_get,
11700 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011701 },
11702 { } /* end */
11703};
11704
11705static struct snd_kcontrol_new alc268_capture_mixer[] = {
11706 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11707 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11708 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11709 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11710 {
11711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11712 /* The multiple "Capture Source" controls confuse alsamixer
11713 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011714 */
11715 /* .name = "Capture Source", */
11716 .name = "Input Source",
11717 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011718 .info = alc_mux_enum_info,
11719 .get = alc_mux_enum_get,
11720 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011721 },
11722 { } /* end */
11723};
11724
11725static struct hda_input_mux alc268_capture_source = {
11726 .num_items = 4,
11727 .items = {
11728 { "Mic", 0x0 },
11729 { "Front Mic", 0x1 },
11730 { "Line", 0x2 },
11731 { "CD", 0x3 },
11732 },
11733};
11734
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011735static struct hda_input_mux alc268_acer_capture_source = {
11736 .num_items = 3,
11737 .items = {
11738 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011739 { "Internal Mic", 0x1 },
11740 { "Line", 0x2 },
11741 },
11742};
11743
11744static struct hda_input_mux alc268_acer_dmic_capture_source = {
11745 .num_items = 3,
11746 .items = {
11747 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011748 { "Internal Mic", 0x6 },
11749 { "Line", 0x2 },
11750 },
11751};
11752
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011753#ifdef CONFIG_SND_DEBUG
11754static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011755 /* Volume widgets */
11756 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11757 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11758 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11759 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11760 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11761 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11762 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11763 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11764 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11765 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11766 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11767 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11768 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011769 /* The below appears problematic on some hardwares */
11770 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011771 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11772 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11773 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11774 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11775
11776 /* Modes for retasking pin widgets */
11777 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11778 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11779 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11780 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11781
11782 /* Controls for GPIO pins, assuming they are configured as outputs */
11783 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11784 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11785 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11786 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11787
11788 /* Switches to allow the digital SPDIF output pin to be enabled.
11789 * The ALC268 does not have an SPDIF input.
11790 */
11791 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11792
11793 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11794 * this output to turn on an external amplifier.
11795 */
11796 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11797 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11798
11799 { } /* end */
11800};
11801#endif
11802
Kailang Yanga361d842007-06-05 12:30:55 +020011803/* create input playback/capture controls for the given pin */
11804static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11805 const char *ctlname, int idx)
11806{
11807 char name[32];
11808 int err;
11809
11810 sprintf(name, "%s Playback Volume", ctlname);
11811 if (nid == 0x14) {
11812 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11813 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11814 HDA_OUTPUT));
11815 if (err < 0)
11816 return err;
11817 } else if (nid == 0x15) {
11818 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11819 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11820 HDA_OUTPUT));
11821 if (err < 0)
11822 return err;
11823 } else
11824 return -1;
11825 sprintf(name, "%s Playback Switch", ctlname);
11826 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11827 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11828 if (err < 0)
11829 return err;
11830 return 0;
11831}
11832
11833/* add playback controls from the parsed DAC table */
11834static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11835 const struct auto_pin_cfg *cfg)
11836{
11837 hda_nid_t nid;
11838 int err;
11839
11840 spec->multiout.num_dacs = 2; /* only use one dac */
11841 spec->multiout.dac_nids = spec->private_dac_nids;
11842 spec->multiout.dac_nids[0] = 2;
11843 spec->multiout.dac_nids[1] = 3;
11844
11845 nid = cfg->line_out_pins[0];
11846 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011847 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011848
11849 nid = cfg->speaker_pins[0];
11850 if (nid == 0x1d) {
11851 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11852 "Speaker Playback Volume",
11853 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11854 if (err < 0)
11855 return err;
11856 }
11857 nid = cfg->hp_pins[0];
11858 if (nid)
11859 alc268_new_analog_output(spec, nid, "Headphone", 0);
11860
11861 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11862 if (nid == 0x16) {
11863 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11864 "Mono Playback Switch",
11865 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11866 if (err < 0)
11867 return err;
11868 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011869 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011870}
11871
11872/* create playback/capture controls for input pins */
11873static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11874 const struct auto_pin_cfg *cfg)
11875{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011876 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011877 int i, idx1;
11878
11879 for (i = 0; i < AUTO_PIN_LAST; i++) {
11880 switch(cfg->input_pins[i]) {
11881 case 0x18:
11882 idx1 = 0; /* Mic 1 */
11883 break;
11884 case 0x19:
11885 idx1 = 1; /* Mic 2 */
11886 break;
11887 case 0x1a:
11888 idx1 = 2; /* Line In */
11889 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011890 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011891 idx1 = 3; /* CD */
11892 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011893 case 0x12:
11894 case 0x13:
11895 idx1 = 6; /* digital mics */
11896 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011897 default:
11898 continue;
11899 }
11900 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11901 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011902 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011903 }
11904 return 0;
11905}
11906
11907static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11908{
11909 struct alc_spec *spec = codec->spec;
11910 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11911 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11912 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11913 unsigned int dac_vol1, dac_vol2;
11914
11915 if (speaker_nid) {
11916 snd_hda_codec_write(codec, speaker_nid, 0,
11917 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11918 snd_hda_codec_write(codec, 0x0f, 0,
11919 AC_VERB_SET_AMP_GAIN_MUTE,
11920 AMP_IN_UNMUTE(1));
11921 snd_hda_codec_write(codec, 0x10, 0,
11922 AC_VERB_SET_AMP_GAIN_MUTE,
11923 AMP_IN_UNMUTE(1));
11924 } else {
11925 snd_hda_codec_write(codec, 0x0f, 0,
11926 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11927 snd_hda_codec_write(codec, 0x10, 0,
11928 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11929 }
11930
11931 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011932 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011933 dac_vol2 = AMP_OUT_ZERO;
11934 else if (line_nid == 0x15)
11935 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011936 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011937 dac_vol2 = AMP_OUT_ZERO;
11938 else if (hp_nid == 0x15)
11939 dac_vol1 = AMP_OUT_ZERO;
11940 if (line_nid != 0x16 || hp_nid != 0x16 ||
11941 spec->autocfg.line_out_pins[1] != 0x16 ||
11942 spec->autocfg.line_out_pins[2] != 0x16)
11943 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11944
11945 snd_hda_codec_write(codec, 0x02, 0,
11946 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11947 snd_hda_codec_write(codec, 0x03, 0,
11948 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11949}
11950
11951/* pcm configuration: identiacal with ALC880 */
11952#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11953#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011954#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011955#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11956
11957/*
11958 * BIOS auto configuration
11959 */
11960static int alc268_parse_auto_config(struct hda_codec *codec)
11961{
11962 struct alc_spec *spec = codec->spec;
11963 int err;
11964 static hda_nid_t alc268_ignore[] = { 0 };
11965
11966 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11967 alc268_ignore);
11968 if (err < 0)
11969 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011970 if (!spec->autocfg.line_outs) {
11971 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11972 spec->multiout.max_channels = 2;
11973 spec->no_analog = 1;
11974 goto dig_only;
11975 }
Kailang Yanga361d842007-06-05 12:30:55 +020011976 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011977 }
Kailang Yanga361d842007-06-05 12:30:55 +020011978 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11979 if (err < 0)
11980 return err;
11981 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11982 if (err < 0)
11983 return err;
11984
11985 spec->multiout.max_channels = 2;
11986
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011987 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011988 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011989 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011990 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011991 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11992 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011993 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011994 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011995
Takashi Iwai892981f2009-03-02 08:04:35 +010011996 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011997 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011998
Takashi Iwaid88897e2008-10-31 15:01:37 +010011999 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012000 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012001 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012002
Takashi Iwai776e1842007-08-29 15:07:11 +020012003 err = alc_auto_add_mic_boost(codec);
12004 if (err < 0)
12005 return err;
12006
Kailang Yanga361d842007-06-05 12:30:55 +020012007 return 1;
12008}
12009
12010#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12011#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12012#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12013
12014/* init callback for auto-configuration model -- overriding the default init */
12015static void alc268_auto_init(struct hda_codec *codec)
12016{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012017 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012018 alc268_auto_init_multi_out(codec);
12019 alc268_auto_init_hp_out(codec);
12020 alc268_auto_init_mono_speaker_out(codec);
12021 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012022 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012023 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012024}
12025
12026/*
12027 * configuration and preset
12028 */
12029static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012030 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012031 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012032 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012033 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012034 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012035 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012036 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012037 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012038#ifdef CONFIG_SND_DEBUG
12039 [ALC268_TEST] = "test",
12040#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012041 [ALC268_AUTO] = "auto",
12042};
12043
12044static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012045 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012046 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012047 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012048 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012049 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012050 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12051 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012052 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012053 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012054 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012055 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012056 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012057 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012058 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012059 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012060 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012061 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012062 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012063 {}
12064};
12065
12066static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012067 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012068 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012069 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12070 alc267_quanta_il1_verbs },
12071 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12072 .dac_nids = alc268_dac_nids,
12073 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12074 .adc_nids = alc268_adc_nids_alt,
12075 .hp_nid = 0x03,
12076 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12077 .channel_mode = alc268_modes,
12078 .input_mux = &alc268_capture_source,
12079 .unsol_event = alc267_quanta_il1_unsol_event,
12080 .init_hook = alc267_quanta_il1_automute,
12081 },
Kailang Yanga361d842007-06-05 12:30:55 +020012082 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012083 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12084 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012085 .init_verbs = { alc268_base_init_verbs },
12086 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12087 .dac_nids = alc268_dac_nids,
12088 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12089 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012090 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012091 .hp_nid = 0x03,
12092 .dig_out_nid = ALC268_DIGOUT_NID,
12093 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12094 .channel_mode = alc268_modes,
12095 .input_mux = &alc268_capture_source,
12096 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012097 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012098 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12099 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012100 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12101 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012102 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12103 .dac_nids = alc268_dac_nids,
12104 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12105 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012106 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012107 .hp_nid = 0x03,
12108 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12109 .channel_mode = alc268_modes,
12110 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012111 .unsol_event = alc268_toshiba_unsol_event,
12112 .init_hook = alc268_toshiba_automute,
12113 },
12114 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012115 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12116 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012117 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12118 alc268_acer_verbs },
12119 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12120 .dac_nids = alc268_dac_nids,
12121 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12122 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012123 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012124 .hp_nid = 0x02,
12125 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12126 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012127 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012128 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012129 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012130 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012131 [ALC268_ACER_DMIC] = {
12132 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12133 alc268_beep_mixer },
12134 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12135 alc268_acer_verbs },
12136 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12137 .dac_nids = alc268_dac_nids,
12138 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12139 .adc_nids = alc268_adc_nids_alt,
12140 .capsrc_nids = alc268_capsrc_nids,
12141 .hp_nid = 0x02,
12142 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12143 .channel_mode = alc268_modes,
12144 .input_mux = &alc268_acer_dmic_capture_source,
12145 .unsol_event = alc268_acer_unsol_event,
12146 .init_hook = alc268_acer_init_hook,
12147 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012148 [ALC268_ACER_ASPIRE_ONE] = {
12149 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012150 alc268_beep_mixer,
12151 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012152 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12153 alc268_acer_aspire_one_verbs },
12154 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12155 .dac_nids = alc268_dac_nids,
12156 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12157 .adc_nids = alc268_adc_nids_alt,
12158 .capsrc_nids = alc268_capsrc_nids,
12159 .hp_nid = 0x03,
12160 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12161 .channel_mode = alc268_modes,
12162 .input_mux = &alc268_acer_lc_capture_source,
12163 .unsol_event = alc268_acer_lc_unsol_event,
12164 .init_hook = alc268_acer_lc_init_hook,
12165 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012166 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012167 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012168 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12169 alc268_dell_verbs },
12170 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12171 .dac_nids = alc268_dac_nids,
12172 .hp_nid = 0x02,
12173 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12174 .channel_mode = alc268_modes,
12175 .unsol_event = alc268_dell_unsol_event,
12176 .init_hook = alc268_dell_init_hook,
12177 .input_mux = &alc268_capture_source,
12178 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012179 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012180 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12181 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012182 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12183 alc268_toshiba_verbs },
12184 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12185 .dac_nids = alc268_dac_nids,
12186 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12187 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012188 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012189 .hp_nid = 0x03,
12190 .dig_out_nid = ALC268_DIGOUT_NID,
12191 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12192 .channel_mode = alc268_modes,
12193 .input_mux = &alc268_capture_source,
12194 .unsol_event = alc268_toshiba_unsol_event,
12195 .init_hook = alc268_toshiba_automute
12196 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012197#ifdef CONFIG_SND_DEBUG
12198 [ALC268_TEST] = {
12199 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12200 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12201 alc268_volume_init_verbs },
12202 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12203 .dac_nids = alc268_dac_nids,
12204 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12205 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012206 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012207 .hp_nid = 0x03,
12208 .dig_out_nid = ALC268_DIGOUT_NID,
12209 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12210 .channel_mode = alc268_modes,
12211 .input_mux = &alc268_capture_source,
12212 },
12213#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012214};
12215
12216static int patch_alc268(struct hda_codec *codec)
12217{
12218 struct alc_spec *spec;
12219 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012220 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012221
12222 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12223 if (spec == NULL)
12224 return -ENOMEM;
12225
12226 codec->spec = spec;
12227
12228 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12229 alc268_models,
12230 alc268_cfg_tbl);
12231
12232 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12233 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12234 "trying auto-probe from BIOS...\n");
12235 board_config = ALC268_AUTO;
12236 }
12237
12238 if (board_config == ALC268_AUTO) {
12239 /* automatic parse from the BIOS config */
12240 err = alc268_parse_auto_config(codec);
12241 if (err < 0) {
12242 alc_free(codec);
12243 return err;
12244 } else if (!err) {
12245 printk(KERN_INFO
12246 "hda_codec: Cannot set up configuration "
12247 "from BIOS. Using base mode...\n");
12248 board_config = ALC268_3ST;
12249 }
12250 }
12251
12252 if (board_config != ALC268_AUTO)
12253 setup_preset(spec, &alc268_presets[board_config]);
12254
Kailang Yang2f893282008-05-27 12:14:47 +020012255 if (codec->vendor_id == 0x10ec0267) {
12256 spec->stream_name_analog = "ALC267 Analog";
12257 spec->stream_name_digital = "ALC267 Digital";
12258 } else {
12259 spec->stream_name_analog = "ALC268 Analog";
12260 spec->stream_name_digital = "ALC268 Digital";
12261 }
12262
Kailang Yanga361d842007-06-05 12:30:55 +020012263 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12264 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012265 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012266
Kailang Yanga361d842007-06-05 12:30:55 +020012267 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12268
Takashi Iwai22971e32009-02-10 11:56:44 +010012269 has_beep = 0;
12270 for (i = 0; i < spec->num_mixers; i++) {
12271 if (spec->mixers[i] == alc268_beep_mixer) {
12272 has_beep = 1;
12273 break;
12274 }
12275 }
12276
12277 if (has_beep) {
12278 err = snd_hda_attach_beep_device(codec, 0x1);
12279 if (err < 0) {
12280 alc_free(codec);
12281 return err;
12282 }
12283 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12284 /* override the amp caps for beep generator */
12285 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012286 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12287 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12288 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12289 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012290 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012291
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012292 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012293 /* check whether NID 0x07 is valid */
12294 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012295 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012296
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012297 /* get type */
12298 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012299 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012300 spec->adc_nids = alc268_adc_nids_alt;
12301 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012302 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012303 } else {
12304 spec->adc_nids = alc268_adc_nids;
12305 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012306 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012307 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012308 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012309 /* set default input source */
12310 for (i = 0; i < spec->num_adc_nids; i++)
12311 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12312 0, AC_VERB_SET_CONNECT_SEL,
12313 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012314 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012315
12316 spec->vmaster_nid = 0x02;
12317
Kailang Yanga361d842007-06-05 12:30:55 +020012318 codec->patch_ops = alc_patch_ops;
12319 if (board_config == ALC268_AUTO)
12320 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012321
Takashi Iwaidaead532008-11-28 12:55:36 +010012322 codec->proc_widget_hook = print_realtek_coef;
12323
Kailang Yanga361d842007-06-05 12:30:55 +020012324 return 0;
12325}
12326
12327/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012328 * ALC269 channel source setting (2 channel)
12329 */
12330#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12331
12332#define alc269_dac_nids alc260_dac_nids
12333
12334static hda_nid_t alc269_adc_nids[1] = {
12335 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012336 0x08,
12337};
12338
Takashi Iwaie01bf502008-08-21 16:25:07 +020012339static hda_nid_t alc269_capsrc_nids[1] = {
12340 0x23,
12341};
12342
12343/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12344 * not a mux!
12345 */
12346
Kailang Yangf53281e2008-07-18 12:36:43 +020012347static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12348 .num_items = 2,
12349 .items = {
12350 { "i-Mic", 0x5 },
12351 { "e-Mic", 0x0 },
12352 },
12353};
12354
12355static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12356 .num_items = 2,
12357 .items = {
12358 { "i-Mic", 0x1 },
12359 { "e-Mic", 0x0 },
12360 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012361};
12362
12363#define alc269_modes alc260_modes
12364#define alc269_capture_source alc880_lg_lw_capture_source
12365
12366static struct snd_kcontrol_new alc269_base_mixer[] = {
12367 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12368 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12378 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12379 { } /* end */
12380};
12381
Kailang Yang60db6b52008-08-26 13:13:00 +020012382static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12383 /* output mixer control */
12384 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12385 {
12386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12387 .name = "Master Playback Switch",
12388 .info = snd_hda_mixer_amp_switch_info,
12389 .get = snd_hda_mixer_amp_switch_get,
12390 .put = alc268_acer_master_sw_put,
12391 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12392 },
12393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12396 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12397 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12398 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012399 { }
12400};
12401
Tony Vroon64154832008-11-06 15:08:49 +000012402static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12403 /* output mixer control */
12404 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12405 {
12406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12407 .name = "Master Playback Switch",
12408 .info = snd_hda_mixer_amp_switch_info,
12409 .get = snd_hda_mixer_amp_switch_get,
12410 .put = alc268_acer_master_sw_put,
12411 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12412 },
12413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12415 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12416 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12417 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12418 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12419 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12420 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12421 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012422 { }
12423};
12424
Kailang Yangf53281e2008-07-18 12:36:43 +020012425/* bind volumes of both NID 0x0c and 0x0d */
12426static struct hda_bind_ctls alc269_epc_bind_vol = {
12427 .ops = &snd_hda_bind_vol,
12428 .values = {
12429 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12430 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12431 0
12432 },
12433};
12434
12435static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12436 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12437 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12438 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12439 { } /* end */
12440};
12441
Kailang Yangf6a92242007-12-13 16:52:54 +010012442/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012443static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12444 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12445 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012446 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12447 { } /* end */
12448};
12449
12450/* FSC amilo */
12451static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12452 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12454 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012455 { } /* end */
12456};
12457
Kailang Yang60db6b52008-08-26 13:13:00 +020012458static struct hda_verb alc269_quanta_fl1_verbs[] = {
12459 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12460 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12462 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12463 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12464 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12465 { }
12466};
12467
Tony Vroon64154832008-11-06 15:08:49 +000012468static struct hda_verb alc269_lifebook_verbs[] = {
12469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12470 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12471 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12472 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12476 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12477 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12478 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12479 { }
12480};
12481
Kailang Yang60db6b52008-08-26 13:13:00 +020012482/* toggle speaker-output according to the hp-jack state */
12483static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12484{
12485 unsigned int present;
12486 unsigned char bits;
12487
12488 present = snd_hda_codec_read(codec, 0x15, 0,
12489 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12490 bits = present ? AMP_IN_MUTE(0) : 0;
12491 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12492 AMP_IN_MUTE(0), bits);
12493 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12494 AMP_IN_MUTE(0), bits);
12495
12496 snd_hda_codec_write(codec, 0x20, 0,
12497 AC_VERB_SET_COEF_INDEX, 0x0c);
12498 snd_hda_codec_write(codec, 0x20, 0,
12499 AC_VERB_SET_PROC_COEF, 0x680);
12500
12501 snd_hda_codec_write(codec, 0x20, 0,
12502 AC_VERB_SET_COEF_INDEX, 0x0c);
12503 snd_hda_codec_write(codec, 0x20, 0,
12504 AC_VERB_SET_PROC_COEF, 0x480);
12505}
12506
Tony Vroon64154832008-11-06 15:08:49 +000012507/* toggle speaker-output according to the hp-jacks state */
12508static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12509{
12510 unsigned int present;
12511 unsigned char bits;
12512
12513 /* Check laptop headphone socket */
12514 present = snd_hda_codec_read(codec, 0x15, 0,
12515 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12516
12517 /* Check port replicator headphone socket */
12518 present |= snd_hda_codec_read(codec, 0x1a, 0,
12519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12520
12521 bits = present ? AMP_IN_MUTE(0) : 0;
12522 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12523 AMP_IN_MUTE(0), bits);
12524 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12525 AMP_IN_MUTE(0), bits);
12526
12527 snd_hda_codec_write(codec, 0x20, 0,
12528 AC_VERB_SET_COEF_INDEX, 0x0c);
12529 snd_hda_codec_write(codec, 0x20, 0,
12530 AC_VERB_SET_PROC_COEF, 0x680);
12531
12532 snd_hda_codec_write(codec, 0x20, 0,
12533 AC_VERB_SET_COEF_INDEX, 0x0c);
12534 snd_hda_codec_write(codec, 0x20, 0,
12535 AC_VERB_SET_PROC_COEF, 0x480);
12536}
12537
Kailang Yang60db6b52008-08-26 13:13:00 +020012538static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12539{
12540 unsigned int present;
12541
12542 present = snd_hda_codec_read(codec, 0x18, 0,
12543 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12544 snd_hda_codec_write(codec, 0x23, 0,
12545 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12546}
12547
Tony Vroon64154832008-11-06 15:08:49 +000012548static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12549{
12550 unsigned int present_laptop;
12551 unsigned int present_dock;
12552
12553 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12554 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12555
12556 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12557 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12558
12559 /* Laptop mic port overrides dock mic port, design decision */
12560 if (present_dock)
12561 snd_hda_codec_write(codec, 0x23, 0,
12562 AC_VERB_SET_CONNECT_SEL, 0x3);
12563 if (present_laptop)
12564 snd_hda_codec_write(codec, 0x23, 0,
12565 AC_VERB_SET_CONNECT_SEL, 0x0);
12566 if (!present_dock && !present_laptop)
12567 snd_hda_codec_write(codec, 0x23, 0,
12568 AC_VERB_SET_CONNECT_SEL, 0x1);
12569}
12570
Kailang Yang60db6b52008-08-26 13:13:00 +020012571static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12572 unsigned int res)
12573{
12574 if ((res >> 26) == ALC880_HP_EVENT)
12575 alc269_quanta_fl1_speaker_automute(codec);
12576 if ((res >> 26) == ALC880_MIC_EVENT)
12577 alc269_quanta_fl1_mic_automute(codec);
12578}
12579
Tony Vroon64154832008-11-06 15:08:49 +000012580static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12581 unsigned int res)
12582{
12583 if ((res >> 26) == ALC880_HP_EVENT)
12584 alc269_lifebook_speaker_automute(codec);
12585 if ((res >> 26) == ALC880_MIC_EVENT)
12586 alc269_lifebook_mic_autoswitch(codec);
12587}
12588
Kailang Yang60db6b52008-08-26 13:13:00 +020012589static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12590{
12591 alc269_quanta_fl1_speaker_automute(codec);
12592 alc269_quanta_fl1_mic_automute(codec);
12593}
12594
Tony Vroon64154832008-11-06 15:08:49 +000012595static void alc269_lifebook_init_hook(struct hda_codec *codec)
12596{
12597 alc269_lifebook_speaker_automute(codec);
12598 alc269_lifebook_mic_autoswitch(codec);
12599}
12600
Kailang Yang60db6b52008-08-26 13:13:00 +020012601static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12603 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12604 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12606 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12609 {}
12610};
12611
12612static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12613 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12614 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12615 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12617 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12618 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12619 {}
12620};
12621
12622/* toggle speaker-output according to the hp-jack state */
12623static void alc269_speaker_automute(struct hda_codec *codec)
12624{
12625 unsigned int present;
12626 unsigned char bits;
12627
12628 present = snd_hda_codec_read(codec, 0x15, 0,
12629 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12630 bits = present ? AMP_IN_MUTE(0) : 0;
12631 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12632 AMP_IN_MUTE(0), bits);
12633 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12634 AMP_IN_MUTE(0), bits);
12635}
12636
12637static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12638{
12639 unsigned int present;
12640
12641 present = snd_hda_codec_read(codec, 0x18, 0,
12642 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12643 snd_hda_codec_write(codec, 0x23, 0,
12644 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12645}
12646
12647static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12648{
12649 unsigned int present;
12650
12651 present = snd_hda_codec_read(codec, 0x18, 0,
12652 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12653 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12654 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12655 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12656 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12657}
12658
12659/* unsolicited event for HP jack sensing */
12660static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12661 unsigned int res)
12662{
12663 if ((res >> 26) == ALC880_HP_EVENT)
12664 alc269_speaker_automute(codec);
12665
12666 if ((res >> 26) == ALC880_MIC_EVENT)
12667 alc269_eeepc_dmic_automute(codec);
12668}
12669
12670static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12671{
12672 alc269_speaker_automute(codec);
12673 alc269_eeepc_dmic_automute(codec);
12674}
12675
12676/* unsolicited event for HP jack sensing */
12677static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12678 unsigned int res)
12679{
12680 if ((res >> 26) == ALC880_HP_EVENT)
12681 alc269_speaker_automute(codec);
12682
12683 if ((res >> 26) == ALC880_MIC_EVENT)
12684 alc269_eeepc_amic_automute(codec);
12685}
12686
12687static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12688{
12689 alc269_speaker_automute(codec);
12690 alc269_eeepc_amic_automute(codec);
12691}
12692
Kailang Yangf6a92242007-12-13 16:52:54 +010012693/*
12694 * generic initialization of ADC, input mixers and output mixers
12695 */
12696static struct hda_verb alc269_init_verbs[] = {
12697 /*
12698 * Unmute ADC0 and set the default input to mic-in
12699 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012701
12702 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12703 * analog-loopback mixer widget
12704 * Note: PASD motherboards uses the Line In 2 as the input for
12705 * front panel mic (mic 2)
12706 */
12707 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12713
12714 /*
12715 * Set up output mixers (0x0c - 0x0e)
12716 */
12717 /* set vol=0 to output mixers */
12718 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12719 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12720
12721 /* set up input amps for analog loopback */
12722 /* Amp Indices: DAC = 0, mixer = 1 */
12723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12729
12730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12733 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12737
12738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12744 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12745
12746 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12747 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12748
12749 /* FIXME: use matrix-type input source selection */
12750 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12751 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12756
12757 /* set EAPD */
12758 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12759 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12760 { }
12761};
12762
12763/* add playback controls from the parsed DAC table */
12764static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12765 const struct auto_pin_cfg *cfg)
12766{
12767 hda_nid_t nid;
12768 int err;
12769
12770 spec->multiout.num_dacs = 1; /* only use one dac */
12771 spec->multiout.dac_nids = spec->private_dac_nids;
12772 spec->multiout.dac_nids[0] = 2;
12773
12774 nid = cfg->line_out_pins[0];
12775 if (nid) {
12776 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12777 "Front Playback Volume",
12778 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12779 if (err < 0)
12780 return err;
12781 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12782 "Front Playback Switch",
12783 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12784 if (err < 0)
12785 return err;
12786 }
12787
12788 nid = cfg->speaker_pins[0];
12789 if (nid) {
12790 if (!cfg->line_out_pins[0]) {
12791 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12792 "Speaker Playback Volume",
12793 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12794 HDA_OUTPUT));
12795 if (err < 0)
12796 return err;
12797 }
12798 if (nid == 0x16) {
12799 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12800 "Speaker Playback Switch",
12801 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12802 HDA_OUTPUT));
12803 if (err < 0)
12804 return err;
12805 } else {
12806 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12807 "Speaker Playback Switch",
12808 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12809 HDA_OUTPUT));
12810 if (err < 0)
12811 return err;
12812 }
12813 }
12814 nid = cfg->hp_pins[0];
12815 if (nid) {
12816 /* spec->multiout.hp_nid = 2; */
12817 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12818 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12819 "Headphone Playback Volume",
12820 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12821 HDA_OUTPUT));
12822 if (err < 0)
12823 return err;
12824 }
12825 if (nid == 0x16) {
12826 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12827 "Headphone Playback Switch",
12828 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12829 HDA_OUTPUT));
12830 if (err < 0)
12831 return err;
12832 } else {
12833 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12834 "Headphone Playback Switch",
12835 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12836 HDA_OUTPUT));
12837 if (err < 0)
12838 return err;
12839 }
12840 }
12841 return 0;
12842}
12843
Takashi Iwaiee956e02008-10-31 17:16:31 +010012844static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12845 const struct auto_pin_cfg *cfg)
12846{
12847 int err;
12848
12849 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12850 if (err < 0)
12851 return err;
12852 /* digital-mic input pin is excluded in alc880_auto_create..()
12853 * because it's under 0x18
12854 */
12855 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12856 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012857 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012858 imux->items[imux->num_items].label = "Int Mic";
12859 imux->items[imux->num_items].index = 0x05;
12860 imux->num_items++;
12861 }
12862 return 0;
12863}
Kailang Yangf6a92242007-12-13 16:52:54 +010012864
12865#ifdef CONFIG_SND_HDA_POWER_SAVE
12866#define alc269_loopbacks alc880_loopbacks
12867#endif
12868
12869/* pcm configuration: identiacal with ALC880 */
12870#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12871#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12872#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12873#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12874
Takashi Iwaif03d3112009-03-05 14:18:16 +010012875static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12876 .substreams = 1,
12877 .channels_min = 2,
12878 .channels_max = 8,
12879 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12880 /* NID is set in alc_build_pcms */
12881 .ops = {
12882 .open = alc880_playback_pcm_open,
12883 .prepare = alc880_playback_pcm_prepare,
12884 .cleanup = alc880_playback_pcm_cleanup
12885 },
12886};
12887
12888static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12889 .substreams = 1,
12890 .channels_min = 2,
12891 .channels_max = 2,
12892 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12893 /* NID is set in alc_build_pcms */
12894};
12895
Kailang Yangf6a92242007-12-13 16:52:54 +010012896/*
12897 * BIOS auto configuration
12898 */
12899static int alc269_parse_auto_config(struct hda_codec *codec)
12900{
12901 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012902 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012903 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12904
12905 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12906 alc269_ignore);
12907 if (err < 0)
12908 return err;
12909
12910 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12911 if (err < 0)
12912 return err;
12913 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12914 if (err < 0)
12915 return err;
12916
12917 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12918
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012919 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012920 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12921
Takashi Iwai603c4012008-07-30 15:01:44 +020012922 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012923 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012924
Takashi Iwaid88897e2008-10-31 15:01:37 +010012925 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012926 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012927 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012928 /* set default input source */
12929 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12930 0, AC_VERB_SET_CONNECT_SEL,
12931 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012932
12933 err = alc_auto_add_mic_boost(codec);
12934 if (err < 0)
12935 return err;
12936
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012937 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012938 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012939
Kailang Yangf6a92242007-12-13 16:52:54 +010012940 return 1;
12941}
12942
12943#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12944#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12945#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12946
12947
12948/* init callback for auto-configuration model -- overriding the default init */
12949static void alc269_auto_init(struct hda_codec *codec)
12950{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012951 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012952 alc269_auto_init_multi_out(codec);
12953 alc269_auto_init_hp_out(codec);
12954 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012955 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012956 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012957}
12958
12959/*
12960 * configuration and preset
12961 */
12962static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012963 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012964 [ALC269_QUANTA_FL1] = "quanta",
12965 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012966 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012967 [ALC269_FUJITSU] = "fujitsu",
12968 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012969};
12970
12971static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012972 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012973 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12974 ALC269_ASUS_EEEPC_P703),
12975 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12976 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012977 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12978 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012979 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012980 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012981 {}
12982};
12983
12984static struct alc_config_preset alc269_presets[] = {
12985 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012986 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012987 .init_verbs = { alc269_init_verbs },
12988 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12989 .dac_nids = alc269_dac_nids,
12990 .hp_nid = 0x03,
12991 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12992 .channel_mode = alc269_modes,
12993 .input_mux = &alc269_capture_source,
12994 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012995 [ALC269_QUANTA_FL1] = {
12996 .mixers = { alc269_quanta_fl1_mixer },
12997 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12998 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12999 .dac_nids = alc269_dac_nids,
13000 .hp_nid = 0x03,
13001 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13002 .channel_mode = alc269_modes,
13003 .input_mux = &alc269_capture_source,
13004 .unsol_event = alc269_quanta_fl1_unsol_event,
13005 .init_hook = alc269_quanta_fl1_init_hook,
13006 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013007 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013008 .mixers = { alc269_eeepc_mixer },
13009 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013010 .init_verbs = { alc269_init_verbs,
13011 alc269_eeepc_amic_init_verbs },
13012 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13013 .dac_nids = alc269_dac_nids,
13014 .hp_nid = 0x03,
13015 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13016 .channel_mode = alc269_modes,
13017 .input_mux = &alc269_eeepc_amic_capture_source,
13018 .unsol_event = alc269_eeepc_amic_unsol_event,
13019 .init_hook = alc269_eeepc_amic_inithook,
13020 },
13021 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013022 .mixers = { alc269_eeepc_mixer },
13023 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013024 .init_verbs = { alc269_init_verbs,
13025 alc269_eeepc_dmic_init_verbs },
13026 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13027 .dac_nids = alc269_dac_nids,
13028 .hp_nid = 0x03,
13029 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13030 .channel_mode = alc269_modes,
13031 .input_mux = &alc269_eeepc_dmic_capture_source,
13032 .unsol_event = alc269_eeepc_dmic_unsol_event,
13033 .init_hook = alc269_eeepc_dmic_inithook,
13034 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013035 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013036 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013037 .cap_mixer = alc269_epc_capture_mixer,
13038 .init_verbs = { alc269_init_verbs,
13039 alc269_eeepc_dmic_init_verbs },
13040 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13041 .dac_nids = alc269_dac_nids,
13042 .hp_nid = 0x03,
13043 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13044 .channel_mode = alc269_modes,
13045 .input_mux = &alc269_eeepc_dmic_capture_source,
13046 .unsol_event = alc269_eeepc_dmic_unsol_event,
13047 .init_hook = alc269_eeepc_dmic_inithook,
13048 },
Tony Vroon64154832008-11-06 15:08:49 +000013049 [ALC269_LIFEBOOK] = {
13050 .mixers = { alc269_lifebook_mixer },
13051 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13052 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13053 .dac_nids = alc269_dac_nids,
13054 .hp_nid = 0x03,
13055 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13056 .channel_mode = alc269_modes,
13057 .input_mux = &alc269_capture_source,
13058 .unsol_event = alc269_lifebook_unsol_event,
13059 .init_hook = alc269_lifebook_init_hook,
13060 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013061};
13062
13063static int patch_alc269(struct hda_codec *codec)
13064{
13065 struct alc_spec *spec;
13066 int board_config;
13067 int err;
13068
13069 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13070 if (spec == NULL)
13071 return -ENOMEM;
13072
13073 codec->spec = spec;
13074
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013075 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13076
Kailang Yangf6a92242007-12-13 16:52:54 +010013077 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13078 alc269_models,
13079 alc269_cfg_tbl);
13080
13081 if (board_config < 0) {
13082 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13083 "trying auto-probe from BIOS...\n");
13084 board_config = ALC269_AUTO;
13085 }
13086
13087 if (board_config == ALC269_AUTO) {
13088 /* automatic parse from the BIOS config */
13089 err = alc269_parse_auto_config(codec);
13090 if (err < 0) {
13091 alc_free(codec);
13092 return err;
13093 } else if (!err) {
13094 printk(KERN_INFO
13095 "hda_codec: Cannot set up configuration "
13096 "from BIOS. Using base mode...\n");
13097 board_config = ALC269_BASIC;
13098 }
13099 }
13100
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013101 err = snd_hda_attach_beep_device(codec, 0x1);
13102 if (err < 0) {
13103 alc_free(codec);
13104 return err;
13105 }
13106
Kailang Yangf6a92242007-12-13 16:52:54 +010013107 if (board_config != ALC269_AUTO)
13108 setup_preset(spec, &alc269_presets[board_config]);
13109
13110 spec->stream_name_analog = "ALC269 Analog";
Takashi Iwaif03d3112009-03-05 14:18:16 +010013111 if (codec->subsystem_id == 0x17aa3bf8) {
13112 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13113 * fix the sample rate of analog I/O to 44.1kHz
13114 */
13115 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13116 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13117 } else {
13118 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13119 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13120 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013121 spec->stream_name_digital = "ALC269 Digital";
13122 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13123 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13124
13125 spec->adc_nids = alc269_adc_nids;
13126 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013127 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013128 if (!spec->cap_mixer)
13129 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013130 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013131
13132 codec->patch_ops = alc_patch_ops;
13133 if (board_config == ALC269_AUTO)
13134 spec->init_hook = alc269_auto_init;
13135#ifdef CONFIG_SND_HDA_POWER_SAVE
13136 if (!spec->loopback.amplist)
13137 spec->loopback.amplist = alc269_loopbacks;
13138#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013139 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013140
13141 return 0;
13142}
13143
13144/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013145 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13146 */
13147
13148/*
13149 * set the path ways for 2 channel output
13150 * need to set the codec line out and mic 1 pin widgets to inputs
13151 */
13152static struct hda_verb alc861_threestack_ch2_init[] = {
13153 /* set pin widget 1Ah (line in) for input */
13154 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013155 /* set pin widget 18h (mic1/2) for input, for mic also enable
13156 * the vref
13157 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013158 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13159
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013160 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13161#if 0
13162 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13163 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13164#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013165 { } /* end */
13166};
13167/*
13168 * 6ch mode
13169 * need to set the codec line out and mic 1 pin widgets to outputs
13170 */
13171static struct hda_verb alc861_threestack_ch6_init[] = {
13172 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13173 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13174 /* set pin widget 18h (mic1) for output (CLFE)*/
13175 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13176
13177 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013178 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013179
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013180 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13181#if 0
13182 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13183 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13184#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013185 { } /* end */
13186};
13187
13188static struct hda_channel_mode alc861_threestack_modes[2] = {
13189 { 2, alc861_threestack_ch2_init },
13190 { 6, alc861_threestack_ch6_init },
13191};
Takashi Iwai22309c32006-08-09 16:57:28 +020013192/* Set mic1 as input and unmute the mixer */
13193static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13194 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13195 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13196 { } /* end */
13197};
13198/* Set mic1 as output and mute mixer */
13199static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13200 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13202 { } /* end */
13203};
13204
13205static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13206 { 2, alc861_uniwill_m31_ch2_init },
13207 { 4, alc861_uniwill_m31_ch4_init },
13208};
Kailang Yangdf694da2005-12-05 19:42:22 +010013209
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013210/* Set mic1 and line-in as input and unmute the mixer */
13211static struct hda_verb alc861_asus_ch2_init[] = {
13212 /* set pin widget 1Ah (line in) for input */
13213 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013214 /* set pin widget 18h (mic1/2) for input, for mic also enable
13215 * the vref
13216 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013217 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13218
13219 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13220#if 0
13221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13222 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13223#endif
13224 { } /* end */
13225};
13226/* Set mic1 nad line-in as output and mute mixer */
13227static struct hda_verb alc861_asus_ch6_init[] = {
13228 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13229 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13230 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13231 /* set pin widget 18h (mic1) for output (CLFE)*/
13232 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13233 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13234 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13235 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13236
13237 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13238#if 0
13239 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13240 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13241#endif
13242 { } /* end */
13243};
13244
13245static struct hda_channel_mode alc861_asus_modes[2] = {
13246 { 2, alc861_asus_ch2_init },
13247 { 6, alc861_asus_ch6_init },
13248};
13249
Kailang Yangdf694da2005-12-05 19:42:22 +010013250/* patch-ALC861 */
13251
13252static struct snd_kcontrol_new alc861_base_mixer[] = {
13253 /* output mixer control */
13254 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13255 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13256 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13257 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13258 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13259
13260 /*Input mixer control */
13261 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13262 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13263 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13264 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13265 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13266 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13268 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13269 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013271
Kailang Yangdf694da2005-12-05 19:42:22 +010013272 { } /* end */
13273};
13274
13275static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13276 /* output mixer control */
13277 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13278 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13279 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13280 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13281 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13282
13283 /* Input mixer control */
13284 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13285 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13286 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13287 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13288 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13289 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13291 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13292 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013294
Kailang Yangdf694da2005-12-05 19:42:22 +010013295 {
13296 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13297 .name = "Channel Mode",
13298 .info = alc_ch_mode_info,
13299 .get = alc_ch_mode_get,
13300 .put = alc_ch_mode_put,
13301 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13302 },
13303 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013304};
13305
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013306static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013307 /* output mixer control */
13308 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13310 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013311
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013312 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013313};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013314
Takashi Iwai22309c32006-08-09 16:57:28 +020013315static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13316 /* output mixer control */
13317 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13318 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13319 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13320 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13321 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13322
13323 /* Input mixer control */
13324 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13326 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13327 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13328 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13329 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13331 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13332 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013334
Takashi Iwai22309c32006-08-09 16:57:28 +020013335 {
13336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13337 .name = "Channel Mode",
13338 .info = alc_ch_mode_info,
13339 .get = alc_ch_mode_get,
13340 .put = alc_ch_mode_put,
13341 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13342 },
13343 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013344};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013345
13346static struct snd_kcontrol_new alc861_asus_mixer[] = {
13347 /* output mixer control */
13348 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13349 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13350 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13351 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13352 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13353
13354 /* Input mixer control */
13355 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13356 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13357 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13358 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13359 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13360 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13362 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13365
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013366 {
13367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13368 .name = "Channel Mode",
13369 .info = alc_ch_mode_info,
13370 .get = alc_ch_mode_get,
13371 .put = alc_ch_mode_put,
13372 .private_value = ARRAY_SIZE(alc861_asus_modes),
13373 },
13374 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013375};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013376
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013377/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013378static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013379 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13380 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013381 { }
13382};
13383
Kailang Yangdf694da2005-12-05 19:42:22 +010013384/*
13385 * generic initialization of ADC, input mixers and output mixers
13386 */
13387static struct hda_verb alc861_base_init_verbs[] = {
13388 /*
13389 * Unmute ADC0 and set the default input to mic-in
13390 */
13391 /* port-A for surround (rear panel) */
13392 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13393 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13394 /* port-B for mic-in (rear panel) with vref */
13395 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13396 /* port-C for line-in (rear panel) */
13397 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13398 /* port-D for Front */
13399 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13400 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13401 /* port-E for HP out (front panel) */
13402 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13403 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013404 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013405 /* port-F for mic-in (front panel) with vref */
13406 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13407 /* port-G for CLFE (rear panel) */
13408 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13409 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13410 /* port-H for side (rear panel) */
13411 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13412 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13413 /* CD-in */
13414 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13415 /* route front mic to ADC1*/
13416 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013418
Kailang Yangdf694da2005-12-05 19:42:22 +010013419 /* Unmute DAC0~3 & spdif out*/
13420 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13422 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13423 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013425
Kailang Yangdf694da2005-12-05 19:42:22 +010013426 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13427 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13428 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13429 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13430 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013431
Kailang Yangdf694da2005-12-05 19:42:22 +010013432 /* Unmute Stereo Mixer 15 */
13433 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013437
13438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13439 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13440 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13441 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13442 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013446 /* hp used DAC 3 (Front) */
13447 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013448 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13449
13450 { }
13451};
13452
13453static struct hda_verb alc861_threestack_init_verbs[] = {
13454 /*
13455 * Unmute ADC0 and set the default input to mic-in
13456 */
13457 /* port-A for surround (rear panel) */
13458 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13459 /* port-B for mic-in (rear panel) with vref */
13460 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13461 /* port-C for line-in (rear panel) */
13462 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13463 /* port-D for Front */
13464 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13465 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13466 /* port-E for HP out (front panel) */
13467 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13468 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013469 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013470 /* port-F for mic-in (front panel) with vref */
13471 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13472 /* port-G for CLFE (rear panel) */
13473 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13474 /* port-H for side (rear panel) */
13475 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13476 /* CD-in */
13477 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13478 /* route front mic to ADC1*/
13479 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13480 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13481 /* Unmute DAC0~3 & spdif out*/
13482 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13483 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13484 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13485 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013487
Kailang Yangdf694da2005-12-05 19:42:22 +010013488 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13489 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13490 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13491 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13492 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013493
Kailang Yangdf694da2005-12-05 19:42:22 +010013494 /* Unmute Stereo Mixer 15 */
13495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013499
13500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13504 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13506 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13507 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013508 /* hp used DAC 3 (Front) */
13509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13511 { }
13512};
Takashi Iwai22309c32006-08-09 16:57:28 +020013513
13514static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13515 /*
13516 * Unmute ADC0 and set the default input to mic-in
13517 */
13518 /* port-A for surround (rear panel) */
13519 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13520 /* port-B for mic-in (rear panel) with vref */
13521 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13522 /* port-C for line-in (rear panel) */
13523 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13524 /* port-D for Front */
13525 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13526 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13527 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013528 /* this has to be set to VREF80 */
13529 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013530 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013531 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013532 /* port-F for mic-in (front panel) with vref */
13533 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13534 /* port-G for CLFE (rear panel) */
13535 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13536 /* port-H for side (rear panel) */
13537 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13538 /* CD-in */
13539 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13540 /* route front mic to ADC1*/
13541 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13542 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13543 /* Unmute DAC0~3 & spdif out*/
13544 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13545 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13547 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013549
Takashi Iwai22309c32006-08-09 16:57:28 +020013550 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13551 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13552 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13553 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13554 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013555
Takashi Iwai22309c32006-08-09 16:57:28 +020013556 /* Unmute Stereo Mixer 15 */
13557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013561
13562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13563 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13564 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13565 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13569 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013570 /* hp used DAC 3 (Front) */
13571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013572 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13573 { }
13574};
13575
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013576static struct hda_verb alc861_asus_init_verbs[] = {
13577 /*
13578 * Unmute ADC0 and set the default input to mic-in
13579 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013580 /* port-A for surround (rear panel)
13581 * according to codec#0 this is the HP jack
13582 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013583 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13584 /* route front PCM to HP */
13585 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13586 /* port-B for mic-in (rear panel) with vref */
13587 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13588 /* port-C for line-in (rear panel) */
13589 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13590 /* port-D for Front */
13591 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13592 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13593 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013594 /* this has to be set to VREF80 */
13595 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013596 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013597 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013598 /* port-F for mic-in (front panel) with vref */
13599 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13600 /* port-G for CLFE (rear panel) */
13601 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13602 /* port-H for side (rear panel) */
13603 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13604 /* CD-in */
13605 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13606 /* route front mic to ADC1*/
13607 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13609 /* Unmute DAC0~3 & spdif out*/
13610 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13611 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13612 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13613 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13615 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13616 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13617 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13618 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13619 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013620
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013621 /* Unmute Stereo Mixer 15 */
13622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013626
13627 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13629 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13630 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13632 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013635 /* hp used DAC 3 (Front) */
13636 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13638 { }
13639};
13640
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013641/* additional init verbs for ASUS laptops */
13642static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13643 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13644 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13645 { }
13646};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013647
Kailang Yangdf694da2005-12-05 19:42:22 +010013648/*
13649 * generic initialization of ADC, input mixers and output mixers
13650 */
13651static struct hda_verb alc861_auto_init_verbs[] = {
13652 /*
13653 * Unmute ADC0 and set the default input to mic-in
13654 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013655 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013657
Kailang Yangdf694da2005-12-05 19:42:22 +010013658 /* Unmute DAC0~3 & spdif out*/
13659 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13661 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13662 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013664
Kailang Yangdf694da2005-12-05 19:42:22 +010013665 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13666 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13667 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13668 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13669 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013670
Kailang Yangdf694da2005-12-05 19:42:22 +010013671 /* Unmute Stereo Mixer 15 */
13672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13676
13677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13685
13686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13691 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013692 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013694
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013695 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013696
13697 { }
13698};
13699
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013700static struct hda_verb alc861_toshiba_init_verbs[] = {
13701 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013702
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013703 { }
13704};
13705
13706/* toggle speaker-output according to the hp-jack state */
13707static void alc861_toshiba_automute(struct hda_codec *codec)
13708{
13709 unsigned int present;
13710
13711 present = snd_hda_codec_read(codec, 0x0f, 0,
13712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013713 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13714 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13715 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13716 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013717}
13718
13719static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13720 unsigned int res)
13721{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013722 if ((res >> 26) == ALC880_HP_EVENT)
13723 alc861_toshiba_automute(codec);
13724}
13725
Kailang Yangdf694da2005-12-05 19:42:22 +010013726/* pcm configuration: identiacal with ALC880 */
13727#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13728#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13729#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13730#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13731
13732
13733#define ALC861_DIGOUT_NID 0x07
13734
13735static struct hda_channel_mode alc861_8ch_modes[1] = {
13736 { 8, NULL }
13737};
13738
13739static hda_nid_t alc861_dac_nids[4] = {
13740 /* front, surround, clfe, side */
13741 0x03, 0x06, 0x05, 0x04
13742};
13743
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013744static hda_nid_t alc660_dac_nids[3] = {
13745 /* front, clfe, surround */
13746 0x03, 0x05, 0x06
13747};
13748
Kailang Yangdf694da2005-12-05 19:42:22 +010013749static hda_nid_t alc861_adc_nids[1] = {
13750 /* ADC0-2 */
13751 0x08,
13752};
13753
13754static struct hda_input_mux alc861_capture_source = {
13755 .num_items = 5,
13756 .items = {
13757 { "Mic", 0x0 },
13758 { "Front Mic", 0x3 },
13759 { "Line", 0x1 },
13760 { "CD", 0x4 },
13761 { "Mixer", 0x5 },
13762 },
13763};
13764
13765/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013766static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13767 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013768{
13769 int i;
13770 hda_nid_t nid;
13771
13772 spec->multiout.dac_nids = spec->private_dac_nids;
13773 for (i = 0; i < cfg->line_outs; i++) {
13774 nid = cfg->line_out_pins[i];
13775 if (nid) {
13776 if (i >= ARRAY_SIZE(alc861_dac_nids))
13777 continue;
13778 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13779 }
13780 }
13781 spec->multiout.num_dacs = cfg->line_outs;
13782 return 0;
13783}
13784
13785/* add playback controls from the parsed DAC table */
13786static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13787 const struct auto_pin_cfg *cfg)
13788{
13789 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013790 static const char *chname[4] = {
13791 "Front", "Surround", NULL /*CLFE*/, "Side"
13792 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013793 hda_nid_t nid;
13794 int i, idx, err;
13795
13796 for (i = 0; i < cfg->line_outs; i++) {
13797 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013798 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013799 continue;
13800 if (nid == 0x05) {
13801 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013802 err = add_control(spec, ALC_CTL_BIND_MUTE,
13803 "Center Playback Switch",
13804 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13805 HDA_OUTPUT));
13806 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013808 err = add_control(spec, ALC_CTL_BIND_MUTE,
13809 "LFE Playback Switch",
13810 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13811 HDA_OUTPUT));
13812 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013813 return err;
13814 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013815 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13816 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 if (nid == alc861_dac_nids[idx])
13818 break;
13819 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013820 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13821 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13822 HDA_OUTPUT));
13823 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013824 return err;
13825 }
13826 }
13827 return 0;
13828}
13829
13830static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13831{
13832 int err;
13833 hda_nid_t nid;
13834
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013835 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013836 return 0;
13837
13838 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13839 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013840 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13841 "Headphone Playback Switch",
13842 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 return err;
13845 spec->multiout.hp_nid = nid;
13846 }
13847 return 0;
13848}
13849
13850/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013851static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13852 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013853{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013854 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013855 int i, err, idx, idx1;
13856
13857 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013858 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013859 case 0x0c:
13860 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013861 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013862 break;
13863 case 0x0f:
13864 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013865 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013866 break;
13867 case 0x0d:
13868 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013869 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013870 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013871 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013873 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013874 break;
13875 case 0x11:
13876 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 break;
13879 default:
13880 continue;
13881 }
13882
Takashi Iwai4a471b72005-12-07 13:56:29 +010013883 err = new_analog_input(spec, cfg->input_pins[i],
13884 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 if (err < 0)
13886 return err;
13887
Takashi Iwai4a471b72005-12-07 13:56:29 +010013888 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013889 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013890 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013891 }
13892 return 0;
13893}
13894
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013895static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13896 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 int pin_type, int dac_idx)
13898{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013899 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13900 pin_type);
13901 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13902 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013903}
13904
13905static void alc861_auto_init_multi_out(struct hda_codec *codec)
13906{
13907 struct alc_spec *spec = codec->spec;
13908 int i;
13909
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013910 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013911 for (i = 0; i < spec->autocfg.line_outs; i++) {
13912 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013913 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013914 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013915 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013916 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013917 }
13918}
13919
13920static void alc861_auto_init_hp_out(struct hda_codec *codec)
13921{
13922 struct alc_spec *spec = codec->spec;
13923 hda_nid_t pin;
13924
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013925 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013926 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13928 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013929 pin = spec->autocfg.speaker_pins[0];
13930 if (pin)
13931 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013932}
13933
13934static void alc861_auto_init_analog_input(struct hda_codec *codec)
13935{
13936 struct alc_spec *spec = codec->spec;
13937 int i;
13938
13939 for (i = 0; i < AUTO_PIN_LAST; i++) {
13940 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013941 if (nid >= 0x0c && nid <= 0x11)
13942 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013943 }
13944}
13945
13946/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013947/* return 1 if successful, 0 if the proper config is not found,
13948 * or a negative error code
13949 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013950static int alc861_parse_auto_config(struct hda_codec *codec)
13951{
13952 struct alc_spec *spec = codec->spec;
13953 int err;
13954 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13955
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013956 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13957 alc861_ignore);
13958 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013959 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013960 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013961 return 0; /* can't find valid BIOS pin config */
13962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013963 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13964 if (err < 0)
13965 return err;
13966 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13967 if (err < 0)
13968 return err;
13969 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13970 if (err < 0)
13971 return err;
13972 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013974 return err;
13975
13976 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13977
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013978 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013979 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13980
Takashi Iwai603c4012008-07-30 15:01:44 +020013981 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013982 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013983
Takashi Iwaid88897e2008-10-31 15:01:37 +010013984 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013985
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013986 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013987 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013988
13989 spec->adc_nids = alc861_adc_nids;
13990 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013991 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013992
13993 return 1;
13994}
13995
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013996/* additional initialization for auto-configuration model */
13997static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013998{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013999 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014000 alc861_auto_init_multi_out(codec);
14001 alc861_auto_init_hp_out(codec);
14002 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014003 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014004 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014005}
14006
Takashi Iwaicb53c622007-08-10 17:21:45 +020014007#ifdef CONFIG_SND_HDA_POWER_SAVE
14008static struct hda_amp_list alc861_loopbacks[] = {
14009 { 0x15, HDA_INPUT, 0 },
14010 { 0x15, HDA_INPUT, 1 },
14011 { 0x15, HDA_INPUT, 2 },
14012 { 0x15, HDA_INPUT, 3 },
14013 { } /* end */
14014};
14015#endif
14016
Kailang Yangdf694da2005-12-05 19:42:22 +010014017
14018/*
14019 * configuration and preset
14020 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014021static const char *alc861_models[ALC861_MODEL_LAST] = {
14022 [ALC861_3ST] = "3stack",
14023 [ALC660_3ST] = "3stack-660",
14024 [ALC861_3ST_DIG] = "3stack-dig",
14025 [ALC861_6ST_DIG] = "6stack-dig",
14026 [ALC861_UNIWILL_M31] = "uniwill-m31",
14027 [ALC861_TOSHIBA] = "toshiba",
14028 [ALC861_ASUS] = "asus",
14029 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14030 [ALC861_AUTO] = "auto",
14031};
14032
14033static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014034 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014035 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14036 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14037 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014038 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014039 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014040 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014041 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14042 * Any other models that need this preset?
14043 */
14044 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014045 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14046 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014047 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14048 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14049 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14050 /* FIXME: the below seems conflict */
14051 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14052 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14053 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014054 {}
14055};
14056
14057static struct alc_config_preset alc861_presets[] = {
14058 [ALC861_3ST] = {
14059 .mixers = { alc861_3ST_mixer },
14060 .init_verbs = { alc861_threestack_init_verbs },
14061 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14062 .dac_nids = alc861_dac_nids,
14063 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14064 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014065 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014066 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14067 .adc_nids = alc861_adc_nids,
14068 .input_mux = &alc861_capture_source,
14069 },
14070 [ALC861_3ST_DIG] = {
14071 .mixers = { alc861_base_mixer },
14072 .init_verbs = { alc861_threestack_init_verbs },
14073 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14074 .dac_nids = alc861_dac_nids,
14075 .dig_out_nid = ALC861_DIGOUT_NID,
14076 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14077 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014078 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014079 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14080 .adc_nids = alc861_adc_nids,
14081 .input_mux = &alc861_capture_source,
14082 },
14083 [ALC861_6ST_DIG] = {
14084 .mixers = { alc861_base_mixer },
14085 .init_verbs = { alc861_base_init_verbs },
14086 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14087 .dac_nids = alc861_dac_nids,
14088 .dig_out_nid = ALC861_DIGOUT_NID,
14089 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14090 .channel_mode = alc861_8ch_modes,
14091 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14092 .adc_nids = alc861_adc_nids,
14093 .input_mux = &alc861_capture_source,
14094 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014095 [ALC660_3ST] = {
14096 .mixers = { alc861_3ST_mixer },
14097 .init_verbs = { alc861_threestack_init_verbs },
14098 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14099 .dac_nids = alc660_dac_nids,
14100 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14101 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014102 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014103 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14104 .adc_nids = alc861_adc_nids,
14105 .input_mux = &alc861_capture_source,
14106 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014107 [ALC861_UNIWILL_M31] = {
14108 .mixers = { alc861_uniwill_m31_mixer },
14109 .init_verbs = { alc861_uniwill_m31_init_verbs },
14110 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14111 .dac_nids = alc861_dac_nids,
14112 .dig_out_nid = ALC861_DIGOUT_NID,
14113 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14114 .channel_mode = alc861_uniwill_m31_modes,
14115 .need_dac_fix = 1,
14116 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14117 .adc_nids = alc861_adc_nids,
14118 .input_mux = &alc861_capture_source,
14119 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014120 [ALC861_TOSHIBA] = {
14121 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014122 .init_verbs = { alc861_base_init_verbs,
14123 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014124 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14125 .dac_nids = alc861_dac_nids,
14126 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14127 .channel_mode = alc883_3ST_2ch_modes,
14128 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14129 .adc_nids = alc861_adc_nids,
14130 .input_mux = &alc861_capture_source,
14131 .unsol_event = alc861_toshiba_unsol_event,
14132 .init_hook = alc861_toshiba_automute,
14133 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014134 [ALC861_ASUS] = {
14135 .mixers = { alc861_asus_mixer },
14136 .init_verbs = { alc861_asus_init_verbs },
14137 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14138 .dac_nids = alc861_dac_nids,
14139 .dig_out_nid = ALC861_DIGOUT_NID,
14140 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14141 .channel_mode = alc861_asus_modes,
14142 .need_dac_fix = 1,
14143 .hp_nid = 0x06,
14144 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14145 .adc_nids = alc861_adc_nids,
14146 .input_mux = &alc861_capture_source,
14147 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014148 [ALC861_ASUS_LAPTOP] = {
14149 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14150 .init_verbs = { alc861_asus_init_verbs,
14151 alc861_asus_laptop_init_verbs },
14152 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14153 .dac_nids = alc861_dac_nids,
14154 .dig_out_nid = ALC861_DIGOUT_NID,
14155 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14156 .channel_mode = alc883_3ST_2ch_modes,
14157 .need_dac_fix = 1,
14158 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14159 .adc_nids = alc861_adc_nids,
14160 .input_mux = &alc861_capture_source,
14161 },
14162};
Kailang Yangdf694da2005-12-05 19:42:22 +010014163
14164
14165static int patch_alc861(struct hda_codec *codec)
14166{
14167 struct alc_spec *spec;
14168 int board_config;
14169 int err;
14170
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014171 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014172 if (spec == NULL)
14173 return -ENOMEM;
14174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014176
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014177 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14178 alc861_models,
14179 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014180
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014181 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014182 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14183 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 board_config = ALC861_AUTO;
14185 }
14186
14187 if (board_config == ALC861_AUTO) {
14188 /* automatic parse from the BIOS config */
14189 err = alc861_parse_auto_config(codec);
14190 if (err < 0) {
14191 alc_free(codec);
14192 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014193 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014194 printk(KERN_INFO
14195 "hda_codec: Cannot set up configuration "
14196 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014197 board_config = ALC861_3ST_DIG;
14198 }
14199 }
14200
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014201 err = snd_hda_attach_beep_device(codec, 0x23);
14202 if (err < 0) {
14203 alc_free(codec);
14204 return err;
14205 }
14206
Kailang Yangdf694da2005-12-05 19:42:22 +010014207 if (board_config != ALC861_AUTO)
14208 setup_preset(spec, &alc861_presets[board_config]);
14209
14210 spec->stream_name_analog = "ALC861 Analog";
14211 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14212 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14213
14214 spec->stream_name_digital = "ALC861 Digital";
14215 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14216 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14217
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014218 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14219
Takashi Iwai2134ea42008-01-10 16:53:55 +010014220 spec->vmaster_nid = 0x03;
14221
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 codec->patch_ops = alc_patch_ops;
14223 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014224 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014225#ifdef CONFIG_SND_HDA_POWER_SAVE
14226 if (!spec->loopback.amplist)
14227 spec->loopback.amplist = alc861_loopbacks;
14228#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014229 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014230
Kailang Yangdf694da2005-12-05 19:42:22 +010014231 return 0;
14232}
14233
14234/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014235 * ALC861-VD support
14236 *
14237 * Based on ALC882
14238 *
14239 * In addition, an independent DAC
14240 */
14241#define ALC861VD_DIGOUT_NID 0x06
14242
14243static hda_nid_t alc861vd_dac_nids[4] = {
14244 /* front, surr, clfe, side surr */
14245 0x02, 0x03, 0x04, 0x05
14246};
14247
14248/* dac_nids for ALC660vd are in a different order - according to
14249 * Realtek's driver.
14250 * This should probably tesult in a different mixer for 6stack models
14251 * of ALC660vd codecs, but for now there is only 3stack mixer
14252 * - and it is the same as in 861vd.
14253 * adc_nids in ALC660vd are (is) the same as in 861vd
14254 */
14255static hda_nid_t alc660vd_dac_nids[3] = {
14256 /* front, rear, clfe, rear_surr */
14257 0x02, 0x04, 0x03
14258};
14259
14260static hda_nid_t alc861vd_adc_nids[1] = {
14261 /* ADC0 */
14262 0x09,
14263};
14264
Takashi Iwaie1406342008-02-11 18:32:32 +010014265static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14266
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014267/* input MUX */
14268/* FIXME: should be a matrix-type input source selection */
14269static struct hda_input_mux alc861vd_capture_source = {
14270 .num_items = 4,
14271 .items = {
14272 { "Mic", 0x0 },
14273 { "Front Mic", 0x1 },
14274 { "Line", 0x2 },
14275 { "CD", 0x4 },
14276 },
14277};
14278
Kailang Yang272a5272007-05-14 11:00:38 +020014279static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014280 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014281 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014282 { "Ext Mic", 0x0 },
14283 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014284 },
14285};
14286
Kailang Yangd1a991a2007-08-15 16:21:59 +020014287static struct hda_input_mux alc861vd_hp_capture_source = {
14288 .num_items = 2,
14289 .items = {
14290 { "Front Mic", 0x0 },
14291 { "ATAPI Mic", 0x1 },
14292 },
14293};
14294
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014295/*
14296 * 2ch mode
14297 */
14298static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14299 { 2, NULL }
14300};
14301
14302/*
14303 * 6ch mode
14304 */
14305static struct hda_verb alc861vd_6stack_ch6_init[] = {
14306 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14307 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14308 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14309 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14310 { } /* end */
14311};
14312
14313/*
14314 * 8ch mode
14315 */
14316static struct hda_verb alc861vd_6stack_ch8_init[] = {
14317 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14318 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14319 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14320 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14321 { } /* end */
14322};
14323
14324static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14325 { 6, alc861vd_6stack_ch6_init },
14326 { 8, alc861vd_6stack_ch8_init },
14327};
14328
14329static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14330 {
14331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14332 .name = "Channel Mode",
14333 .info = alc_ch_mode_info,
14334 .get = alc_ch_mode_get,
14335 .put = alc_ch_mode_put,
14336 },
14337 { } /* end */
14338};
14339
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014340/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14341 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14342 */
14343static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14344 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14345 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14346
14347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14348 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14349
14350 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14351 HDA_OUTPUT),
14352 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14353 HDA_OUTPUT),
14354 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14355 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14356
14357 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14358 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14359
14360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14361
14362 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14365
14366 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14367 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14368 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14369
14370 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14371 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14372
14373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14375
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014376 { } /* end */
14377};
14378
14379static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14380 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14381 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14382
14383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14384
14385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14388
14389 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14392
14393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14395
14396 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14397 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14398
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014399 { } /* end */
14400};
14401
Kailang Yangbdd148a2007-05-08 15:19:08 +020014402static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14403 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14404 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14405 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14406
14407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14408
14409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14411 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14412
14413 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14416
14417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14419
14420 { } /* end */
14421};
14422
Tobin Davisb419f342008-03-07 11:57:51 +010014423/* Pin assignment: Speaker=0x14, HP = 0x15,
14424 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014425 */
14426static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014427 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14428 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014429 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14430 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014431 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14432 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14433 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14434 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14435 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14436 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014437 { } /* end */
14438};
14439
Kailang Yangd1a991a2007-08-15 16:21:59 +020014440/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14441 * Front Mic=0x18, ATAPI Mic = 0x19,
14442 */
14443static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14444 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14445 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14446 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14447 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14448 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14450 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14451 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014452
Kailang Yangd1a991a2007-08-15 16:21:59 +020014453 { } /* end */
14454};
14455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014456/*
14457 * generic initialization of ADC, input mixers and output mixers
14458 */
14459static struct hda_verb alc861vd_volume_init_verbs[] = {
14460 /*
14461 * Unmute ADC0 and set the default input to mic-in
14462 */
14463 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14465
14466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14467 * the analog-loopback mixer widget
14468 */
14469 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014475
14476 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014481
14482 /*
14483 * Set up output mixers (0x02 - 0x05)
14484 */
14485 /* set vol=0 to output mixers */
14486 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14488 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14489 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14490
14491 /* set up input amps for analog loopback */
14492 /* Amp Indices: DAC = 0, mixer = 1 */
14493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14501
14502 { }
14503};
14504
14505/*
14506 * 3-stack pin configuration:
14507 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14508 */
14509static struct hda_verb alc861vd_3stack_init_verbs[] = {
14510 /*
14511 * Set pin mode and muting
14512 */
14513 /* set front pin widgets 0x14 for output */
14514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14516 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14517
14518 /* Mic (rear) pin: input vref at 80% */
14519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14521 /* Front Mic pin: input vref at 80% */
14522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14523 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14524 /* Line In pin: input */
14525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14526 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14527 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14529 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14530 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14531 /* CD pin widget for input */
14532 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14533
14534 { }
14535};
14536
14537/*
14538 * 6-stack pin configuration:
14539 */
14540static struct hda_verb alc861vd_6stack_init_verbs[] = {
14541 /*
14542 * Set pin mode and muting
14543 */
14544 /* set front pin widgets 0x14 for output */
14545 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14547 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14548
14549 /* Rear Pin: output 1 (0x0d) */
14550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14551 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14553 /* CLFE Pin: output 2 (0x0e) */
14554 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14555 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14556 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14557 /* Side Pin: output 3 (0x0f) */
14558 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14559 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14560 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14561
14562 /* Mic (rear) pin: input vref at 80% */
14563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14564 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14565 /* Front Mic pin: input vref at 80% */
14566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14568 /* Line In pin: input */
14569 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14570 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14571 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14572 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14573 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14574 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14575 /* CD pin widget for input */
14576 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14577
14578 { }
14579};
14580
Kailang Yangbdd148a2007-05-08 15:19:08 +020014581static struct hda_verb alc861vd_eapd_verbs[] = {
14582 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14583 { }
14584};
14585
Kailang Yangf9423e72008-05-27 12:32:25 +020014586static struct hda_verb alc660vd_eapd_verbs[] = {
14587 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14588 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14589 { }
14590};
14591
Kailang Yangbdd148a2007-05-08 15:19:08 +020014592static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14596 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014597 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014598 {}
14599};
14600
14601/* toggle speaker-output according to the hp-jack state */
14602static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14603{
14604 unsigned int present;
14605 unsigned char bits;
14606
14607 present = snd_hda_codec_read(codec, 0x1b, 0,
14608 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014609 bits = present ? HDA_AMP_MUTE : 0;
14610 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14611 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014612}
14613
14614static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14615{
14616 unsigned int present;
14617 unsigned char bits;
14618
14619 present = snd_hda_codec_read(codec, 0x18, 0,
14620 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014621 bits = present ? HDA_AMP_MUTE : 0;
14622 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14623 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014624}
14625
14626static void alc861vd_lenovo_automute(struct hda_codec *codec)
14627{
14628 alc861vd_lenovo_hp_automute(codec);
14629 alc861vd_lenovo_mic_automute(codec);
14630}
14631
14632static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14633 unsigned int res)
14634{
14635 switch (res >> 26) {
14636 case ALC880_HP_EVENT:
14637 alc861vd_lenovo_hp_automute(codec);
14638 break;
14639 case ALC880_MIC_EVENT:
14640 alc861vd_lenovo_mic_automute(codec);
14641 break;
14642 }
14643}
14644
Kailang Yang272a5272007-05-14 11:00:38 +020014645static struct hda_verb alc861vd_dallas_verbs[] = {
14646 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14647 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14648 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14649 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14650
14651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014659
Kailang Yang272a5272007-05-14 11:00:38 +020014660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14668
14669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14676 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14677
14678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14682
14683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014685 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14686
14687 { } /* end */
14688};
14689
14690/* toggle speaker-output according to the hp-jack state */
14691static void alc861vd_dallas_automute(struct hda_codec *codec)
14692{
14693 unsigned int present;
14694
14695 present = snd_hda_codec_read(codec, 0x15, 0,
14696 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014697 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14698 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014699}
14700
14701static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14702{
14703 if ((res >> 26) == ALC880_HP_EVENT)
14704 alc861vd_dallas_automute(codec);
14705}
14706
Takashi Iwaicb53c622007-08-10 17:21:45 +020014707#ifdef CONFIG_SND_HDA_POWER_SAVE
14708#define alc861vd_loopbacks alc880_loopbacks
14709#endif
14710
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014711/* pcm configuration: identiacal with ALC880 */
14712#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14713#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14714#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14715#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14716
14717/*
14718 * configuration and preset
14719 */
14720static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14721 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014722 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014723 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014724 [ALC861VD_3ST] = "3stack",
14725 [ALC861VD_3ST_DIG] = "3stack-digout",
14726 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014727 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014728 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014729 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014730 [ALC861VD_AUTO] = "auto",
14731};
14732
14733static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014734 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14735 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014736 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014737 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014738 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014739 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014740 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014741 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014742 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014743 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014744 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014745 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014746 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014747 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014748 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014749 {}
14750};
14751
14752static struct alc_config_preset alc861vd_presets[] = {
14753 [ALC660VD_3ST] = {
14754 .mixers = { alc861vd_3st_mixer },
14755 .init_verbs = { alc861vd_volume_init_verbs,
14756 alc861vd_3stack_init_verbs },
14757 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14758 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014759 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14760 .channel_mode = alc861vd_3stack_2ch_modes,
14761 .input_mux = &alc861vd_capture_source,
14762 },
Mike Crash6963f842007-06-25 12:12:51 +020014763 [ALC660VD_3ST_DIG] = {
14764 .mixers = { alc861vd_3st_mixer },
14765 .init_verbs = { alc861vd_volume_init_verbs,
14766 alc861vd_3stack_init_verbs },
14767 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14768 .dac_nids = alc660vd_dac_nids,
14769 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014770 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14771 .channel_mode = alc861vd_3stack_2ch_modes,
14772 .input_mux = &alc861vd_capture_source,
14773 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014774 [ALC861VD_3ST] = {
14775 .mixers = { alc861vd_3st_mixer },
14776 .init_verbs = { alc861vd_volume_init_verbs,
14777 alc861vd_3stack_init_verbs },
14778 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14779 .dac_nids = alc861vd_dac_nids,
14780 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14781 .channel_mode = alc861vd_3stack_2ch_modes,
14782 .input_mux = &alc861vd_capture_source,
14783 },
14784 [ALC861VD_3ST_DIG] = {
14785 .mixers = { alc861vd_3st_mixer },
14786 .init_verbs = { alc861vd_volume_init_verbs,
14787 alc861vd_3stack_init_verbs },
14788 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14789 .dac_nids = alc861vd_dac_nids,
14790 .dig_out_nid = ALC861VD_DIGOUT_NID,
14791 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14792 .channel_mode = alc861vd_3stack_2ch_modes,
14793 .input_mux = &alc861vd_capture_source,
14794 },
14795 [ALC861VD_6ST_DIG] = {
14796 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14797 .init_verbs = { alc861vd_volume_init_verbs,
14798 alc861vd_6stack_init_verbs },
14799 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14800 .dac_nids = alc861vd_dac_nids,
14801 .dig_out_nid = ALC861VD_DIGOUT_NID,
14802 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14803 .channel_mode = alc861vd_6stack_modes,
14804 .input_mux = &alc861vd_capture_source,
14805 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014806 [ALC861VD_LENOVO] = {
14807 .mixers = { alc861vd_lenovo_mixer },
14808 .init_verbs = { alc861vd_volume_init_verbs,
14809 alc861vd_3stack_init_verbs,
14810 alc861vd_eapd_verbs,
14811 alc861vd_lenovo_unsol_verbs },
14812 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14813 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014814 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14815 .channel_mode = alc861vd_3stack_2ch_modes,
14816 .input_mux = &alc861vd_capture_source,
14817 .unsol_event = alc861vd_lenovo_unsol_event,
14818 .init_hook = alc861vd_lenovo_automute,
14819 },
Kailang Yang272a5272007-05-14 11:00:38 +020014820 [ALC861VD_DALLAS] = {
14821 .mixers = { alc861vd_dallas_mixer },
14822 .init_verbs = { alc861vd_dallas_verbs },
14823 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14824 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014825 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14826 .channel_mode = alc861vd_3stack_2ch_modes,
14827 .input_mux = &alc861vd_dallas_capture_source,
14828 .unsol_event = alc861vd_dallas_unsol_event,
14829 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014830 },
14831 [ALC861VD_HP] = {
14832 .mixers = { alc861vd_hp_mixer },
14833 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14834 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14835 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014836 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014837 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14838 .channel_mode = alc861vd_3stack_2ch_modes,
14839 .input_mux = &alc861vd_hp_capture_source,
14840 .unsol_event = alc861vd_dallas_unsol_event,
14841 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014842 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014843 [ALC660VD_ASUS_V1S] = {
14844 .mixers = { alc861vd_lenovo_mixer },
14845 .init_verbs = { alc861vd_volume_init_verbs,
14846 alc861vd_3stack_init_verbs,
14847 alc861vd_eapd_verbs,
14848 alc861vd_lenovo_unsol_verbs },
14849 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14850 .dac_nids = alc660vd_dac_nids,
14851 .dig_out_nid = ALC861VD_DIGOUT_NID,
14852 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14853 .channel_mode = alc861vd_3stack_2ch_modes,
14854 .input_mux = &alc861vd_capture_source,
14855 .unsol_event = alc861vd_lenovo_unsol_event,
14856 .init_hook = alc861vd_lenovo_automute,
14857 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014858};
14859
14860/*
14861 * BIOS auto configuration
14862 */
14863static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14864 hda_nid_t nid, int pin_type, int dac_idx)
14865{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014866 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014867}
14868
14869static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14870{
14871 struct alc_spec *spec = codec->spec;
14872 int i;
14873
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014874 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014875 for (i = 0; i <= HDA_SIDE; i++) {
14876 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014877 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878 if (nid)
14879 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014880 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014881 }
14882}
14883
14884
14885static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14886{
14887 struct alc_spec *spec = codec->spec;
14888 hda_nid_t pin;
14889
14890 pin = spec->autocfg.hp_pins[0];
14891 if (pin) /* connect to front and use dac 0 */
14892 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014893 pin = spec->autocfg.speaker_pins[0];
14894 if (pin)
14895 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014896}
14897
14898#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14899#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14900
14901static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14902{
14903 struct alc_spec *spec = codec->spec;
14904 int i;
14905
14906 for (i = 0; i < AUTO_PIN_LAST; i++) {
14907 hda_nid_t nid = spec->autocfg.input_pins[i];
14908 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014909 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014910 if (nid != ALC861VD_PIN_CD_NID &&
14911 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014912 snd_hda_codec_write(codec, nid, 0,
14913 AC_VERB_SET_AMP_GAIN_MUTE,
14914 AMP_OUT_MUTE);
14915 }
14916 }
14917}
14918
Takashi Iwaif511b012008-08-15 16:46:42 +020014919#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14920
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14922#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14923
14924/* add playback controls from the parsed DAC table */
14925/* Based on ALC880 version. But ALC861VD has separate,
14926 * different NIDs for mute/unmute switch and volume control */
14927static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14928 const struct auto_pin_cfg *cfg)
14929{
14930 char name[32];
14931 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14932 hda_nid_t nid_v, nid_s;
14933 int i, err;
14934
14935 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014936 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014937 continue;
14938 nid_v = alc861vd_idx_to_mixer_vol(
14939 alc880_dac_to_idx(
14940 spec->multiout.dac_nids[i]));
14941 nid_s = alc861vd_idx_to_mixer_switch(
14942 alc880_dac_to_idx(
14943 spec->multiout.dac_nids[i]));
14944
14945 if (i == 2) {
14946 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14948 "Center Playback Volume",
14949 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14950 HDA_OUTPUT));
14951 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014952 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014953 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14954 "LFE Playback Volume",
14955 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14956 HDA_OUTPUT));
14957 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014958 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014959 err = add_control(spec, ALC_CTL_BIND_MUTE,
14960 "Center Playback Switch",
14961 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14962 HDA_INPUT));
14963 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014964 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014965 err = add_control(spec, ALC_CTL_BIND_MUTE,
14966 "LFE Playback Switch",
14967 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14968 HDA_INPUT));
14969 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014970 return err;
14971 } else {
14972 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014973 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14974 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14975 HDA_OUTPUT));
14976 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014977 return err;
14978 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014979 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014980 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014981 HDA_INPUT));
14982 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014983 return err;
14984 }
14985 }
14986 return 0;
14987}
14988
14989/* add playback controls for speaker and HP outputs */
14990/* Based on ALC880 version. But ALC861VD has separate,
14991 * different NIDs for mute/unmute switch and volume control */
14992static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14993 hda_nid_t pin, const char *pfx)
14994{
14995 hda_nid_t nid_v, nid_s;
14996 int err;
14997 char name[32];
14998
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014999 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 return 0;
15001
15002 if (alc880_is_fixed_pin(pin)) {
15003 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15004 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015005 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015006 spec->multiout.hp_nid = nid_v;
15007 else
15008 spec->multiout.extra_out_nid[0] = nid_v;
15009 /* control HP volume/switch on the output mixer amp */
15010 nid_v = alc861vd_idx_to_mixer_vol(
15011 alc880_fixed_pin_idx(pin));
15012 nid_s = alc861vd_idx_to_mixer_switch(
15013 alc880_fixed_pin_idx(pin));
15014
15015 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015016 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15017 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15018 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015019 return err;
15020 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015021 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15022 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15023 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015024 return err;
15025 } else if (alc880_is_multi_pin(pin)) {
15026 /* set manual connection */
15027 /* we have only a switch on HP-out PIN */
15028 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015029 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15030 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15031 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015032 return err;
15033 }
15034 return 0;
15035}
15036
15037/* parse the BIOS configuration and set up the alc_spec
15038 * return 1 if successful, 0 if the proper config is not found,
15039 * or a negative error code
15040 * Based on ALC880 version - had to change it to override
15041 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15042static int alc861vd_parse_auto_config(struct hda_codec *codec)
15043{
15044 struct alc_spec *spec = codec->spec;
15045 int err;
15046 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015048 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15049 alc861vd_ignore);
15050 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015051 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015052 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015053 return 0; /* can't find valid BIOS pin config */
15054
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015055 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15056 if (err < 0)
15057 return err;
15058 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15059 if (err < 0)
15060 return err;
15061 err = alc861vd_auto_create_extra_out(spec,
15062 spec->autocfg.speaker_pins[0],
15063 "Speaker");
15064 if (err < 0)
15065 return err;
15066 err = alc861vd_auto_create_extra_out(spec,
15067 spec->autocfg.hp_pins[0],
15068 "Headphone");
15069 if (err < 0)
15070 return err;
15071 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15072 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015073 return err;
15074
15075 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15076
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015077 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015078 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15079
Takashi Iwai603c4012008-07-30 15:01:44 +020015080 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015081 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015082
Takashi Iwaid88897e2008-10-31 15:01:37 +010015083 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015084
15085 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015086 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015087
Takashi Iwai776e1842007-08-29 15:07:11 +020015088 err = alc_auto_add_mic_boost(codec);
15089 if (err < 0)
15090 return err;
15091
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015092 return 1;
15093}
15094
15095/* additional initialization for auto-configuration model */
15096static void alc861vd_auto_init(struct hda_codec *codec)
15097{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015098 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015099 alc861vd_auto_init_multi_out(codec);
15100 alc861vd_auto_init_hp_out(codec);
15101 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015102 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015103 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015104 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015105}
15106
15107static int patch_alc861vd(struct hda_codec *codec)
15108{
15109 struct alc_spec *spec;
15110 int err, board_config;
15111
15112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15113 if (spec == NULL)
15114 return -ENOMEM;
15115
15116 codec->spec = spec;
15117
15118 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15119 alc861vd_models,
15120 alc861vd_cfg_tbl);
15121
15122 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15123 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15124 "ALC861VD, trying auto-probe from BIOS...\n");
15125 board_config = ALC861VD_AUTO;
15126 }
15127
15128 if (board_config == ALC861VD_AUTO) {
15129 /* automatic parse from the BIOS config */
15130 err = alc861vd_parse_auto_config(codec);
15131 if (err < 0) {
15132 alc_free(codec);
15133 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015134 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015135 printk(KERN_INFO
15136 "hda_codec: Cannot set up configuration "
15137 "from BIOS. Using base mode...\n");
15138 board_config = ALC861VD_3ST;
15139 }
15140 }
15141
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015142 err = snd_hda_attach_beep_device(codec, 0x23);
15143 if (err < 0) {
15144 alc_free(codec);
15145 return err;
15146 }
15147
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 if (board_config != ALC861VD_AUTO)
15149 setup_preset(spec, &alc861vd_presets[board_config]);
15150
Kailang Yang2f893282008-05-27 12:14:47 +020015151 if (codec->vendor_id == 0x10ec0660) {
15152 spec->stream_name_analog = "ALC660-VD Analog";
15153 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020015154 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015155 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015156 } else {
15157 spec->stream_name_analog = "ALC861VD Analog";
15158 spec->stream_name_digital = "ALC861VD Digital";
15159 }
15160
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15162 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15163
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015164 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15165 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15166
15167 spec->adc_nids = alc861vd_adc_nids;
15168 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015169 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015170 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015171
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015172 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015173 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015174
Takashi Iwai2134ea42008-01-10 16:53:55 +010015175 spec->vmaster_nid = 0x02;
15176
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015177 codec->patch_ops = alc_patch_ops;
15178
15179 if (board_config == ALC861VD_AUTO)
15180 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015181#ifdef CONFIG_SND_HDA_POWER_SAVE
15182 if (!spec->loopback.amplist)
15183 spec->loopback.amplist = alc861vd_loopbacks;
15184#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015185 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015186
15187 return 0;
15188}
15189
15190/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015191 * ALC662 support
15192 *
15193 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15194 * configuration. Each pin widget can choose any input DACs and a mixer.
15195 * Each ADC is connected from a mixer of all inputs. This makes possible
15196 * 6-channel independent captures.
15197 *
15198 * In addition, an independent DAC for the multi-playback (not used in this
15199 * driver yet).
15200 */
15201#define ALC662_DIGOUT_NID 0x06
15202#define ALC662_DIGIN_NID 0x0a
15203
15204static hda_nid_t alc662_dac_nids[4] = {
15205 /* front, rear, clfe, rear_surr */
15206 0x02, 0x03, 0x04
15207};
15208
15209static hda_nid_t alc662_adc_nids[1] = {
15210 /* ADC1-2 */
15211 0x09,
15212};
Takashi Iwaie1406342008-02-11 18:32:32 +010015213
Kailang Yang77a261b2008-02-19 11:38:05 +010015214static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015215
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015216/* input MUX */
15217/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015218static struct hda_input_mux alc662_capture_source = {
15219 .num_items = 4,
15220 .items = {
15221 { "Mic", 0x0 },
15222 { "Front Mic", 0x1 },
15223 { "Line", 0x2 },
15224 { "CD", 0x4 },
15225 },
15226};
15227
15228static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15229 .num_items = 2,
15230 .items = {
15231 { "Mic", 0x1 },
15232 { "Line", 0x2 },
15233 },
15234};
Kailang Yang291702f2007-10-16 14:28:03 +020015235
15236static struct hda_input_mux alc662_eeepc_capture_source = {
15237 .num_items = 2,
15238 .items = {
15239 { "i-Mic", 0x1 },
15240 { "e-Mic", 0x0 },
15241 },
15242};
15243
Kailang Yang6dda9f42008-05-27 12:05:31 +020015244static struct hda_input_mux alc663_capture_source = {
15245 .num_items = 3,
15246 .items = {
15247 { "Mic", 0x0 },
15248 { "Front Mic", 0x1 },
15249 { "Line", 0x2 },
15250 },
15251};
15252
15253static struct hda_input_mux alc663_m51va_capture_source = {
15254 .num_items = 2,
15255 .items = {
15256 { "Ext-Mic", 0x0 },
15257 { "D-Mic", 0x9 },
15258 },
15259};
15260
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015261/*
15262 * 2ch mode
15263 */
15264static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15265 { 2, NULL }
15266};
15267
15268/*
15269 * 2ch mode
15270 */
15271static struct hda_verb alc662_3ST_ch2_init[] = {
15272 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15273 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15274 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15275 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15276 { } /* end */
15277};
15278
15279/*
15280 * 6ch mode
15281 */
15282static struct hda_verb alc662_3ST_ch6_init[] = {
15283 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15284 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15285 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15286 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15287 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15288 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15289 { } /* end */
15290};
15291
15292static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15293 { 2, alc662_3ST_ch2_init },
15294 { 6, alc662_3ST_ch6_init },
15295};
15296
15297/*
15298 * 2ch mode
15299 */
15300static struct hda_verb alc662_sixstack_ch6_init[] = {
15301 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15302 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15303 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15304 { } /* end */
15305};
15306
15307/*
15308 * 6ch mode
15309 */
15310static struct hda_verb alc662_sixstack_ch8_init[] = {
15311 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15312 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15313 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15314 { } /* end */
15315};
15316
15317static struct hda_channel_mode alc662_5stack_modes[2] = {
15318 { 2, alc662_sixstack_ch6_init },
15319 { 6, alc662_sixstack_ch8_init },
15320};
15321
15322/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15323 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15324 */
15325
15326static struct snd_kcontrol_new alc662_base_mixer[] = {
15327 /* output mixer control */
15328 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015329 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015330 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015331 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015332 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15333 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015334 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15335 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15337
15338 /*Input mixer control */
15339 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15340 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15341 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15342 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15343 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15344 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015347 { } /* end */
15348};
15349
15350static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15351 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015352 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15360 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15361 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015362 { } /* end */
15363};
15364
15365static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15366 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015367 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015368 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015369 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015370 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15371 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015372 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15373 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015374 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15381 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15382 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015383 { } /* end */
15384};
15385
15386static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15387 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15388 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015389 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15390 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15392 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15393 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015396 { } /* end */
15397};
15398
Kailang Yang291702f2007-10-16 14:28:03 +020015399static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015401
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015402 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015404
15405 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15406 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15407 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15408
15409 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15410 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15411 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15412 { } /* end */
15413};
15414
Kailang Yang8c427222008-01-10 13:03:59 +010015415static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015416 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15417 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015418 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15419 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15420 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15421 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15422 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15423 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015424 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015425 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15426 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15427 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15430 { } /* end */
15431};
15432
Kailang Yangf1d4e282008-08-26 14:03:29 +020015433static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15434 .ops = &snd_hda_bind_vol,
15435 .values = {
15436 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15437 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15438 0
15439 },
15440};
15441
15442static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15443 .ops = &snd_hda_bind_sw,
15444 .values = {
15445 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15446 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15447 0
15448 },
15449};
15450
Kailang Yang6dda9f42008-05-27 12:05:31 +020015451static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015452 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15453 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15456 { } /* end */
15457};
15458
15459static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15460 .ops = &snd_hda_bind_sw,
15461 .values = {
15462 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15463 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15464 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15465 0
15466 },
15467};
15468
15469static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15470 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15471 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15474 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15475 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15476
15477 { } /* end */
15478};
15479
15480static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15481 .ops = &snd_hda_bind_sw,
15482 .values = {
15483 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15484 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15485 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15486 0
15487 },
15488};
15489
15490static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15491 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15492 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15495 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15496 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15497 { } /* end */
15498};
15499
15500static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015501 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15502 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15506 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15507 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15508 { } /* end */
15509};
15510
15511static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15512 .ops = &snd_hda_bind_vol,
15513 .values = {
15514 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15515 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15516 0
15517 },
15518};
15519
15520static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15521 .ops = &snd_hda_bind_sw,
15522 .values = {
15523 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15524 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15525 0
15526 },
15527};
15528
15529static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15530 HDA_BIND_VOL("Master Playback Volume",
15531 &alc663_asus_two_bind_master_vol),
15532 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15533 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015534 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015537 { } /* end */
15538};
15539
15540static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15541 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15542 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015547 { } /* end */
15548};
15549
15550static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15551 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15552 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15553 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15554 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15556
15557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15559 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15560 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15561 { } /* end */
15562};
15563
15564static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15565 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15566 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15568
15569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15571 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15572 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15575 { } /* end */
15576};
15577
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015578static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15579 {
15580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15581 .name = "Channel Mode",
15582 .info = alc_ch_mode_info,
15583 .get = alc_ch_mode_get,
15584 .put = alc_ch_mode_put,
15585 },
15586 { } /* end */
15587};
15588
15589static struct hda_verb alc662_init_verbs[] = {
15590 /* ADC: mute amp left and right */
15591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15593 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15594
Takashi Iwaicb53c622007-08-10 17:21:45 +020015595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15596 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15598 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015600
Kailang Yangb60dd392007-09-20 12:50:29 +020015601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015607
15608 /* Front Pin: output 0 (0x0c) */
15609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15611
15612 /* Rear Pin: output 1 (0x0d) */
15613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15615
15616 /* CLFE Pin: output 2 (0x0e) */
15617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15618 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15619
15620 /* Mic (rear) pin: input vref at 80% */
15621 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15622 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15623 /* Front Mic pin: input vref at 80% */
15624 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15625 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15626 /* Line In pin: input */
15627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15629 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15633 /* CD pin widget for input */
15634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15635
15636 /* FIXME: use matrix-type input source selection */
15637 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15638 /* Input mixer */
15639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015643
15644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15646 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015648
15649 /* always trun on EAPD */
15650 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15651 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15652
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015653 { }
15654};
15655
15656static struct hda_verb alc662_sue_init_verbs[] = {
15657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15658 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015659 {}
15660};
15661
15662static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15663 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15664 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15665 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015666};
15667
Kailang Yang8c427222008-01-10 13:03:59 +010015668/* Set Unsolicited Event*/
15669static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15671 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15672 {}
15673};
15674
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015675/*
15676 * generic initialization of ADC, input mixers and output mixers
15677 */
15678static struct hda_verb alc662_auto_init_verbs[] = {
15679 /*
15680 * Unmute ADC and set the default input to mic-in
15681 */
15682 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684
15685 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15686 * mixer widget
15687 * Note: PASD motherboards uses the Line In 2 as the input for front
15688 * panel mic (mic 2)
15689 */
15690 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015696
15697 /*
15698 * Set up output mixers (0x0c - 0x0f)
15699 */
15700 /* set vol=0 to output mixers */
15701 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15702 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15703 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15704
15705 /* set up input amps for analog loopback */
15706 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015713
15714
15715 /* FIXME: use matrix-type input source selection */
15716 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15717 /* Input mixer */
15718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015719 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015720 { }
15721};
15722
Takashi Iwai24fb9172008-09-02 14:48:20 +020015723/* additional verbs for ALC663 */
15724static struct hda_verb alc663_auto_init_verbs[] = {
15725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15727 { }
15728};
15729
Kailang Yang6dda9f42008-05-27 12:05:31 +020015730static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015733 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15734 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015735 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15739 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15740 {}
15741};
15742
Kailang Yangf1d4e282008-08-26 14:03:29 +020015743static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15744 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15745 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15746 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15749 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15750 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15751 {}
15752};
15753
15754static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15755 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15756 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15758 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15761 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15762 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15763 {}
15764};
15765
15766static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15772 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15773 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15774 {}
15775};
15776
15777static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15779 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15780 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15781 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15787 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15788 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15789 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15790 {}
15791};
15792
15793static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15796 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15797 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15803 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15805 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15806 {}
15807};
15808
Kailang Yang6dda9f42008-05-27 12:05:31 +020015809static struct hda_verb alc663_g71v_init_verbs[] = {
15810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15811 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15812 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15813
15814 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15815 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15816 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15817
15818 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15820 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15821 {}
15822};
15823
15824static struct hda_verb alc663_g50v_init_verbs[] = {
15825 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15826 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15827 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15828
15829 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15830 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15831 {}
15832};
15833
Kailang Yangf1d4e282008-08-26 14:03:29 +020015834static struct hda_verb alc662_ecs_init_verbs[] = {
15835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15837 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15838 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15839 {}
15840};
15841
Kailang Yangf1d4e282008-08-26 14:03:29 +020015842static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15843 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15844 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15845 { } /* end */
15846};
15847
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015848static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15849{
15850 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015851 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015852
15853 present = snd_hda_codec_read(codec, 0x14, 0,
15854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015855 bits = present ? HDA_AMP_MUTE : 0;
15856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15857 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015858}
15859
15860static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15861{
15862 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015863 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015864
15865 present = snd_hda_codec_read(codec, 0x1b, 0,
15866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015867 bits = present ? HDA_AMP_MUTE : 0;
15868 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15869 HDA_AMP_MUTE, bits);
15870 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15871 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015872}
15873
15874static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15875 unsigned int res)
15876{
15877 if ((res >> 26) == ALC880_HP_EVENT)
15878 alc662_lenovo_101e_all_automute(codec);
15879 if ((res >> 26) == ALC880_FRONT_EVENT)
15880 alc662_lenovo_101e_ispeaker_automute(codec);
15881}
15882
Kailang Yang291702f2007-10-16 14:28:03 +020015883static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15884{
15885 unsigned int present;
15886
15887 present = snd_hda_codec_read(codec, 0x18, 0,
15888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15889 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15890 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15891 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15892 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15893 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15894 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15895 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15896 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15897}
15898
15899/* unsolicited event for HP jack sensing */
15900static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15901 unsigned int res)
15902{
15903 if ((res >> 26) == ALC880_HP_EVENT)
15904 alc262_hippo1_automute( codec );
15905
15906 if ((res >> 26) == ALC880_MIC_EVENT)
15907 alc662_eeepc_mic_automute(codec);
15908}
15909
15910static void alc662_eeepc_inithook(struct hda_codec *codec)
15911{
15912 alc262_hippo1_automute( codec );
15913 alc662_eeepc_mic_automute(codec);
15914}
15915
Kailang Yang8c427222008-01-10 13:03:59 +010015916static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15917{
15918 unsigned int mute;
15919 unsigned int present;
15920
15921 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15922 present = snd_hda_codec_read(codec, 0x14, 0,
15923 AC_VERB_GET_PIN_SENSE, 0);
15924 present = (present & 0x80000000) != 0;
15925 if (present) {
15926 /* mute internal speaker */
15927 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015928 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015929 } else {
15930 /* unmute internal speaker if necessary */
15931 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15932 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015933 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015934 }
15935}
15936
15937/* unsolicited event for HP jack sensing */
15938static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15939 unsigned int res)
15940{
15941 if ((res >> 26) == ALC880_HP_EVENT)
15942 alc662_eeepc_ep20_automute(codec);
15943}
15944
15945static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15946{
15947 alc662_eeepc_ep20_automute(codec);
15948}
15949
Kailang Yang6dda9f42008-05-27 12:05:31 +020015950static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15951{
15952 unsigned int present;
15953 unsigned char bits;
15954
15955 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015956 AC_VERB_GET_PIN_SENSE, 0)
15957 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015958 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015959 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15960 AMP_IN_MUTE(0), bits);
15961 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15962 AMP_IN_MUTE(0), bits);
15963}
15964
15965static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15966{
15967 unsigned int present;
15968 unsigned char bits;
15969
15970 present = snd_hda_codec_read(codec, 0x21, 0,
15971 AC_VERB_GET_PIN_SENSE, 0)
15972 & AC_PINSENSE_PRESENCE;
15973 bits = present ? HDA_AMP_MUTE : 0;
15974 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15975 AMP_IN_MUTE(0), bits);
15976 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15977 AMP_IN_MUTE(0), bits);
15978 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15979 AMP_IN_MUTE(0), bits);
15980 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15981 AMP_IN_MUTE(0), bits);
15982}
15983
15984static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15985{
15986 unsigned int present;
15987 unsigned char bits;
15988
15989 present = snd_hda_codec_read(codec, 0x15, 0,
15990 AC_VERB_GET_PIN_SENSE, 0)
15991 & AC_PINSENSE_PRESENCE;
15992 bits = present ? HDA_AMP_MUTE : 0;
15993 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15994 AMP_IN_MUTE(0), bits);
15995 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15996 AMP_IN_MUTE(0), bits);
15997 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15998 AMP_IN_MUTE(0), bits);
15999 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16000 AMP_IN_MUTE(0), bits);
16001}
16002
16003static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16004{
16005 unsigned int present;
16006 unsigned char bits;
16007
16008 present = snd_hda_codec_read(codec, 0x1b, 0,
16009 AC_VERB_GET_PIN_SENSE, 0)
16010 & AC_PINSENSE_PRESENCE;
16011 bits = present ? 0 : PIN_OUT;
16012 snd_hda_codec_write(codec, 0x14, 0,
16013 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16014}
16015
16016static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16017{
16018 unsigned int present1, present2;
16019
16020 present1 = snd_hda_codec_read(codec, 0x21, 0,
16021 AC_VERB_GET_PIN_SENSE, 0)
16022 & AC_PINSENSE_PRESENCE;
16023 present2 = snd_hda_codec_read(codec, 0x15, 0,
16024 AC_VERB_GET_PIN_SENSE, 0)
16025 & AC_PINSENSE_PRESENCE;
16026
16027 if (present1 || present2) {
16028 snd_hda_codec_write_cache(codec, 0x14, 0,
16029 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16030 } else {
16031 snd_hda_codec_write_cache(codec, 0x14, 0,
16032 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16033 }
16034}
16035
16036static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16037{
16038 unsigned int present1, present2;
16039
16040 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16041 AC_VERB_GET_PIN_SENSE, 0)
16042 & AC_PINSENSE_PRESENCE;
16043 present2 = snd_hda_codec_read(codec, 0x15, 0,
16044 AC_VERB_GET_PIN_SENSE, 0)
16045 & AC_PINSENSE_PRESENCE;
16046
16047 if (present1 || present2) {
16048 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16049 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16050 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16051 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16052 } else {
16053 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16054 AMP_IN_MUTE(0), 0);
16055 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16056 AMP_IN_MUTE(0), 0);
16057 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016058}
16059
16060static void alc663_m51va_mic_automute(struct hda_codec *codec)
16061{
16062 unsigned int present;
16063
16064 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016065 AC_VERB_GET_PIN_SENSE, 0)
16066 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016067 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016068 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016069 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016070 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016071 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016072 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016073 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016074 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016075}
16076
16077static void alc663_m51va_unsol_event(struct hda_codec *codec,
16078 unsigned int res)
16079{
16080 switch (res >> 26) {
16081 case ALC880_HP_EVENT:
16082 alc663_m51va_speaker_automute(codec);
16083 break;
16084 case ALC880_MIC_EVENT:
16085 alc663_m51va_mic_automute(codec);
16086 break;
16087 }
16088}
16089
16090static void alc663_m51va_inithook(struct hda_codec *codec)
16091{
16092 alc663_m51va_speaker_automute(codec);
16093 alc663_m51va_mic_automute(codec);
16094}
16095
Kailang Yangf1d4e282008-08-26 14:03:29 +020016096/* ***************** Mode1 ******************************/
16097static void alc663_mode1_unsol_event(struct hda_codec *codec,
16098 unsigned int res)
16099{
16100 switch (res >> 26) {
16101 case ALC880_HP_EVENT:
16102 alc663_m51va_speaker_automute(codec);
16103 break;
16104 case ALC880_MIC_EVENT:
16105 alc662_eeepc_mic_automute(codec);
16106 break;
16107 }
16108}
16109
16110static void alc663_mode1_inithook(struct hda_codec *codec)
16111{
16112 alc663_m51va_speaker_automute(codec);
16113 alc662_eeepc_mic_automute(codec);
16114}
16115/* ***************** Mode2 ******************************/
16116static void alc662_mode2_unsol_event(struct hda_codec *codec,
16117 unsigned int res)
16118{
16119 switch (res >> 26) {
16120 case ALC880_HP_EVENT:
16121 alc662_f5z_speaker_automute(codec);
16122 break;
16123 case ALC880_MIC_EVENT:
16124 alc662_eeepc_mic_automute(codec);
16125 break;
16126 }
16127}
16128
16129static void alc662_mode2_inithook(struct hda_codec *codec)
16130{
16131 alc662_f5z_speaker_automute(codec);
16132 alc662_eeepc_mic_automute(codec);
16133}
16134/* ***************** Mode3 ******************************/
16135static void alc663_mode3_unsol_event(struct hda_codec *codec,
16136 unsigned int res)
16137{
16138 switch (res >> 26) {
16139 case ALC880_HP_EVENT:
16140 alc663_two_hp_m1_speaker_automute(codec);
16141 break;
16142 case ALC880_MIC_EVENT:
16143 alc662_eeepc_mic_automute(codec);
16144 break;
16145 }
16146}
16147
16148static void alc663_mode3_inithook(struct hda_codec *codec)
16149{
16150 alc663_two_hp_m1_speaker_automute(codec);
16151 alc662_eeepc_mic_automute(codec);
16152}
16153/* ***************** Mode4 ******************************/
16154static void alc663_mode4_unsol_event(struct hda_codec *codec,
16155 unsigned int res)
16156{
16157 switch (res >> 26) {
16158 case ALC880_HP_EVENT:
16159 alc663_21jd_two_speaker_automute(codec);
16160 break;
16161 case ALC880_MIC_EVENT:
16162 alc662_eeepc_mic_automute(codec);
16163 break;
16164 }
16165}
16166
16167static void alc663_mode4_inithook(struct hda_codec *codec)
16168{
16169 alc663_21jd_two_speaker_automute(codec);
16170 alc662_eeepc_mic_automute(codec);
16171}
16172/* ***************** Mode5 ******************************/
16173static void alc663_mode5_unsol_event(struct hda_codec *codec,
16174 unsigned int res)
16175{
16176 switch (res >> 26) {
16177 case ALC880_HP_EVENT:
16178 alc663_15jd_two_speaker_automute(codec);
16179 break;
16180 case ALC880_MIC_EVENT:
16181 alc662_eeepc_mic_automute(codec);
16182 break;
16183 }
16184}
16185
16186static void alc663_mode5_inithook(struct hda_codec *codec)
16187{
16188 alc663_15jd_two_speaker_automute(codec);
16189 alc662_eeepc_mic_automute(codec);
16190}
16191/* ***************** Mode6 ******************************/
16192static void alc663_mode6_unsol_event(struct hda_codec *codec,
16193 unsigned int res)
16194{
16195 switch (res >> 26) {
16196 case ALC880_HP_EVENT:
16197 alc663_two_hp_m2_speaker_automute(codec);
16198 break;
16199 case ALC880_MIC_EVENT:
16200 alc662_eeepc_mic_automute(codec);
16201 break;
16202 }
16203}
16204
16205static void alc663_mode6_inithook(struct hda_codec *codec)
16206{
16207 alc663_two_hp_m2_speaker_automute(codec);
16208 alc662_eeepc_mic_automute(codec);
16209}
16210
Kailang Yang6dda9f42008-05-27 12:05:31 +020016211static void alc663_g71v_hp_automute(struct hda_codec *codec)
16212{
16213 unsigned int present;
16214 unsigned char bits;
16215
16216 present = snd_hda_codec_read(codec, 0x21, 0,
16217 AC_VERB_GET_PIN_SENSE, 0)
16218 & AC_PINSENSE_PRESENCE;
16219 bits = present ? HDA_AMP_MUTE : 0;
16220 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16221 HDA_AMP_MUTE, bits);
16222 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16223 HDA_AMP_MUTE, bits);
16224}
16225
16226static void alc663_g71v_front_automute(struct hda_codec *codec)
16227{
16228 unsigned int present;
16229 unsigned char bits;
16230
16231 present = snd_hda_codec_read(codec, 0x15, 0,
16232 AC_VERB_GET_PIN_SENSE, 0)
16233 & AC_PINSENSE_PRESENCE;
16234 bits = present ? HDA_AMP_MUTE : 0;
16235 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16236 HDA_AMP_MUTE, bits);
16237}
16238
16239static void alc663_g71v_unsol_event(struct hda_codec *codec,
16240 unsigned int res)
16241{
16242 switch (res >> 26) {
16243 case ALC880_HP_EVENT:
16244 alc663_g71v_hp_automute(codec);
16245 break;
16246 case ALC880_FRONT_EVENT:
16247 alc663_g71v_front_automute(codec);
16248 break;
16249 case ALC880_MIC_EVENT:
16250 alc662_eeepc_mic_automute(codec);
16251 break;
16252 }
16253}
16254
16255static void alc663_g71v_inithook(struct hda_codec *codec)
16256{
16257 alc663_g71v_front_automute(codec);
16258 alc663_g71v_hp_automute(codec);
16259 alc662_eeepc_mic_automute(codec);
16260}
16261
16262static void alc663_g50v_unsol_event(struct hda_codec *codec,
16263 unsigned int res)
16264{
16265 switch (res >> 26) {
16266 case ALC880_HP_EVENT:
16267 alc663_m51va_speaker_automute(codec);
16268 break;
16269 case ALC880_MIC_EVENT:
16270 alc662_eeepc_mic_automute(codec);
16271 break;
16272 }
16273}
16274
16275static void alc663_g50v_inithook(struct hda_codec *codec)
16276{
16277 alc663_m51va_speaker_automute(codec);
16278 alc662_eeepc_mic_automute(codec);
16279}
16280
Kailang Yangf1d4e282008-08-26 14:03:29 +020016281/* bind hp and internal speaker mute (with plug check) */
16282static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16283 struct snd_ctl_elem_value *ucontrol)
16284{
16285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16286 long *valp = ucontrol->value.integer.value;
16287 int change;
16288
16289 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16290 HDA_AMP_MUTE,
16291 valp[0] ? 0 : HDA_AMP_MUTE);
16292 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16293 HDA_AMP_MUTE,
16294 valp[1] ? 0 : HDA_AMP_MUTE);
16295 if (change)
16296 alc262_hippo1_automute(codec);
16297 return change;
16298}
16299
16300static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16301 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16302 {
16303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16304 .name = "Master Playback Switch",
16305 .info = snd_hda_mixer_amp_switch_info,
16306 .get = snd_hda_mixer_amp_switch_get,
16307 .put = alc662_ecs_master_sw_put,
16308 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16309 },
16310
16311 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16312 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16313 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16314
16315 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16316 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16317 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16318 { } /* end */
16319};
16320
Takashi Iwaicb53c622007-08-10 17:21:45 +020016321#ifdef CONFIG_SND_HDA_POWER_SAVE
16322#define alc662_loopbacks alc880_loopbacks
16323#endif
16324
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325
16326/* pcm configuration: identiacal with ALC880 */
16327#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16328#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16329#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16330#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16331
16332/*
16333 * configuration and preset
16334 */
16335static const char *alc662_models[ALC662_MODEL_LAST] = {
16336 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16337 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16338 [ALC662_3ST_6ch] = "3stack-6ch",
16339 [ALC662_5ST_DIG] = "6stack-dig",
16340 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016341 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016342 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016343 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016344 [ALC663_ASUS_M51VA] = "m51va",
16345 [ALC663_ASUS_G71V] = "g71v",
16346 [ALC663_ASUS_H13] = "h13",
16347 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016348 [ALC663_ASUS_MODE1] = "asus-mode1",
16349 [ALC662_ASUS_MODE2] = "asus-mode2",
16350 [ALC663_ASUS_MODE3] = "asus-mode3",
16351 [ALC663_ASUS_MODE4] = "asus-mode4",
16352 [ALC663_ASUS_MODE5] = "asus-mode5",
16353 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016354 [ALC662_AUTO] = "auto",
16355};
16356
16357static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016358 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16359 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16360 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16361 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16362 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16363 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16364 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16365 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16366 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16367 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16368 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16369 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16370 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16371 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16372 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16373 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16374 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16375 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16376 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016377 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016378 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16379 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16380 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16381 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16382 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16383 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16384 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16385 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16386 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016387 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016388 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16389 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16390 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16391 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16392 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016393 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016394 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016395 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016396 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016397 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16398 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016399 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16400 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016401 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016402 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016403 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016404 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016405 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16406 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016407 {}
16408};
16409
16410static struct alc_config_preset alc662_presets[] = {
16411 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016412 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016413 .init_verbs = { alc662_init_verbs },
16414 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16415 .dac_nids = alc662_dac_nids,
16416 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016417 .dig_in_nid = ALC662_DIGIN_NID,
16418 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16419 .channel_mode = alc662_3ST_2ch_modes,
16420 .input_mux = &alc662_capture_source,
16421 },
16422 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016423 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016424 .init_verbs = { alc662_init_verbs },
16425 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16426 .dac_nids = alc662_dac_nids,
16427 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016428 .dig_in_nid = ALC662_DIGIN_NID,
16429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16430 .channel_mode = alc662_3ST_6ch_modes,
16431 .need_dac_fix = 1,
16432 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016433 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016434 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016435 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016436 .init_verbs = { alc662_init_verbs },
16437 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16438 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016439 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16440 .channel_mode = alc662_3ST_6ch_modes,
16441 .need_dac_fix = 1,
16442 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016443 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016444 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016445 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016446 .init_verbs = { alc662_init_verbs },
16447 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16448 .dac_nids = alc662_dac_nids,
16449 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016450 .dig_in_nid = ALC662_DIGIN_NID,
16451 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16452 .channel_mode = alc662_5stack_modes,
16453 .input_mux = &alc662_capture_source,
16454 },
16455 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016456 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016457 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16458 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16459 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016460 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16461 .channel_mode = alc662_3ST_2ch_modes,
16462 .input_mux = &alc662_lenovo_101e_capture_source,
16463 .unsol_event = alc662_lenovo_101e_unsol_event,
16464 .init_hook = alc662_lenovo_101e_all_automute,
16465 },
Kailang Yang291702f2007-10-16 14:28:03 +020016466 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016467 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016468 .init_verbs = { alc662_init_verbs,
16469 alc662_eeepc_sue_init_verbs },
16470 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16471 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016472 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16473 .channel_mode = alc662_3ST_2ch_modes,
16474 .input_mux = &alc662_eeepc_capture_source,
16475 .unsol_event = alc662_eeepc_unsol_event,
16476 .init_hook = alc662_eeepc_inithook,
16477 },
Kailang Yang8c427222008-01-10 13:03:59 +010016478 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016479 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016480 alc662_chmode_mixer },
16481 .init_verbs = { alc662_init_verbs,
16482 alc662_eeepc_ep20_sue_init_verbs },
16483 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16484 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016485 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16486 .channel_mode = alc662_3ST_6ch_modes,
16487 .input_mux = &alc662_lenovo_101e_capture_source,
16488 .unsol_event = alc662_eeepc_ep20_unsol_event,
16489 .init_hook = alc662_eeepc_ep20_inithook,
16490 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016491 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016492 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016493 .init_verbs = { alc662_init_verbs,
16494 alc662_ecs_init_verbs },
16495 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16496 .dac_nids = alc662_dac_nids,
16497 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16498 .channel_mode = alc662_3ST_2ch_modes,
16499 .input_mux = &alc662_eeepc_capture_source,
16500 .unsol_event = alc662_eeepc_unsol_event,
16501 .init_hook = alc662_eeepc_inithook,
16502 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016503 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016504 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016505 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16506 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16507 .dac_nids = alc662_dac_nids,
16508 .dig_out_nid = ALC662_DIGOUT_NID,
16509 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16510 .channel_mode = alc662_3ST_2ch_modes,
16511 .input_mux = &alc663_m51va_capture_source,
16512 .unsol_event = alc663_m51va_unsol_event,
16513 .init_hook = alc663_m51va_inithook,
16514 },
16515 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016516 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016517 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16518 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16519 .dac_nids = alc662_dac_nids,
16520 .dig_out_nid = ALC662_DIGOUT_NID,
16521 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16522 .channel_mode = alc662_3ST_2ch_modes,
16523 .input_mux = &alc662_eeepc_capture_source,
16524 .unsol_event = alc663_g71v_unsol_event,
16525 .init_hook = alc663_g71v_inithook,
16526 },
16527 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016528 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016529 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16530 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16531 .dac_nids = alc662_dac_nids,
16532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16533 .channel_mode = alc662_3ST_2ch_modes,
16534 .input_mux = &alc663_m51va_capture_source,
16535 .unsol_event = alc663_m51va_unsol_event,
16536 .init_hook = alc663_m51va_inithook,
16537 },
16538 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016539 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016540 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16541 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16542 .dac_nids = alc662_dac_nids,
16543 .dig_out_nid = ALC662_DIGOUT_NID,
16544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16545 .channel_mode = alc662_3ST_6ch_modes,
16546 .input_mux = &alc663_capture_source,
16547 .unsol_event = alc663_g50v_unsol_event,
16548 .init_hook = alc663_g50v_inithook,
16549 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016550 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016551 .mixers = { alc663_m51va_mixer },
16552 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016553 .init_verbs = { alc662_init_verbs,
16554 alc663_21jd_amic_init_verbs },
16555 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16556 .hp_nid = 0x03,
16557 .dac_nids = alc662_dac_nids,
16558 .dig_out_nid = ALC662_DIGOUT_NID,
16559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16560 .channel_mode = alc662_3ST_2ch_modes,
16561 .input_mux = &alc662_eeepc_capture_source,
16562 .unsol_event = alc663_mode1_unsol_event,
16563 .init_hook = alc663_mode1_inithook,
16564 },
16565 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016566 .mixers = { alc662_1bjd_mixer },
16567 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016568 .init_verbs = { alc662_init_verbs,
16569 alc662_1bjd_amic_init_verbs },
16570 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16571 .dac_nids = alc662_dac_nids,
16572 .dig_out_nid = ALC662_DIGOUT_NID,
16573 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16574 .channel_mode = alc662_3ST_2ch_modes,
16575 .input_mux = &alc662_eeepc_capture_source,
16576 .unsol_event = alc662_mode2_unsol_event,
16577 .init_hook = alc662_mode2_inithook,
16578 },
16579 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016580 .mixers = { alc663_two_hp_m1_mixer },
16581 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016582 .init_verbs = { alc662_init_verbs,
16583 alc663_two_hp_amic_m1_init_verbs },
16584 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16585 .hp_nid = 0x03,
16586 .dac_nids = alc662_dac_nids,
16587 .dig_out_nid = ALC662_DIGOUT_NID,
16588 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16589 .channel_mode = alc662_3ST_2ch_modes,
16590 .input_mux = &alc662_eeepc_capture_source,
16591 .unsol_event = alc663_mode3_unsol_event,
16592 .init_hook = alc663_mode3_inithook,
16593 },
16594 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016595 .mixers = { alc663_asus_21jd_clfe_mixer },
16596 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016597 .init_verbs = { alc662_init_verbs,
16598 alc663_21jd_amic_init_verbs},
16599 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16600 .hp_nid = 0x03,
16601 .dac_nids = alc662_dac_nids,
16602 .dig_out_nid = ALC662_DIGOUT_NID,
16603 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16604 .channel_mode = alc662_3ST_2ch_modes,
16605 .input_mux = &alc662_eeepc_capture_source,
16606 .unsol_event = alc663_mode4_unsol_event,
16607 .init_hook = alc663_mode4_inithook,
16608 },
16609 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016610 .mixers = { alc663_asus_15jd_clfe_mixer },
16611 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016612 .init_verbs = { alc662_init_verbs,
16613 alc663_15jd_amic_init_verbs },
16614 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16615 .hp_nid = 0x03,
16616 .dac_nids = alc662_dac_nids,
16617 .dig_out_nid = ALC662_DIGOUT_NID,
16618 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16619 .channel_mode = alc662_3ST_2ch_modes,
16620 .input_mux = &alc662_eeepc_capture_source,
16621 .unsol_event = alc663_mode5_unsol_event,
16622 .init_hook = alc663_mode5_inithook,
16623 },
16624 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016625 .mixers = { alc663_two_hp_m2_mixer },
16626 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016627 .init_verbs = { alc662_init_verbs,
16628 alc663_two_hp_amic_m2_init_verbs },
16629 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16630 .hp_nid = 0x03,
16631 .dac_nids = alc662_dac_nids,
16632 .dig_out_nid = ALC662_DIGOUT_NID,
16633 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16634 .channel_mode = alc662_3ST_2ch_modes,
16635 .input_mux = &alc662_eeepc_capture_source,
16636 .unsol_event = alc663_mode6_unsol_event,
16637 .init_hook = alc663_mode6_inithook,
16638 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016639};
16640
16641
16642/*
16643 * BIOS auto configuration
16644 */
16645
16646/* add playback controls from the parsed DAC table */
16647static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16648 const struct auto_pin_cfg *cfg)
16649{
16650 char name[32];
16651 static const char *chname[4] = {
16652 "Front", "Surround", NULL /*CLFE*/, "Side"
16653 };
16654 hda_nid_t nid;
16655 int i, err;
16656
16657 for (i = 0; i < cfg->line_outs; i++) {
16658 if (!spec->multiout.dac_nids[i])
16659 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016660 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016661 if (i == 2) {
16662 /* Center/LFE */
16663 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16664 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016665 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16666 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016667 if (err < 0)
16668 return err;
16669 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16670 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016671 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16672 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016673 if (err < 0)
16674 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016675 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016676 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016677 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016678 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016679 if (err < 0)
16680 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016681 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016682 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016683 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016684 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016685 if (err < 0)
16686 return err;
16687 } else {
16688 sprintf(name, "%s Playback Volume", chname[i]);
16689 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016690 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16691 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016692 if (err < 0)
16693 return err;
16694 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016695 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16696 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16697 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016698 if (err < 0)
16699 return err;
16700 }
16701 }
16702 return 0;
16703}
16704
16705/* add playback controls for speaker and HP outputs */
16706static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16707 const char *pfx)
16708{
16709 hda_nid_t nid;
16710 int err;
16711 char name[32];
16712
16713 if (!pin)
16714 return 0;
16715
Takashi Iwai24fb9172008-09-02 14:48:20 +020016716 if (pin == 0x17) {
16717 /* ALC663 has a mono output pin on 0x17 */
16718 sprintf(name, "%s Playback Switch", pfx);
16719 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16720 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16721 return err;
16722 }
16723
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016724 if (alc880_is_fixed_pin(pin)) {
16725 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016726 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016727 /* specify the DAC as the extra output */
16728 if (!spec->multiout.hp_nid)
16729 spec->multiout.hp_nid = nid;
16730 else
16731 spec->multiout.extra_out_nid[0] = nid;
16732 /* control HP volume/switch on the output mixer amp */
16733 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16734 sprintf(name, "%s Playback Volume", pfx);
16735 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16736 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16737 if (err < 0)
16738 return err;
16739 sprintf(name, "%s Playback Switch", pfx);
16740 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16741 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16742 if (err < 0)
16743 return err;
16744 } else if (alc880_is_multi_pin(pin)) {
16745 /* set manual connection */
16746 /* we have only a switch on HP-out PIN */
16747 sprintf(name, "%s Playback Switch", pfx);
16748 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16749 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16750 if (err < 0)
16751 return err;
16752 }
16753 return 0;
16754}
16755
Takashi Iwai2d864c42009-03-20 12:52:47 +010016756/* return the index of the src widget from the connection list of the nid.
16757 * return -1 if not found
16758 */
16759static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16760 hda_nid_t src)
16761{
16762 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16763 int i, conns;
16764
16765 conns = snd_hda_get_connections(codec, nid, conn_list,
16766 ARRAY_SIZE(conn_list));
16767 if (conns < 0)
16768 return -1;
16769 for (i = 0; i < conns; i++)
16770 if (conn_list[i] == src)
16771 return i;
16772 return -1;
16773}
16774
16775static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16776{
Takashi Iwai1327a322009-03-23 13:07:47 +010016777 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016778 return (pincap & AC_PINCAP_IN) != 0;
16779}
16780
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016782static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016783 const struct auto_pin_cfg *cfg)
16784{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016785 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016786 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016787 int i, err, idx;
16788
16789 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016790 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16791 idx = alc662_input_pin_idx(codec, 0x0b,
16792 cfg->input_pins[i]);
16793 if (idx >= 0) {
16794 err = new_analog_input(spec, cfg->input_pins[i],
16795 auto_pin_cfg_labels[i],
16796 idx, 0x0b);
16797 if (err < 0)
16798 return err;
16799 }
16800 idx = alc662_input_pin_idx(codec, 0x22,
16801 cfg->input_pins[i]);
16802 if (idx >= 0) {
16803 imux->items[imux->num_items].label =
16804 auto_pin_cfg_labels[i];
16805 imux->items[imux->num_items].index = idx;
16806 imux->num_items++;
16807 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016808 }
16809 }
16810 return 0;
16811}
16812
16813static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16814 hda_nid_t nid, int pin_type,
16815 int dac_idx)
16816{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016817 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016818 /* need the manual connection? */
16819 if (alc880_is_multi_pin(nid)) {
16820 struct alc_spec *spec = codec->spec;
16821 int idx = alc880_multi_pin_idx(nid);
16822 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16823 AC_VERB_SET_CONNECT_SEL,
16824 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16825 }
16826}
16827
16828static void alc662_auto_init_multi_out(struct hda_codec *codec)
16829{
16830 struct alc_spec *spec = codec->spec;
16831 int i;
16832
Kailang Yang8c427222008-01-10 13:03:59 +010016833 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016834 for (i = 0; i <= HDA_SIDE; i++) {
16835 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016836 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016837 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016838 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016839 i);
16840 }
16841}
16842
16843static void alc662_auto_init_hp_out(struct hda_codec *codec)
16844{
16845 struct alc_spec *spec = codec->spec;
16846 hda_nid_t pin;
16847
16848 pin = spec->autocfg.hp_pins[0];
16849 if (pin) /* connect to front */
16850 /* use dac 0 */
16851 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016852 pin = spec->autocfg.speaker_pins[0];
16853 if (pin)
16854 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855}
16856
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016857#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16858
16859static void alc662_auto_init_analog_input(struct hda_codec *codec)
16860{
16861 struct alc_spec *spec = codec->spec;
16862 int i;
16863
16864 for (i = 0; i < AUTO_PIN_LAST; i++) {
16865 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016866 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016867 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016868 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016869 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016870 snd_hda_codec_write(codec, nid, 0,
16871 AC_VERB_SET_AMP_GAIN_MUTE,
16872 AMP_OUT_MUTE);
16873 }
16874 }
16875}
16876
Takashi Iwaif511b012008-08-15 16:46:42 +020016877#define alc662_auto_init_input_src alc882_auto_init_input_src
16878
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879static int alc662_parse_auto_config(struct hda_codec *codec)
16880{
16881 struct alc_spec *spec = codec->spec;
16882 int err;
16883 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16884
16885 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16886 alc662_ignore);
16887 if (err < 0)
16888 return err;
16889 if (!spec->autocfg.line_outs)
16890 return 0; /* can't find valid BIOS pin config */
16891
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016892 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16893 if (err < 0)
16894 return err;
16895 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16896 if (err < 0)
16897 return err;
16898 err = alc662_auto_create_extra_out(spec,
16899 spec->autocfg.speaker_pins[0],
16900 "Speaker");
16901 if (err < 0)
16902 return err;
16903 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16904 "Headphone");
16905 if (err < 0)
16906 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016907 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016908 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909 return err;
16910
16911 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16912
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016913 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16915
Takashi Iwai603c4012008-07-30 15:01:44 +020016916 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016917 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016918
16919 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016920 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016921
Takashi Iwaid88897e2008-10-31 15:01:37 +010016922 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016923 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016924 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016925
16926 err = alc_auto_add_mic_boost(codec);
16927 if (err < 0)
16928 return err;
16929
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016930 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016931}
16932
16933/* additional initialization for auto-configuration model */
16934static void alc662_auto_init(struct hda_codec *codec)
16935{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016936 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016937 alc662_auto_init_multi_out(codec);
16938 alc662_auto_init_hp_out(codec);
16939 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016940 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016941 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016942 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016943}
16944
16945static int patch_alc662(struct hda_codec *codec)
16946{
16947 struct alc_spec *spec;
16948 int err, board_config;
16949
16950 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16951 if (!spec)
16952 return -ENOMEM;
16953
16954 codec->spec = spec;
16955
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016956 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16957
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016958 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16959 alc662_models,
16960 alc662_cfg_tbl);
16961 if (board_config < 0) {
16962 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16963 "trying auto-probe from BIOS...\n");
16964 board_config = ALC662_AUTO;
16965 }
16966
16967 if (board_config == ALC662_AUTO) {
16968 /* automatic parse from the BIOS config */
16969 err = alc662_parse_auto_config(codec);
16970 if (err < 0) {
16971 alc_free(codec);
16972 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016973 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016974 printk(KERN_INFO
16975 "hda_codec: Cannot set up configuration "
16976 "from BIOS. Using base mode...\n");
16977 board_config = ALC662_3ST_2ch_DIG;
16978 }
16979 }
16980
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016981 err = snd_hda_attach_beep_device(codec, 0x1);
16982 if (err < 0) {
16983 alc_free(codec);
16984 return err;
16985 }
16986
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987 if (board_config != ALC662_AUTO)
16988 setup_preset(spec, &alc662_presets[board_config]);
16989
Kailang Yang6dda9f42008-05-27 12:05:31 +020016990 if (codec->vendor_id == 0x10ec0663) {
16991 spec->stream_name_analog = "ALC663 Analog";
16992 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016993 } else if (codec->vendor_id == 0x10ec0272) {
16994 spec->stream_name_analog = "ALC272 Analog";
16995 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016996 } else {
16997 spec->stream_name_analog = "ALC662 Analog";
16998 spec->stream_name_digital = "ALC662 Digital";
16999 }
17000
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017001 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17002 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17003
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017004 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17005 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17006
Takashi Iwaie1406342008-02-11 18:32:32 +010017007 spec->adc_nids = alc662_adc_nids;
17008 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17009 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017010 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017011
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017012 if (!spec->cap_mixer)
17013 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017014 if (codec->vendor_id == 0x10ec0662)
17015 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17016 else
17017 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017018
Takashi Iwai2134ea42008-01-10 16:53:55 +010017019 spec->vmaster_nid = 0x02;
17020
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017021 codec->patch_ops = alc_patch_ops;
17022 if (board_config == ALC662_AUTO)
17023 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017024#ifdef CONFIG_SND_HDA_POWER_SAVE
17025 if (!spec->loopback.amplist)
17026 spec->loopback.amplist = alc662_loopbacks;
17027#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017028 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017029
17030 return 0;
17031}
17032
17033/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017034 * patch entries
17035 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017036static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017037 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017038 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017039 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017040 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017041 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017042 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017043 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017044 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017045 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17046 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17047 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017048 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17049 .patch = patch_alc883 },
17050 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17051 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017052 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017053 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017054 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017055 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017056 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17057 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017058 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017059 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017060 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017061 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017062 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17063 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017064 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017065 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017066 {} /* terminator */
17067};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017068
17069MODULE_ALIAS("snd-hda-codec-id:10ec*");
17070
17071MODULE_LICENSE("GPL");
17072MODULE_DESCRIPTION("Realtek HD-audio codec");
17073
17074static struct hda_codec_preset_list realtek_list = {
17075 .preset = snd_hda_preset_realtek,
17076 .owner = THIS_MODULE,
17077};
17078
17079static int __init patch_realtek_init(void)
17080{
17081 return snd_hda_add_codec_preset(&realtek_list);
17082}
17083
17084static void __exit patch_realtek_exit(void)
17085{
17086 snd_hda_delete_codec_preset(&realtek_list);
17087}
17088
17089module_init(patch_realtek_init)
17090module_exit(patch_realtek_exit)