blob: 2bbb9e445cb1143061d2a9353d2f5d8c95f4aaf9 [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 Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 ALC882_MODEL_LAST,
213};
214
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215/* ALC883 models */
216enum {
217 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch,
220 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200221 ALC883_TARGA_DIG,
222 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200223 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200224 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800225 ALC888_ACER_ASPIRE_4930G,
Hector Martin3b315d72009-06-02 10:54:19 +0200226 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200227 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100229 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200230 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200231 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200232 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200233 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200235 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100236 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100237 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100238 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100239 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800240 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200241 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200242 ALC888_ASUS_M90V,
243 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200244 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100245 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200246 ALC883_AUTO,
247 ALC883_MODEL_LAST,
248};
249
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200250/* styles of capture selection */
251enum {
252 CAPT_MUX = 0, /* only mux based */
253 CAPT_MIX, /* only mixer based */
254 CAPT_1MUX_MIX, /* first mux and other mixers */
255};
256
Kailang Yangdf694da2005-12-05 19:42:22 +0100257/* for GPIO Poll */
258#define GPIO_MASK 0x03
259
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200260/* extra amp-initialization sequence types */
261enum {
262 ALC_INIT_NONE,
263 ALC_INIT_DEFAULT,
264 ALC_INIT_GPIO1,
265 ALC_INIT_GPIO2,
266 ALC_INIT_GPIO3,
267};
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269struct alc_spec {
270 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100273 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100274 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200277 * don't forget NULL
278 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200279 */
280 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200282 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 struct hda_pcm_stream *stream_analog_playback;
284 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100285 struct hda_pcm_stream *stream_analog_alt_playback;
286 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200288 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 struct hda_pcm_stream *stream_digital_playback;
290 struct hda_pcm_stream *stream_digital_capture;
291
292 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200293 struct hda_multi_out multiout; /* playback set-up
294 * max_channels, dacs must be set
295 * dig_out_nid and hp_nid are optional
296 */
Takashi Iwai63300792008-01-24 15:31:36 +0100297 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100298 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100299 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* capture */
302 unsigned int num_adc_nids;
303 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100304 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200305 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200306 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
308 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200309 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 const struct hda_input_mux *input_mux;
311 unsigned int cur_mux[3];
312
313 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100314 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200316 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200317 int const_channel_count;
318 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100321 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200322
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200323 /* dynamic controls, init_verbs and input_mux */
324 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200325 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200326 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200327 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100328
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100329 /* hooks */
330 void (*init_hook)(struct hda_codec *codec);
331 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
332
Takashi Iwai834be882006-03-01 14:16:17 +0100333 /* for pin sensing */
334 unsigned int sense_updated: 1;
335 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100336 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200337
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100338 /* other flags */
339 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200340 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100341
Takashi Iwai2134ea42008-01-10 16:53:55 +0100342 /* for virtual master */
343 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200344#ifdef CONFIG_SND_HDA_POWER_SAVE
345 struct hda_loopback_check loopback;
346#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200347
348 /* for PLL fix */
349 hda_nid_t pll_nid;
350 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100351};
352
353/*
354 * configuration template - to be copied to the spec instance
355 */
356struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200357 struct snd_kcontrol_new *mixers[5]; /* should be identical size
358 * with spec
359 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100360 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100361 const struct hda_verb *init_verbs[5];
362 unsigned int num_dacs;
363 hda_nid_t *dac_nids;
364 hda_nid_t dig_out_nid; /* optional */
365 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800366 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367 unsigned int num_adc_nids;
368 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100369 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100370 hda_nid_t dig_in_nid;
371 unsigned int num_channel_mode;
372 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200373 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200374 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200375 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100377 void (*unsol_event)(struct hda_codec *, unsigned int);
378 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200379#ifdef CONFIG_SND_HDA_POWER_SAVE
380 struct hda_amp_list *loopbacks;
381#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382};
383
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385/*
386 * input MUX handling
387 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200388static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
389 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
391 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
392 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200393 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
394 if (mux_idx >= spec->num_mux_defs)
395 mux_idx = 0;
396 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397}
398
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200399static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
400 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401{
402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
403 struct alc_spec *spec = codec->spec;
404 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
405
406 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
407 return 0;
408}
409
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200410static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
411 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
414 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100415 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100417 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100418 hda_nid_t nid = spec->capsrc_nids ?
419 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Takashi Iwaicd896c32008-11-18 12:36:33 +0100421 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
422 imux = &spec->input_mux[mux_idx];
423
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200424 if (spec->capture_style &&
425 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100426 /* Matrix-mixer style (e.g. ALC882) */
427 unsigned int *cur_val = &spec->cur_mux[adc_idx];
428 unsigned int i, idx;
429
430 idx = ucontrol->value.enumerated.item[0];
431 if (idx >= imux->num_items)
432 idx = imux->num_items - 1;
433 if (*cur_val == idx)
434 return 0;
435 for (i = 0; i < imux->num_items; i++) {
436 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
437 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
438 imux->items[i].index,
439 HDA_AMP_MUTE, v);
440 }
441 *cur_val = idx;
442 return 1;
443 } else {
444 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100445 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100446 &spec->cur_mux[adc_idx]);
447 }
448}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450/*
451 * channel mode setting
452 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_info *uinfo)
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 Iwaid2a6d7d2005-11-17 11:06:29 +0100458 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
459 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460}
461
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100467 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200469 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470}
471
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200477 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
478 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200479 &spec->ext_channel_count);
480 if (err >= 0 && !spec->const_channel_count) {
481 spec->multiout.max_channels = spec->ext_channel_count;
482 if (spec->need_dac_fix)
483 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
484 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200485 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486}
487
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200490 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491 * being part of a format specifier. Maximum allowed length of a value is
492 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100493 *
494 * Note: some retasking pin complexes seem to ignore requests for input
495 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
496 * are requested. Therefore order this list so that this behaviour will not
497 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200498 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
499 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200500 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100502 "Mic 50pc bias", "Mic 80pc bias",
503 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504};
505static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100506 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507};
508/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200509 * in the pin being assumed to be exclusively an input or an output pin. In
510 * addition, "input" pins may or may not process the mic bias option
511 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
512 * accept requests for bias as of chip versions up to March 2006) and/or
513 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200515#define ALC_PIN_DIR_IN 0x00
516#define ALC_PIN_DIR_OUT 0x01
517#define ALC_PIN_DIR_INOUT 0x02
518#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
519#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520
Kailang Yangea1fb292008-08-26 12:58:38 +0200521/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 * For each direction the minimum and maximum values are given.
523 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 { 0, 2 }, /* ALC_PIN_DIR_IN */
526 { 3, 4 }, /* ALC_PIN_DIR_OUT */
527 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200528 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
529 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530};
531#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
532#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
533#define alc_pin_mode_n_items(_dir) \
534 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
535
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200538{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100539 unsigned int item_num = uinfo->value.enumerated.item;
540 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
541
542 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
545
546 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
547 item_num = alc_pin_mode_min(dir);
548 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549 return 0;
550}
551
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100555 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_PIN_WIDGET_CONTROL,
562 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564 /* Find enumerated value for current pinctl setting */
565 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 return 0;
570}
571
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
573 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574{
575 signed int change;
576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
577 hda_nid_t nid = kcontrol->private_value & 0xffff;
578 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
579 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
581 AC_VERB_GET_PIN_WIDGET_CONTROL,
582 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200584 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 val = alc_pin_mode_min(dir);
586
587 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100588 if (change) {
589 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200590 snd_hda_codec_write_cache(codec, nid, 0,
591 AC_VERB_SET_PIN_WIDGET_CONTROL,
592 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100593
Kailang Yangea1fb292008-08-26 12:58:38 +0200594 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100595 * for the requested pin mode. Enum values of 2 or less are
596 * input modes.
597 *
598 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200599 * reduces noise slightly (particularly on input) so we'll
600 * do it. However, having both input and output buffers
601 * enabled simultaneously doesn't seem to be problematic if
602 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 */
604 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200605 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
606 HDA_AMP_MUTE, HDA_AMP_MUTE);
607 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
608 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100609 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200610 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
611 HDA_AMP_MUTE, HDA_AMP_MUTE);
612 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
613 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 }
615 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616 return change;
617}
618
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200620 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 .info = alc_pin_mode_info, \
622 .get = alc_pin_mode_get, \
623 .put = alc_pin_mode_put, \
624 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100625
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100626/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
627 * together using a mask with more than one bit set. This control is
628 * currently used only by the ALC260 test model. At this stage they are not
629 * needed for any "production" models.
630 */
631#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200632#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200633
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100636{
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 hda_nid_t nid = kcontrol->private_value & 0xffff;
639 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
640 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641 unsigned int val = snd_hda_codec_read(codec, nid, 0,
642 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100643
644 *valp = (val & mask) != 0;
645 return 0;
646}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
648 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100649{
650 signed int change;
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
652 hda_nid_t nid = kcontrol->private_value & 0xffff;
653 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
654 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
656 AC_VERB_GET_GPIO_DATA,
657 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658
659 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200660 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
661 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100662 gpio_data &= ~mask;
663 else
664 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200665 snd_hda_codec_write_cache(codec, nid, 0,
666 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667
668 return change;
669}
670#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
671 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
672 .info = alc_gpio_data_info, \
673 .get = alc_gpio_data_get, \
674 .put = alc_gpio_data_put, \
675 .private_value = nid | (mask<<16) }
676#endif /* CONFIG_SND_DEBUG */
677
Jonathan Woithe92621f12006-02-28 11:47:47 +0100678/* A switch control to allow the enabling of the digital IO pins on the
679 * ALC260. This is incredibly simplistic; the intention of this control is
680 * to provide something in the test model allowing digital outputs to be
681 * identified if present. If models are found which can utilise these
682 * outputs a more complete mixer control can be devised for those models if
683 * necessary.
684 */
685#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200686#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200687
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200688static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
689 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100690{
691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
692 hda_nid_t nid = kcontrol->private_value & 0xffff;
693 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
694 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200695 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100696 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100697
698 *valp = (val & mask) != 0;
699 return 0;
700}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703{
704 signed int change;
705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
706 hda_nid_t nid = kcontrol->private_value & 0xffff;
707 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
708 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100710 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100712
713 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715 if (val==0)
716 ctrl_data &= ~mask;
717 else
718 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200719 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
720 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100721
722 return change;
723}
724#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
725 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
726 .info = alc_spdif_ctrl_info, \
727 .get = alc_spdif_ctrl_get, \
728 .put = alc_spdif_ctrl_put, \
729 .private_value = nid | (mask<<16) }
730#endif /* CONFIG_SND_DEBUG */
731
Jonathan Woithef8225f62008-01-08 12:16:54 +0100732/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
733 * Again, this is only used in the ALC26x test models to help identify when
734 * the EAPD line must be asserted for features to work.
735 */
736#ifdef CONFIG_SND_DEBUG
737#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
738
739static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
740 struct snd_ctl_elem_value *ucontrol)
741{
742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
743 hda_nid_t nid = kcontrol->private_value & 0xffff;
744 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
745 long *valp = ucontrol->value.integer.value;
746 unsigned int val = snd_hda_codec_read(codec, nid, 0,
747 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
748
749 *valp = (val & mask) != 0;
750 return 0;
751}
752
753static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
755{
756 int change;
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 hda_nid_t nid = kcontrol->private_value & 0xffff;
759 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
760 long val = *ucontrol->value.integer.value;
761 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
762 AC_VERB_GET_EAPD_BTLENABLE,
763 0x00);
764
765 /* Set/unset the masked control bit(s) as needed */
766 change = (!val ? 0 : mask) != (ctrl_data & mask);
767 if (!val)
768 ctrl_data &= ~mask;
769 else
770 ctrl_data |= mask;
771 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
772 ctrl_data);
773
774 return change;
775}
776
777#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
778 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
779 .info = alc_eapd_ctrl_info, \
780 .get = alc_eapd_ctrl_get, \
781 .put = alc_eapd_ctrl_put, \
782 .private_value = nid | (mask<<16) }
783#endif /* CONFIG_SND_DEBUG */
784
Kailang Yangdf694da2005-12-05 19:42:22 +0100785/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100786 * set up the input pin config (depending on the given auto-pin type)
787 */
788static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
789 int auto_pin_type)
790{
791 unsigned int val = PIN_IN;
792
793 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
794 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100795 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100796 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
797 if (pincap & AC_PINCAP_VREF_80)
798 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200799 else if (pincap & AC_PINCAP_VREF_50)
800 val = PIN_VREF50;
801 else if (pincap & AC_PINCAP_VREF_100)
802 val = PIN_VREF100;
803 else if (pincap & AC_PINCAP_VREF_GRD)
804 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100805 }
806 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
807}
808
809/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100810 */
811static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
812{
813 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
814 return;
815 spec->mixers[spec->num_mixers++] = mix;
816}
817
818static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
819{
820 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
821 return;
822 spec->init_verbs[spec->num_init_verbs++] = verb;
823}
824
Takashi Iwaidaead532008-11-28 12:55:36 +0100825#ifdef CONFIG_PROC_FS
826/*
827 * hook for proc
828 */
829static void print_realtek_coef(struct snd_info_buffer *buffer,
830 struct hda_codec *codec, hda_nid_t nid)
831{
832 int coeff;
833
834 if (nid != 0x20)
835 return;
836 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
837 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
838 coeff = snd_hda_codec_read(codec, nid, 0,
839 AC_VERB_GET_COEF_INDEX, 0);
840 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
841}
842#else
843#define print_realtek_coef NULL
844#endif
845
Takashi Iwaid88897e2008-10-31 15:01:37 +0100846/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100847 * set up from the preset table
848 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200849static void setup_preset(struct alc_spec *spec,
850 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100851{
852 int i;
853
854 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100855 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100856 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200857 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
858 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100859 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200860
Kailang Yangdf694da2005-12-05 19:42:22 +0100861 spec->channel_mode = preset->channel_mode;
862 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200863 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200864 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100865
Hector Martin3b315d72009-06-02 10:54:19 +0200866 if (preset->const_channel_count)
867 spec->multiout.max_channels = preset->const_channel_count;
868 else
869 spec->multiout.max_channels = spec->channel_mode[0].channels;
870 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100871
872 spec->multiout.num_dacs = preset->num_dacs;
873 spec->multiout.dac_nids = preset->dac_nids;
874 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800875 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100876 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200877
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200878 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200879 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200880 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881 spec->input_mux = preset->input_mux;
882
883 spec->num_adc_nids = preset->num_adc_nids;
884 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100885 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100887
888 spec->unsol_event = preset->unsol_event;
889 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200890#ifdef CONFIG_SND_HDA_POWER_SAVE
891 spec->loopback.amplist = preset->loopbacks;
892#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100893}
894
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200895/* Enable GPIO mask and set output */
896static struct hda_verb alc_gpio1_init_verbs[] = {
897 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
898 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
899 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
900 { }
901};
902
903static struct hda_verb alc_gpio2_init_verbs[] = {
904 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
905 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
906 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
907 { }
908};
909
Kailang Yangbdd148a2007-05-08 15:19:08 +0200910static struct hda_verb alc_gpio3_init_verbs[] = {
911 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
912 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
913 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
914 { }
915};
916
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200917/*
918 * Fix hardware PLL issue
919 * On some codecs, the analog PLL gating control must be off while
920 * the default value is 1.
921 */
922static void alc_fix_pll(struct hda_codec *codec)
923{
924 struct alc_spec *spec = codec->spec;
925 unsigned int val;
926
927 if (!spec->pll_nid)
928 return;
929 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
930 spec->pll_coef_idx);
931 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
932 AC_VERB_GET_PROC_COEF, 0);
933 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
934 spec->pll_coef_idx);
935 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
936 val & ~(1 << spec->pll_coef_bit));
937}
938
939static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
940 unsigned int coef_idx, unsigned int coef_bit)
941{
942 struct alc_spec *spec = codec->spec;
943 spec->pll_nid = nid;
944 spec->pll_coef_idx = coef_idx;
945 spec->pll_coef_bit = coef_bit;
946 alc_fix_pll(codec);
947}
948
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200949static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200950{
951 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200952 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200953 unsigned int nid = spec->autocfg.hp_pins[0];
954 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200955
956 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200957 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
958 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200959 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
961 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
962 nid = spec->autocfg.speaker_pins[i];
963 if (!nid)
964 break;
965 snd_hda_codec_write(codec, nid, 0,
966 AC_VERB_SET_PIN_WIDGET_CONTROL,
967 spec->jack_present ? 0 : PIN_OUT);
968 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200969}
970
Takashi Iwai4605b712008-10-31 14:18:24 +0100971#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200972static void alc_mic_automute(struct hda_codec *codec)
973{
974 struct alc_spec *spec = codec->spec;
975 unsigned int present;
976 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
977 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
978 unsigned int mix_nid = spec->capsrc_nids[0];
979 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
980
981 capsrc_idx_mic = mic_nid - 0x18;
982 capsrc_idx_fmic = fmic_nid - 0x18;
983 present = snd_hda_codec_read(codec, mic_nid, 0,
984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
985 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
986 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
987 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
988 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
989 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
990 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
991}
Takashi Iwai4605b712008-10-31 14:18:24 +0100992#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100993#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100994#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200995
Kailang Yangc9b58002007-10-16 14:30:01 +0200996/* unsolicited event for HP jack sensing */
997static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
998{
999 if (codec->vendor_id == 0x10ec0880)
1000 res >>= 28;
1001 else
1002 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001003 switch (res) {
1004 case ALC880_HP_EVENT:
1005 alc_automute_pin(codec);
1006 break;
1007 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001008 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001009 break;
1010 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001011}
1012
1013static void alc_inithook(struct hda_codec *codec)
1014{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001015 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001016 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001017}
1018
Kailang Yangf9423e72008-05-27 12:32:25 +02001019/* additional initialization for ALC888 variants */
1020static void alc888_coef_init(struct hda_codec *codec)
1021{
1022 unsigned int tmp;
1023
1024 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1025 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1026 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001027 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001028 /* alc888S-VC */
1029 snd_hda_codec_read(codec, 0x20, 0,
1030 AC_VERB_SET_PROC_COEF, 0x830);
1031 else
1032 /* alc888-VB */
1033 snd_hda_codec_read(codec, 0x20, 0,
1034 AC_VERB_SET_PROC_COEF, 0x3030);
1035}
1036
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001037static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001038{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001039 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001040
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001041 switch (type) {
1042 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001043 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1044 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001045 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001046 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1047 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001048 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001049 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1050 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001051 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001052 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001053 case 0x10ec0260:
1054 snd_hda_codec_write(codec, 0x0f, 0,
1055 AC_VERB_SET_EAPD_BTLENABLE, 2);
1056 snd_hda_codec_write(codec, 0x10, 0,
1057 AC_VERB_SET_EAPD_BTLENABLE, 2);
1058 break;
1059 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001060 case 0x10ec0267:
1061 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001062 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001063 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001064 case 0x10ec0660:
1065 case 0x10ec0662:
1066 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001067 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001068 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001069 snd_hda_codec_write(codec, 0x14, 0,
1070 AC_VERB_SET_EAPD_BTLENABLE, 2);
1071 snd_hda_codec_write(codec, 0x15, 0,
1072 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001073 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001074 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001075 switch (codec->vendor_id) {
1076 case 0x10ec0260:
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_COEF_INDEX, 7);
1079 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1080 AC_VERB_GET_PROC_COEF, 0);
1081 snd_hda_codec_write(codec, 0x1a, 0,
1082 AC_VERB_SET_COEF_INDEX, 7);
1083 snd_hda_codec_write(codec, 0x1a, 0,
1084 AC_VERB_SET_PROC_COEF,
1085 tmp | 0x2010);
1086 break;
1087 case 0x10ec0262:
1088 case 0x10ec0880:
1089 case 0x10ec0882:
1090 case 0x10ec0883:
1091 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001092 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001093 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001094 snd_hda_codec_write(codec, 0x20, 0,
1095 AC_VERB_SET_COEF_INDEX, 7);
1096 tmp = snd_hda_codec_read(codec, 0x20, 0,
1097 AC_VERB_GET_PROC_COEF, 0);
1098 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001099 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 snd_hda_codec_write(codec, 0x20, 0,
1101 AC_VERB_SET_PROC_COEF,
1102 tmp | 0x2010);
1103 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001104 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001106 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001107 case 0x10ec0267:
1108 case 0x10ec0268:
1109 snd_hda_codec_write(codec, 0x20, 0,
1110 AC_VERB_SET_COEF_INDEX, 7);
1111 tmp = snd_hda_codec_read(codec, 0x20, 0,
1112 AC_VERB_GET_PROC_COEF, 0);
1113 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001114 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 snd_hda_codec_write(codec, 0x20, 0,
1116 AC_VERB_SET_PROC_COEF,
1117 tmp | 0x3000);
1118 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001119 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001120 break;
1121 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001122}
Kailang Yangea1fb292008-08-26 12:58:38 +02001123
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001124static void alc_init_auto_hp(struct hda_codec *codec)
1125{
1126 struct alc_spec *spec = codec->spec;
1127
1128 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001130
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001132 if (spec->autocfg.line_out_pins[0] &&
1133 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001135 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001136 else
1137 return;
1138 }
1139
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001140 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1141 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001142 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1143 AC_VERB_SET_UNSOLICITED_ENABLE,
1144 AC_USRSP_EN | ALC880_HP_EVENT);
1145 spec->unsol_event = alc_sku_unsol_event;
1146}
1147
1148/* check subsystem ID and set up device-specific initialization;
1149 * return 1 if initialized, 0 if invalid SSID
1150 */
1151/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1152 * 31 ~ 16 : Manufacture ID
1153 * 15 ~ 8 : SKU ID
1154 * 7 ~ 0 : Assembly ID
1155 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1156 */
1157static int alc_subsystem_id(struct hda_codec *codec,
1158 hda_nid_t porta, hda_nid_t porte,
1159 hda_nid_t portd)
1160{
1161 unsigned int ass, tmp, i;
1162 unsigned nid;
1163 struct alc_spec *spec = codec->spec;
1164
1165 ass = codec->subsystem_id & 0xffff;
1166 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1167 goto do_sku;
1168
1169 /* invalid SSID, check the special NID pin defcfg instead */
1170 /*
1171 * 31~30 : port conetcivity
1172 * 29~21 : reserve
1173 * 20 : PCBEEP input
1174 * 19~16 : Check sum (15:1)
1175 * 15~1 : Custom
1176 * 0 : override
1177 */
1178 nid = 0x1d;
1179 if (codec->vendor_id == 0x10ec0260)
1180 nid = 0x17;
1181 ass = snd_hda_codec_get_pincfg(codec, nid);
1182 snd_printd("realtek: No valid SSID, "
1183 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001184 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001185 if (!(ass & 1) && !(ass & 0x100000))
1186 return 0;
1187 if ((ass >> 30) != 1) /* no physical connection */
1188 return 0;
1189
1190 /* check sum */
1191 tmp = 0;
1192 for (i = 1; i < 16; i++) {
1193 if ((ass >> i) & 1)
1194 tmp++;
1195 }
1196 if (((ass >> 16) & 0xf) != tmp)
1197 return 0;
1198do_sku:
1199 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1200 ass & 0xffff, codec->vendor_id);
1201 /*
1202 * 0 : override
1203 * 1 : Swap Jack
1204 * 2 : 0 --> Desktop, 1 --> Laptop
1205 * 3~5 : External Amplifier control
1206 * 7~6 : Reserved
1207 */
1208 tmp = (ass & 0x38) >> 3; /* external Amp control */
1209 switch (tmp) {
1210 case 1:
1211 spec->init_amp = ALC_INIT_GPIO1;
1212 break;
1213 case 3:
1214 spec->init_amp = ALC_INIT_GPIO2;
1215 break;
1216 case 7:
1217 spec->init_amp = ALC_INIT_GPIO3;
1218 break;
1219 case 5:
1220 spec->init_amp = ALC_INIT_DEFAULT;
1221 break;
1222 }
1223
1224 /* is laptop or Desktop and enable the function "Mute internal speaker
1225 * when the external headphone out jack is plugged"
1226 */
1227 if (!(ass & 0x8000))
1228 return 1;
1229 /*
1230 * 10~8 : Jack location
1231 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1232 * 14~13: Resvered
1233 * 15 : 1 --> enable the function "Mute internal speaker
1234 * when the external headphone out jack is plugged"
1235 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001236 if (!spec->autocfg.hp_pins[0]) {
1237 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1238 if (tmp == 0)
1239 spec->autocfg.hp_pins[0] = porta;
1240 else if (tmp == 1)
1241 spec->autocfg.hp_pins[0] = porte;
1242 else if (tmp == 2)
1243 spec->autocfg.hp_pins[0] = portd;
1244 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001246 }
1247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248 alc_init_auto_hp(codec);
1249 return 1;
1250}
Kailang Yangea1fb292008-08-26 12:58:38 +02001251
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001252static void alc_ssid_check(struct hda_codec *codec,
1253 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1254{
1255 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1256 struct alc_spec *spec = codec->spec;
1257 snd_printd("realtek: "
1258 "Enable default setup for auto mode as fallback\n");
1259 spec->init_amp = ALC_INIT_DEFAULT;
1260 alc_init_auto_hp(codec);
1261 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001262}
1263
Takashi Iwai41e41f12005-06-08 14:48:49 +02001264/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001265 * Fix-up pin default configurations
1266 */
1267
1268struct alc_pincfg {
1269 hda_nid_t nid;
1270 u32 val;
1271};
1272
1273static void alc_fix_pincfg(struct hda_codec *codec,
1274 const struct snd_pci_quirk *quirk,
1275 const struct alc_pincfg **pinfix)
1276{
1277 const struct alc_pincfg *cfg;
1278
1279 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1280 if (!quirk)
1281 return;
1282
1283 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001284 for (; cfg->nid; cfg++)
1285 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001286}
1287
1288/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001289 * ALC888
1290 */
1291
1292/*
1293 * 2ch mode
1294 */
1295static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1296/* Mic-in jack as mic in */
1297 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1298 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1299/* Line-in jack as Line in */
1300 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1301 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1302/* Line-Out as Front */
1303 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1304 { } /* end */
1305};
1306
1307/*
1308 * 4ch mode
1309 */
1310static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1311/* Mic-in jack as mic in */
1312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1314/* Line-in jack as Surround */
1315 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1316 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1317/* Line-Out as Front */
1318 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1319 { } /* end */
1320};
1321
1322/*
1323 * 6ch mode
1324 */
1325static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1326/* Mic-in jack as CLFE */
1327 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1328 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1329/* Line-in jack as Surround */
1330 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1331 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1332/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1333 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1334 { } /* end */
1335};
1336
1337/*
1338 * 8ch mode
1339 */
1340static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1341/* Mic-in jack as CLFE */
1342 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1343 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1344/* Line-in jack as Surround */
1345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1347/* Line-Out as Side */
1348 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1349 { } /* end */
1350};
1351
1352static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1353 { 2, alc888_4ST_ch2_intel_init },
1354 { 4, alc888_4ST_ch4_intel_init },
1355 { 6, alc888_4ST_ch6_intel_init },
1356 { 8, alc888_4ST_ch8_intel_init },
1357};
1358
1359/*
1360 * ALC888 Fujitsu Siemens Amillo xa3530
1361 */
1362
1363static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1364/* Front Mic: set to PIN_IN (empty by default) */
1365 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1366/* Connect Internal HP to Front */
1367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1370/* Connect Bass HP to Front */
1371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1374/* Connect Line-Out side jack (SPDIF) to Side */
1375 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1377 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1378/* Connect Mic jack to CLFE */
1379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1382/* Connect Line-in jack to Surround */
1383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1385 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1386/* Connect HP out jack to Front */
1387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1388 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1389 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1390/* Enable unsolicited event for HP jack and Line-out jack */
1391 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1392 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1393 {}
1394};
1395
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001396static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001398 struct alc_spec *spec = codec->spec;
1399 unsigned int val, mute;
1400 hda_nid_t nid;
1401 int i;
1402
1403 spec->jack_present = 0;
1404 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1405 nid = spec->autocfg.hp_pins[i];
1406 if (!nid)
1407 break;
1408 val = snd_hda_codec_read(codec, nid, 0,
1409 AC_VERB_GET_PIN_SENSE, 0);
1410 if (val & AC_PINSENSE_PRESENCE) {
1411 spec->jack_present = 1;
1412 break;
1413 }
1414 }
1415
1416 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001417 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001418 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1419 nid = spec->autocfg.speaker_pins[i];
1420 if (!nid)
1421 break;
1422 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1423 HDA_AMP_MUTE, mute);
1424 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001425}
1426
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001427static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1428 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001429{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001430 if (codec->vendor_id == 0x10ec0880)
1431 res >>= 28;
1432 else
1433 res >>= 26;
1434 if (res == ALC880_HP_EVENT)
1435 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001436}
1437
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001438static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1439{
1440 struct alc_spec *spec = codec->spec;
1441
1442 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1443 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1444 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1445 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1446 alc_automute_amp(codec);
1447}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001448
1449/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001450 * ALC888 Acer Aspire 4930G model
1451 */
1452
1453static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1454/* Front Mic: set to PIN_IN (empty by default) */
1455 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1456/* Unselect Front Mic by default in input mixer 3 */
1457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001458/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001459 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1460/* Connect Internal HP to front */
1461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1464/* Connect HP out to front */
1465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1468 { }
1469};
1470
Hector Martin3b315d72009-06-02 10:54:19 +02001471/*
1472 * ALC888 Acer Aspire 8930G model
1473 */
1474
1475static struct hda_verb alc888_acer_aspire_8930g_verbs[] = {
1476/* Front Mic: set to PIN_IN (empty by default) */
1477 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1478/* Unselect Front Mic by default in input mixer 3 */
1479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1480/* Enable unsolicited event for HP jack */
1481 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1482/* Connect Internal Front to Front */
1483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1486/* Connect Internal Rear to Rear */
1487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1490/* Connect Internal CLFE to CLFE */
1491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1494/* Connect HP out to Front */
1495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1498/* Enable all DACs */
1499/* DAC DISABLE/MUTE 1? */
1500/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1501 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1502 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1503/* DAC DISABLE/MUTE 2? */
1504/* some bit here disables the other DACs. Init=0x4900 */
1505 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1506 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1507/* Enable amplifiers */
1508 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1509 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1510 { }
1511};
1512
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001513static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001514 /* Front mic only available on one ADC */
1515 {
1516 .num_items = 4,
1517 .items = {
1518 { "Mic", 0x0 },
1519 { "Line", 0x2 },
1520 { "CD", 0x4 },
1521 { "Front Mic", 0xb },
1522 },
1523 },
1524 {
1525 .num_items = 3,
1526 .items = {
1527 { "Mic", 0x0 },
1528 { "Line", 0x2 },
1529 { "CD", 0x4 },
1530 },
1531 }
1532};
1533
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001534static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1536 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1537 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1538 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1539 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1540 HDA_OUTPUT),
1541 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1542 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1543 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1544 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1545 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1551 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001553 { } /* end */
1554};
1555
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001556static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001557{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001558 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001559
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001560 spec->autocfg.hp_pins[0] = 0x15;
1561 spec->autocfg.speaker_pins[0] = 0x14;
1562 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001563}
1564
Hector Martin3b315d72009-06-02 10:54:19 +02001565static void alc888_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1566{
1567 struct alc_spec *spec = codec->spec;
1568
1569 spec->autocfg.hp_pins[0] = 0x15;
1570 spec->autocfg.speaker_pins[0] = 0x14;
1571 spec->autocfg.speaker_pins[1] = 0x16;
1572 spec->autocfg.speaker_pins[2] = 0x1b;
1573 alc_automute_amp(codec);
1574}
1575
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001576/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001577 * ALC880 3-stack model
1578 *
1579 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001580 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1581 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 */
1583
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001584static hda_nid_t alc880_dac_nids[4] = {
1585 /* front, rear, clfe, rear_surr */
1586 0x02, 0x05, 0x04, 0x03
1587};
1588
1589static hda_nid_t alc880_adc_nids[3] = {
1590 /* ADC0-2 */
1591 0x07, 0x08, 0x09,
1592};
1593
1594/* The datasheet says the node 0x07 is connected from inputs,
1595 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001596 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001598static hda_nid_t alc880_adc_nids_alt[2] = {
1599 /* ADC1-2 */
1600 0x08, 0x09,
1601};
1602
1603#define ALC880_DIGOUT_NID 0x06
1604#define ALC880_DIGIN_NID 0x0a
1605
1606static struct hda_input_mux alc880_capture_source = {
1607 .num_items = 4,
1608 .items = {
1609 { "Mic", 0x0 },
1610 { "Front Mic", 0x3 },
1611 { "Line", 0x2 },
1612 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001614};
1615
1616/* channel source setting (2/6 channel selection for 3-stack) */
1617/* 2ch mode */
1618static struct hda_verb alc880_threestack_ch2_init[] = {
1619 /* set line-in to input, mute it */
1620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1622 /* set mic-in to input vref 80%, mute it */
1623 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1624 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 { } /* end */
1626};
1627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001628/* 6ch mode */
1629static struct hda_verb alc880_threestack_ch6_init[] = {
1630 /* set line-in to output, unmute it */
1631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1633 /* set mic-in to output, unmute it */
1634 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1635 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1636 { } /* end */
1637};
1638
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001639static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001640 { 2, alc880_threestack_ch2_init },
1641 { 6, alc880_threestack_ch6_init },
1642};
1643
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001644static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001648 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001651 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1652 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001662 {
1663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1664 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001665 .info = alc_ch_mode_info,
1666 .get = alc_ch_mode_get,
1667 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001668 },
1669 { } /* end */
1670};
1671
1672/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001673static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1674 struct snd_ctl_elem_info *uinfo)
1675{
1676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1677 struct alc_spec *spec = codec->spec;
1678 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001680 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001681 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1682 HDA_INPUT);
1683 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001684 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001685 return err;
1686}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001688static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1689 unsigned int size, unsigned int __user *tlv)
1690{
1691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1692 struct alc_spec *spec = codec->spec;
1693 int err;
1694
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001695 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001696 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1697 HDA_INPUT);
1698 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001699 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001700 return err;
1701}
1702
1703typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1704 struct snd_ctl_elem_value *ucontrol);
1705
1706static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1707 struct snd_ctl_elem_value *ucontrol,
1708 getput_call_t func)
1709{
1710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1711 struct alc_spec *spec = codec->spec;
1712 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1713 int err;
1714
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001715 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001716 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1717 3, 0, HDA_INPUT);
1718 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001719 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001720 return err;
1721}
1722
1723static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1724 struct snd_ctl_elem_value *ucontrol)
1725{
1726 return alc_cap_getput_caller(kcontrol, ucontrol,
1727 snd_hda_mixer_amp_volume_get);
1728}
1729
1730static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1731 struct snd_ctl_elem_value *ucontrol)
1732{
1733 return alc_cap_getput_caller(kcontrol, ucontrol,
1734 snd_hda_mixer_amp_volume_put);
1735}
1736
1737/* capture mixer elements */
1738#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1739
1740static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1741 struct snd_ctl_elem_value *ucontrol)
1742{
1743 return alc_cap_getput_caller(kcontrol, ucontrol,
1744 snd_hda_mixer_amp_switch_get);
1745}
1746
1747static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1748 struct snd_ctl_elem_value *ucontrol)
1749{
1750 return alc_cap_getput_caller(kcontrol, ucontrol,
1751 snd_hda_mixer_amp_switch_put);
1752}
1753
Takashi Iwaia23b6882009-03-23 15:21:36 +01001754#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001755 { \
1756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1757 .name = "Capture Switch", \
1758 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1759 .count = num, \
1760 .info = alc_cap_sw_info, \
1761 .get = alc_cap_sw_get, \
1762 .put = alc_cap_sw_put, \
1763 }, \
1764 { \
1765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1766 .name = "Capture Volume", \
1767 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1768 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1769 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1770 .count = num, \
1771 .info = alc_cap_vol_info, \
1772 .get = alc_cap_vol_get, \
1773 .put = alc_cap_vol_put, \
1774 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001775 }
1776
1777#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001778 { \
1779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1780 /* .name = "Capture Source", */ \
1781 .name = "Input Source", \
1782 .count = num, \
1783 .info = alc_mux_enum_info, \
1784 .get = alc_mux_enum_get, \
1785 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001786 }
1787
1788#define DEFINE_CAPMIX(num) \
1789static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1790 _DEFINE_CAPMIX(num), \
1791 _DEFINE_CAPSRC(num), \
1792 { } /* end */ \
1793}
1794
1795#define DEFINE_CAPMIX_NOSRC(num) \
1796static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1797 _DEFINE_CAPMIX(num), \
1798 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001799}
1800
1801/* up to three ADCs */
1802DEFINE_CAPMIX(1);
1803DEFINE_CAPMIX(2);
1804DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001805DEFINE_CAPMIX_NOSRC(1);
1806DEFINE_CAPMIX_NOSRC(2);
1807DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808
1809/*
1810 * ALC880 5-stack model
1811 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001812 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1813 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1815 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1816 */
1817
1818/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001819static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001821 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 { } /* end */
1823};
1824
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825/* channel source setting (6/8 channel selection for 5-stack) */
1826/* 6ch mode */
1827static struct hda_verb alc880_fivestack_ch6_init[] = {
1828 /* set line-in to input, mute it */
1829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001831 { } /* end */
1832};
1833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834/* 8ch mode */
1835static struct hda_verb alc880_fivestack_ch8_init[] = {
1836 /* set line-in to output, unmute it */
1837 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1838 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1839 { } /* end */
1840};
1841
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001842static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001843 { 6, alc880_fivestack_ch6_init },
1844 { 8, alc880_fivestack_ch8_init },
1845};
1846
1847
1848/*
1849 * ALC880 6-stack model
1850 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001851 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1852 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001853 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1854 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1855 */
1856
1857static hda_nid_t alc880_6st_dac_nids[4] = {
1858 /* front, rear, clfe, rear_surr */
1859 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001860};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861
1862static struct hda_input_mux alc880_6stack_capture_source = {
1863 .num_items = 4,
1864 .items = {
1865 { "Mic", 0x0 },
1866 { "Front Mic", 0x1 },
1867 { "Line", 0x2 },
1868 { "CD", 0x4 },
1869 },
1870};
1871
1872/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001873static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874 { 8, NULL },
1875};
1876
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001877static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001880 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001881 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001882 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001884 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1885 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001886 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001887 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001896 {
1897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1898 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001899 .info = alc_ch_mode_info,
1900 .get = alc_ch_mode_get,
1901 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001902 },
1903 { } /* end */
1904};
1905
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001906
1907/*
1908 * ALC880 W810 model
1909 *
1910 * W810 has rear IO for:
1911 * Front (DAC 02)
1912 * Surround (DAC 03)
1913 * Center/LFE (DAC 04)
1914 * Digital out (06)
1915 *
1916 * The system also has a pair of internal speakers, and a headphone jack.
1917 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001918 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001919 * There is a variable resistor to control the speaker or headphone
1920 * volume. This is a hardware-only device without a software API.
1921 *
1922 * Plugging headphones in will disable the internal speakers. This is
1923 * implemented in hardware, not via the driver using jack sense. In
1924 * a similar fashion, plugging into the rear socket marked "front" will
1925 * disable both the speakers and headphones.
1926 *
1927 * For input, there's a microphone jack, and an "audio in" jack.
1928 * These may not do anything useful with this driver yet, because I
1929 * haven't setup any initialization verbs for these yet...
1930 */
1931
1932static hda_nid_t alc880_w810_dac_nids[3] = {
1933 /* front, rear/surround, clfe */
1934 0x02, 0x03, 0x04
1935};
1936
1937/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001938static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001939 { 6, NULL }
1940};
1941
1942/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001943static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001946 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001947 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1949 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001950 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1951 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1953 { } /* end */
1954};
1955
1956
1957/*
1958 * Z710V model
1959 *
1960 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001961 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1962 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001963 */
1964
1965static hda_nid_t alc880_z71v_dac_nids[1] = {
1966 0x02
1967};
1968#define ALC880_Z71V_HP_DAC 0x03
1969
1970/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001971static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972 { 2, NULL }
1973};
1974
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001975static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001977 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001979 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1984 { } /* end */
1985};
1986
1987
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001988/*
1989 * ALC880 F1734 model
1990 *
1991 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1992 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1993 */
1994
1995static hda_nid_t alc880_f1734_dac_nids[1] = {
1996 0x03
1997};
1998#define ALC880_F1734_HP_DAC 0x02
1999
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002000static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002002 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002003 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2004 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002009 { } /* end */
2010};
2011
Takashi Iwai937b4162008-02-11 14:52:36 +01002012static struct hda_input_mux alc880_f1734_capture_source = {
2013 .num_items = 2,
2014 .items = {
2015 { "Mic", 0x1 },
2016 { "CD", 0x4 },
2017 },
2018};
2019
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002021/*
2022 * ALC880 ASUS model
2023 *
2024 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2025 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2026 * Mic = 0x18, Line = 0x1a
2027 */
2028
2029#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2030#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2031
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002032static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002035 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002036 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002047 {
2048 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2049 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002050 .info = alc_ch_mode_info,
2051 .get = alc_ch_mode_get,
2052 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002053 },
2054 { } /* end */
2055};
2056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057/*
2058 * ALC880 ASUS W1V model
2059 *
2060 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2061 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2062 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2063 */
2064
2065/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002066static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002067 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2068 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002069 { } /* end */
2070};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071
Kailang Yangdf694da2005-12-05 19:42:22 +01002072/* TCL S700 */
2073static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2075 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2078 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2081 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2082 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002083 { } /* end */
2084};
2085
Kailang Yangccc656c2006-10-17 12:32:26 +02002086/* Uniwill */
2087static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2089 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2090 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2091 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002092 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2093 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2094 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2095 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002104 {
2105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2106 .name = "Channel Mode",
2107 .info = alc_ch_mode_info,
2108 .get = alc_ch_mode_get,
2109 .put = alc_ch_mode_put,
2110 },
2111 { } /* end */
2112};
2113
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002114static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2116 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2117 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2118 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2122 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2124 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2125 { } /* end */
2126};
2127
Kailang Yangccc656c2006-10-17 12:32:26 +02002128static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2130 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2132 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2135 { } /* end */
2136};
2137
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002139 * virtual master controls
2140 */
2141
2142/*
2143 * slave controls for virtual master
2144 */
2145static const char *alc_slave_vols[] = {
2146 "Front Playback Volume",
2147 "Surround Playback Volume",
2148 "Center Playback Volume",
2149 "LFE Playback Volume",
2150 "Side Playback Volume",
2151 "Headphone Playback Volume",
2152 "Speaker Playback Volume",
2153 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002154 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002155 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002156 NULL,
2157};
2158
2159static const char *alc_slave_sws[] = {
2160 "Front Playback Switch",
2161 "Surround Playback Switch",
2162 "Center Playback Switch",
2163 "LFE Playback Switch",
2164 "Side Playback Switch",
2165 "Headphone Playback Switch",
2166 "Speaker Playback Switch",
2167 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002168 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002169 NULL,
2170};
2171
2172/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002175
2176static void alc_free_kctls(struct hda_codec *codec);
2177
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002178/* additional beep mixers; the actual parameters are overwritten at build */
2179static struct snd_kcontrol_new alc_beep_mixer[] = {
2180 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2181 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2182 { } /* end */
2183};
2184
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185static int alc_build_controls(struct hda_codec *codec)
2186{
2187 struct alc_spec *spec = codec->spec;
2188 int err;
2189 int i;
2190
2191 for (i = 0; i < spec->num_mixers; i++) {
2192 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2193 if (err < 0)
2194 return err;
2195 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002196 if (spec->cap_mixer) {
2197 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2198 if (err < 0)
2199 return err;
2200 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002202 err = snd_hda_create_spdif_out_ctls(codec,
2203 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 if (err < 0)
2205 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002206 if (!spec->no_analog) {
2207 err = snd_hda_create_spdif_share_sw(codec,
2208 &spec->multiout);
2209 if (err < 0)
2210 return err;
2211 spec->multiout.share_spdif = 1;
2212 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213 }
2214 if (spec->dig_in_nid) {
2215 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2216 if (err < 0)
2217 return err;
2218 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002219
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002220 /* create beep controls if needed */
2221 if (spec->beep_amp) {
2222 struct snd_kcontrol_new *knew;
2223 for (knew = alc_beep_mixer; knew->name; knew++) {
2224 struct snd_kcontrol *kctl;
2225 kctl = snd_ctl_new1(knew, codec);
2226 if (!kctl)
2227 return -ENOMEM;
2228 kctl->private_value = spec->beep_amp;
2229 err = snd_hda_ctl_add(codec, kctl);
2230 if (err < 0)
2231 return err;
2232 }
2233 }
2234
Takashi Iwai2134ea42008-01-10 16:53:55 +01002235 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002236 if (!spec->no_analog &&
2237 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002238 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002239 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002240 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002241 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002242 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002243 if (err < 0)
2244 return err;
2245 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002246 if (!spec->no_analog &&
2247 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002248 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2249 NULL, alc_slave_sws);
2250 if (err < 0)
2251 return err;
2252 }
2253
Takashi Iwai603c4012008-07-30 15:01:44 +02002254 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 return 0;
2256}
2257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002258
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259/*
2260 * initialize the codec volumes, etc
2261 */
2262
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263/*
2264 * generic initialization of ADC, input mixers and output mixers
2265 */
2266static struct hda_verb alc880_volume_init_verbs[] = {
2267 /*
2268 * Unmute ADC0-2 and set the default input to mic-in
2269 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002270 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002272 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002274 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2278 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002279 * Note: PASD motherboards uses the Line In 2 as the input for front
2280 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291 /*
2292 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002294 /* set vol=0 to output mixers */
2295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2298 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2299 /* set up input amps for analog loopback */
2300 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002303 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002305 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309
2310 { }
2311};
2312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002313/*
2314 * 3-stack pin configuration:
2315 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2316 */
2317static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2318 /*
2319 * preset connection lists of input pins
2320 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2321 */
2322 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2323 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2324 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2325
2326 /*
2327 * Set pin mode and muting
2328 */
2329 /* set front pin widgets 0x14 for output */
2330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2332 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2334 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2335 /* Mic2 (as headphone out) for HP output */
2336 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2338 /* Line In pin widget for input */
2339 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2341 /* Line2 (as front mic) pin widget for input and vref at 80% */
2342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2344 /* CD pin widget for input */
2345 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2346
2347 { }
2348};
2349
2350/*
2351 * 5-stack pin configuration:
2352 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2353 * line-in/side = 0x1a, f-mic = 0x1b
2354 */
2355static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2356 /*
2357 * preset connection lists of input pins
2358 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2359 */
2360 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2361 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2362
2363 /*
2364 * Set pin mode and muting
2365 */
2366 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2370 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371 /* unmute pins for output (no gain on this amp) */
2372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2374 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2375 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2376
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2380 /* Mic2 (as headphone out) for HP output */
2381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002383 /* Line In pin widget for input */
2384 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2386 /* Line2 (as front mic) pin widget for input and vref at 80% */
2387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2388 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2389 /* CD pin widget for input */
2390 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391
2392 { }
2393};
2394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002395/*
2396 * W810 pin configuration:
2397 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2398 */
2399static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 /* hphone/speaker input selector: front DAC */
2401 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2402
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2407 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409
2410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002411 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 { }
2414};
2415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002416/*
2417 * Z71V pin configuration:
2418 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2419 */
2420static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002422 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002425
Takashi Iwai16ded522005-06-10 19:58:24 +02002426 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002427 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002428 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002430
2431 { }
2432};
2433
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002434/*
2435 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002436 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2437 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 */
2439static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2440 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2441
Takashi Iwai16ded522005-06-10 19:58:24 +02002442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002446 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002447 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002448 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2450
Takashi Iwai16ded522005-06-10 19:58:24 +02002451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002454 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002457 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002458 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002459 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002461 { }
2462};
Takashi Iwai16ded522005-06-10 19:58:24 +02002463
Kailang Yangccc656c2006-10-17 12:32:26 +02002464/*
2465 * Uniwill pin configuration:
2466 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2467 * line = 0x1a
2468 */
2469static struct hda_verb alc880_uniwill_init_verbs[] = {
2470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2471
2472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2479 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2484 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2486
2487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2489 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2493 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2494 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2495 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2496
2497 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2498 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2499
2500 { }
2501};
2502
2503/*
2504* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002505* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002506 */
2507static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2508 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2509
2510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2514 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2522
2523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2529
2530 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2531 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2532
2533 { }
2534};
2535
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002536static struct hda_verb alc880_beep_init_verbs[] = {
2537 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2538 { }
2539};
2540
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002541/* auto-toggle front mic */
2542static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2543{
2544 unsigned int present;
2545 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002546
2547 present = snd_hda_codec_read(codec, 0x18, 0,
2548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002549 bits = present ? HDA_AMP_MUTE : 0;
2550 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002551}
2552
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002553static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002554{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002555 struct alc_spec *spec = codec->spec;
2556
2557 spec->autocfg.hp_pins[0] = 0x14;
2558 spec->autocfg.speaker_pins[0] = 0x15;
2559 spec->autocfg.speaker_pins[0] = 0x16;
2560 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002561 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002562}
2563
2564static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2565 unsigned int res)
2566{
2567 /* Looks like the unsol event is incompatible with the standard
2568 * definition. 4bit tag is placed at 28 bit!
2569 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002570 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002571 case ALC880_MIC_EVENT:
2572 alc880_uniwill_mic_automute(codec);
2573 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002574 default:
2575 alc_automute_amp_unsol_event(codec, res);
2576 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002577 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002578}
2579
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002580static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002581{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002582 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002583
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002584 spec->autocfg.hp_pins[0] = 0x14;
2585 spec->autocfg.speaker_pins[0] = 0x15;
2586 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002587}
2588
2589static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2590{
2591 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002592
Kailang Yangccc656c2006-10-17 12:32:26 +02002593 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002594 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2595 present &= HDA_AMP_VOLMASK;
2596 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2597 HDA_AMP_VOLMASK, present);
2598 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2599 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002600}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002601
Kailang Yangccc656c2006-10-17 12:32:26 +02002602static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2603 unsigned int res)
2604{
2605 /* Looks like the unsol event is incompatible with the standard
2606 * definition. 4bit tag is placed at 28 bit!
2607 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002608 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002609 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002610 else
2611 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002612}
2613
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614/*
2615 * F1734 pin configuration:
2616 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2617 */
2618static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002619 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002620 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2621 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2622 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2623 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2624
2625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2629
2630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002632 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2634 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2637 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002639
Takashi Iwai937b4162008-02-11 14:52:36 +01002640 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2641 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2642
Takashi Iwai16ded522005-06-10 19:58:24 +02002643 { }
2644};
2645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002646/*
2647 * ASUS pin configuration:
2648 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2649 */
2650static struct hda_verb alc880_pin_asus_init_verbs[] = {
2651 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2653 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2654 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2655
2656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2660 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2662 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2664
2665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002674
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002675 { }
2676};
2677
2678/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002679#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2680#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002681
Kailang Yangdf694da2005-12-05 19:42:22 +01002682/* Clevo m520g init */
2683static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2684 /* headphone output */
2685 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2686 /* line-out */
2687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689 /* Line-in */
2690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 /* CD */
2693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2694 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 /* Mic1 (rear panel) */
2696 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2697 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2698 /* Mic2 (front panel) */
2699 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2700 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2701 /* headphone */
2702 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2704 /* change to EAPD mode */
2705 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2706 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2707
2708 { }
2709};
2710
2711static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002712 /* change to EAPD mode */
2713 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2714 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2715
Kailang Yangdf694da2005-12-05 19:42:22 +01002716 /* Headphone output */
2717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2718 /* Front output*/
2719 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2721
2722 /* Line In pin widget for input */
2723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2724 /* CD pin widget for input */
2725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2726 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2728
2729 /* change to EAPD mode */
2730 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2731 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2732
2733 { }
2734};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735
2736/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002737 * LG m1 express dual
2738 *
2739 * Pin assignment:
2740 * Rear Line-In/Out (blue): 0x14
2741 * Build-in Mic-In: 0x15
2742 * Speaker-out: 0x17
2743 * HP-Out (green): 0x1b
2744 * Mic-In/Out (red): 0x19
2745 * SPDIF-Out: 0x1e
2746 */
2747
2748/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2749static hda_nid_t alc880_lg_dac_nids[3] = {
2750 0x05, 0x02, 0x03
2751};
2752
2753/* seems analog CD is not working */
2754static struct hda_input_mux alc880_lg_capture_source = {
2755 .num_items = 3,
2756 .items = {
2757 { "Mic", 0x1 },
2758 { "Line", 0x5 },
2759 { "Internal Mic", 0x6 },
2760 },
2761};
2762
2763/* 2,4,6 channel modes */
2764static struct hda_verb alc880_lg_ch2_init[] = {
2765 /* set line-in and mic-in to input */
2766 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2767 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2768 { }
2769};
2770
2771static struct hda_verb alc880_lg_ch4_init[] = {
2772 /* set line-in to out and mic-in to input */
2773 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2774 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2775 { }
2776};
2777
2778static struct hda_verb alc880_lg_ch6_init[] = {
2779 /* set line-in and mic-in to output */
2780 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2781 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2782 { }
2783};
2784
2785static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2786 { 2, alc880_lg_ch2_init },
2787 { 4, alc880_lg_ch4_init },
2788 { 6, alc880_lg_ch6_init },
2789};
2790
2791static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2793 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2795 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2801 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2805 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2806 {
2807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2808 .name = "Channel Mode",
2809 .info = alc_ch_mode_info,
2810 .get = alc_ch_mode_get,
2811 .put = alc_ch_mode_put,
2812 },
2813 { } /* end */
2814};
2815
2816static struct hda_verb alc880_lg_init_verbs[] = {
2817 /* set capture source to mic-in */
2818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2819 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2821 /* mute all amp mixer inputs */
2822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002825 /* line-in to input */
2826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 /* built-in mic */
2829 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2831 /* speaker-out */
2832 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2833 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2834 /* mic-in to input */
2835 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2838 /* HP-out */
2839 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2841 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002843 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002844 { }
2845};
2846
2847/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002848static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002849{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002850 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002851
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002852 spec->autocfg.hp_pins[0] = 0x1b;
2853 spec->autocfg.speaker_pins[0] = 0x17;
2854 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002855}
2856
2857/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002858 * LG LW20
2859 *
2860 * Pin assignment:
2861 * Speaker-out: 0x14
2862 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002863 * Built-in Mic-In: 0x19
2864 * Line-In: 0x1b
2865 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002866 * SPDIF-Out: 0x1e
2867 */
2868
Takashi Iwaid6815182006-03-23 16:06:23 +01002869static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002870 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002871 .items = {
2872 { "Mic", 0x0 },
2873 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002874 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002875 },
2876};
2877
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002878#define alc880_lg_lw_modes alc880_threestack_modes
2879
Takashi Iwaid6815182006-03-23 16:06:23 +01002880static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2882 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2883 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2884 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2885 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2886 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2887 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2888 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2893 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2894 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002895 {
2896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2897 .name = "Channel Mode",
2898 .info = alc_ch_mode_info,
2899 .get = alc_ch_mode_get,
2900 .put = alc_ch_mode_put,
2901 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002902 { } /* end */
2903};
2904
2905static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002906 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2907 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2908 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2909
Takashi Iwaid6815182006-03-23 16:06:23 +01002910 /* set capture source to mic-in */
2911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002915 /* speaker-out */
2916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* mic-in to input */
2922 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 /* built-in mic */
2925 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2926 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2927 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01002929 { }
2930};
2931
2932/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002933static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01002934{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002935 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01002936
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002937 spec->autocfg.hp_pins[0] = 0x1b;
2938 spec->autocfg.speaker_pins[0] = 0x14;
2939 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01002940}
2941
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002942static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2943 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2944 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2947 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2948 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2949 { } /* end */
2950};
2951
2952static struct hda_input_mux alc880_medion_rim_capture_source = {
2953 .num_items = 2,
2954 .items = {
2955 { "Mic", 0x0 },
2956 { "Internal Mic", 0x1 },
2957 },
2958};
2959
2960static struct hda_verb alc880_medion_rim_init_verbs[] = {
2961 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2962
2963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2965
2966 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2969 /* Mic2 (as headphone out) for HP output */
2970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2972 /* Internal Speaker */
2973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2974 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2975
2976 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2977 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2978
2979 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2980 { }
2981};
2982
2983/* toggle speaker-output according to the hp-jack state */
2984static void alc880_medion_rim_automute(struct hda_codec *codec)
2985{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002986 struct alc_spec *spec = codec->spec;
2987 alc_automute_amp(codec);
2988 /* toggle EAPD */
2989 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002990 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2991 else
2992 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2993}
2994
2995static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2996 unsigned int res)
2997{
2998 /* Looks like the unsol event is incompatible with the standard
2999 * definition. 4bit tag is placed at 28 bit!
3000 */
3001 if ((res >> 28) == ALC880_HP_EVENT)
3002 alc880_medion_rim_automute(codec);
3003}
3004
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003005static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3006{
3007 struct alc_spec *spec = codec->spec;
3008
3009 spec->autocfg.hp_pins[0] = 0x14;
3010 spec->autocfg.speaker_pins[0] = 0x1b;
3011 alc880_medion_rim_automute(codec);
3012}
3013
Takashi Iwaicb53c622007-08-10 17:21:45 +02003014#ifdef CONFIG_SND_HDA_POWER_SAVE
3015static struct hda_amp_list alc880_loopbacks[] = {
3016 { 0x0b, HDA_INPUT, 0 },
3017 { 0x0b, HDA_INPUT, 1 },
3018 { 0x0b, HDA_INPUT, 2 },
3019 { 0x0b, HDA_INPUT, 3 },
3020 { 0x0b, HDA_INPUT, 4 },
3021 { } /* end */
3022};
3023
3024static struct hda_amp_list alc880_lg_loopbacks[] = {
3025 { 0x0b, HDA_INPUT, 1 },
3026 { 0x0b, HDA_INPUT, 6 },
3027 { 0x0b, HDA_INPUT, 7 },
3028 { } /* end */
3029};
3030#endif
3031
Takashi Iwaid6815182006-03-23 16:06:23 +01003032/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003033 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003035
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036static int alc_init(struct hda_codec *codec)
3037{
3038 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039 unsigned int i;
3040
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003041 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003042 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003043
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003044 for (i = 0; i < spec->num_init_verbs; i++)
3045 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003046
3047 if (spec->init_hook)
3048 spec->init_hook(codec);
3049
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050 return 0;
3051}
3052
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003053static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3054{
3055 struct alc_spec *spec = codec->spec;
3056
3057 if (spec->unsol_event)
3058 spec->unsol_event(codec, res);
3059}
3060
Takashi Iwaicb53c622007-08-10 17:21:45 +02003061#ifdef CONFIG_SND_HDA_POWER_SAVE
3062static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3063{
3064 struct alc_spec *spec = codec->spec;
3065 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3066}
3067#endif
3068
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069/*
3070 * Analog playback callbacks
3071 */
3072static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3073 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003074 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075{
3076 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003077 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3078 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003079}
3080
3081static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3082 struct hda_codec *codec,
3083 unsigned int stream_tag,
3084 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003085 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086{
3087 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003088 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3089 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090}
3091
3092static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3093 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003094 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095{
3096 struct alc_spec *spec = codec->spec;
3097 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3098}
3099
3100/*
3101 * Digital out
3102 */
3103static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3104 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003105 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106{
3107 struct alc_spec *spec = codec->spec;
3108 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3109}
3110
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003111static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3112 struct hda_codec *codec,
3113 unsigned int stream_tag,
3114 unsigned int format,
3115 struct snd_pcm_substream *substream)
3116{
3117 struct alc_spec *spec = codec->spec;
3118 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3119 stream_tag, format, substream);
3120}
3121
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003122static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3123 struct hda_codec *codec,
3124 struct snd_pcm_substream *substream)
3125{
3126 struct alc_spec *spec = codec->spec;
3127 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3128}
3129
Linus Torvalds1da177e2005-04-16 15:20:36 -07003130static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3131 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003132 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133{
3134 struct alc_spec *spec = codec->spec;
3135 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3136}
3137
3138/*
3139 * Analog capture
3140 */
Takashi Iwai63300792008-01-24 15:31:36 +01003141static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003142 struct hda_codec *codec,
3143 unsigned int stream_tag,
3144 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003145 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146{
3147 struct alc_spec *spec = codec->spec;
3148
Takashi Iwai63300792008-01-24 15:31:36 +01003149 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003150 stream_tag, 0, format);
3151 return 0;
3152}
3153
Takashi Iwai63300792008-01-24 15:31:36 +01003154static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003155 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003156 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157{
3158 struct alc_spec *spec = codec->spec;
3159
Takashi Iwai888afa12008-03-18 09:57:50 +01003160 snd_hda_codec_cleanup_stream(codec,
3161 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003162 return 0;
3163}
3164
3165
3166/*
3167 */
3168static struct hda_pcm_stream alc880_pcm_analog_playback = {
3169 .substreams = 1,
3170 .channels_min = 2,
3171 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173 .ops = {
3174 .open = alc880_playback_pcm_open,
3175 .prepare = alc880_playback_pcm_prepare,
3176 .cleanup = alc880_playback_pcm_cleanup
3177 },
3178};
3179
3180static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003181 .substreams = 1,
3182 .channels_min = 2,
3183 .channels_max = 2,
3184 /* NID is set in alc_build_pcms */
3185};
3186
3187static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3188 .substreams = 1,
3189 .channels_min = 2,
3190 .channels_max = 2,
3191 /* NID is set in alc_build_pcms */
3192};
3193
3194static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3195 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003196 .channels_min = 2,
3197 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003199 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003200 .prepare = alc880_alt_capture_pcm_prepare,
3201 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003202 },
3203};
3204
3205static struct hda_pcm_stream alc880_pcm_digital_playback = {
3206 .substreams = 1,
3207 .channels_min = 2,
3208 .channels_max = 2,
3209 /* NID is set in alc_build_pcms */
3210 .ops = {
3211 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003212 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003213 .prepare = alc880_dig_playback_pcm_prepare,
3214 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215 },
3216};
3217
3218static struct hda_pcm_stream alc880_pcm_digital_capture = {
3219 .substreams = 1,
3220 .channels_min = 2,
3221 .channels_max = 2,
3222 /* NID is set in alc_build_pcms */
3223};
3224
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003225/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003226static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003227 .substreams = 0,
3228 .channels_min = 0,
3229 .channels_max = 0,
3230};
3231
Linus Torvalds1da177e2005-04-16 15:20:36 -07003232static int alc_build_pcms(struct hda_codec *codec)
3233{
3234 struct alc_spec *spec = codec->spec;
3235 struct hda_pcm *info = spec->pcm_rec;
3236 int i;
3237
3238 codec->num_pcms = 1;
3239 codec->pcm_info = info;
3240
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003241 if (spec->no_analog)
3242 goto skip_analog;
3243
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003244 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3245 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003246 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003247
Takashi Iwai4a471b72005-12-07 13:56:29 +01003248 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003249 if (snd_BUG_ON(!spec->multiout.dac_nids))
3250 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003251 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3252 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3253 }
3254 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003255 if (snd_BUG_ON(!spec->adc_nids))
3256 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003257 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3258 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3259 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003260
Takashi Iwai4a471b72005-12-07 13:56:29 +01003261 if (spec->channel_mode) {
3262 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3263 for (i = 0; i < spec->num_channel_mode; i++) {
3264 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3265 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3266 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267 }
3268 }
3269
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003270 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003271 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003272 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003273 snprintf(spec->stream_name_digital,
3274 sizeof(spec->stream_name_digital),
3275 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003276 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003277 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003278 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003279 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003280 if (spec->dig_out_type)
3281 info->pcm_type = spec->dig_out_type;
3282 else
3283 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003284 if (spec->multiout.dig_out_nid &&
3285 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3287 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3288 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003289 if (spec->dig_in_nid &&
3290 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003291 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3292 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3293 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003294 /* FIXME: do we need this for all Realtek codec models? */
3295 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296 }
3297
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003298 if (spec->no_analog)
3299 return 0;
3300
Takashi Iwaie08a0072006-09-07 17:52:14 +02003301 /* If the use of more than one ADC is requested for the current
3302 * model, configure a second analog capture-only PCM.
3303 */
3304 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003305 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3306 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003307 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003308 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003309 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003310 if (spec->alt_dac_nid) {
3311 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3312 *spec->stream_analog_alt_playback;
3313 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3314 spec->alt_dac_nid;
3315 } else {
3316 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3317 alc_pcm_null_stream;
3318 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3319 }
3320 if (spec->num_adc_nids > 1) {
3321 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3322 *spec->stream_analog_alt_capture;
3323 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3324 spec->adc_nids[1];
3325 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3326 spec->num_adc_nids - 1;
3327 } else {
3328 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3329 alc_pcm_null_stream;
3330 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003331 }
3332 }
3333
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334 return 0;
3335}
3336
Takashi Iwai603c4012008-07-30 15:01:44 +02003337static void alc_free_kctls(struct hda_codec *codec)
3338{
3339 struct alc_spec *spec = codec->spec;
3340
3341 if (spec->kctls.list) {
3342 struct snd_kcontrol_new *kctl = spec->kctls.list;
3343 int i;
3344 for (i = 0; i < spec->kctls.used; i++)
3345 kfree(kctl[i].name);
3346 }
3347 snd_array_free(&spec->kctls);
3348}
3349
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350static void alc_free(struct hda_codec *codec)
3351{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003355 return;
3356
Takashi Iwai603c4012008-07-30 15:01:44 +02003357 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003359 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360}
3361
Takashi Iwaie044c392008-10-27 16:56:24 +01003362#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003363static int alc_resume(struct hda_codec *codec)
3364{
Takashi Iwaie044c392008-10-27 16:56:24 +01003365 codec->patch_ops.init(codec);
3366 snd_hda_codec_resume_amp(codec);
3367 snd_hda_codec_resume_cache(codec);
3368 return 0;
3369}
Takashi Iwaie044c392008-10-27 16:56:24 +01003370#endif
3371
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372/*
3373 */
3374static struct hda_codec_ops alc_patch_ops = {
3375 .build_controls = alc_build_controls,
3376 .build_pcms = alc_build_pcms,
3377 .init = alc_init,
3378 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003379 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003380#ifdef SND_HDA_NEEDS_RESUME
3381 .resume = alc_resume,
3382#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003383#ifdef CONFIG_SND_HDA_POWER_SAVE
3384 .check_power_status = alc_check_power_status,
3385#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386};
3387
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003388
3389/*
3390 * Test configuration for debugging
3391 *
3392 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3393 * enum controls.
3394 */
3395#ifdef CONFIG_SND_DEBUG
3396static hda_nid_t alc880_test_dac_nids[4] = {
3397 0x02, 0x03, 0x04, 0x05
3398};
3399
3400static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003401 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003402 .items = {
3403 { "In-1", 0x0 },
3404 { "In-2", 0x1 },
3405 { "In-3", 0x2 },
3406 { "In-4", 0x3 },
3407 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003408 { "Front", 0x5 },
3409 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003410 },
3411};
3412
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003413static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003414 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003415 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003416 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003417 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003418};
3419
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003420static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3421 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003422{
3423 static char *texts[] = {
3424 "N/A", "Line Out", "HP Out",
3425 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3426 };
3427 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3428 uinfo->count = 1;
3429 uinfo->value.enumerated.items = 8;
3430 if (uinfo->value.enumerated.item >= 8)
3431 uinfo->value.enumerated.item = 7;
3432 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3433 return 0;
3434}
3435
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003436static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3437 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003438{
3439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3440 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3441 unsigned int pin_ctl, item = 0;
3442
3443 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3444 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3445 if (pin_ctl & AC_PINCTL_OUT_EN) {
3446 if (pin_ctl & AC_PINCTL_HP_EN)
3447 item = 2;
3448 else
3449 item = 1;
3450 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3451 switch (pin_ctl & AC_PINCTL_VREFEN) {
3452 case AC_PINCTL_VREF_HIZ: item = 3; break;
3453 case AC_PINCTL_VREF_50: item = 4; break;
3454 case AC_PINCTL_VREF_GRD: item = 5; break;
3455 case AC_PINCTL_VREF_80: item = 6; break;
3456 case AC_PINCTL_VREF_100: item = 7; break;
3457 }
3458 }
3459 ucontrol->value.enumerated.item[0] = item;
3460 return 0;
3461}
3462
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003463static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3464 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003465{
3466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3467 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3468 static unsigned int ctls[] = {
3469 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3470 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3471 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3472 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3473 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3474 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3475 };
3476 unsigned int old_ctl, new_ctl;
3477
3478 old_ctl = snd_hda_codec_read(codec, nid, 0,
3479 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3480 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3481 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003482 int val;
3483 snd_hda_codec_write_cache(codec, nid, 0,
3484 AC_VERB_SET_PIN_WIDGET_CONTROL,
3485 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003486 val = ucontrol->value.enumerated.item[0] >= 3 ?
3487 HDA_AMP_MUTE : 0;
3488 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3489 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003490 return 1;
3491 }
3492 return 0;
3493}
3494
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003495static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3496 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003497{
3498 static char *texts[] = {
3499 "Front", "Surround", "CLFE", "Side"
3500 };
3501 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3502 uinfo->count = 1;
3503 uinfo->value.enumerated.items = 4;
3504 if (uinfo->value.enumerated.item >= 4)
3505 uinfo->value.enumerated.item = 3;
3506 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3507 return 0;
3508}
3509
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003510static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3511 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512{
3513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3514 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3515 unsigned int sel;
3516
3517 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3518 ucontrol->value.enumerated.item[0] = sel & 3;
3519 return 0;
3520}
3521
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003522static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3523 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003524{
3525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3526 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3527 unsigned int sel;
3528
3529 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3530 if (ucontrol->value.enumerated.item[0] != sel) {
3531 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003532 snd_hda_codec_write_cache(codec, nid, 0,
3533 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003534 return 1;
3535 }
3536 return 0;
3537}
3538
3539#define PIN_CTL_TEST(xname,nid) { \
3540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3541 .name = xname, \
3542 .info = alc_test_pin_ctl_info, \
3543 .get = alc_test_pin_ctl_get, \
3544 .put = alc_test_pin_ctl_put, \
3545 .private_value = nid \
3546 }
3547
3548#define PIN_SRC_TEST(xname,nid) { \
3549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3550 .name = xname, \
3551 .info = alc_test_pin_src_info, \
3552 .get = alc_test_pin_src_get, \
3553 .put = alc_test_pin_src_put, \
3554 .private_value = nid \
3555 }
3556
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003557static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003558 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3559 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3560 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3561 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003562 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3563 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3564 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3565 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003566 PIN_CTL_TEST("Front Pin Mode", 0x14),
3567 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3568 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3569 PIN_CTL_TEST("Side Pin Mode", 0x17),
3570 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3571 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3572 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3573 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3574 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3575 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3576 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3577 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3578 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3579 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3580 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3581 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3582 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3583 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3584 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3585 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003588 {
3589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3590 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003591 .info = alc_ch_mode_info,
3592 .get = alc_ch_mode_get,
3593 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003594 },
3595 { } /* end */
3596};
3597
3598static struct hda_verb alc880_test_init_verbs[] = {
3599 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3604 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003608 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3612 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003613 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3617 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003618 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003623 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3625 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3628 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003629 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3631 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3632 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3633 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003634 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003636 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003638 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003640 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003641 /* Analog input/passthru */
3642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003647 { }
3648};
3649#endif
3650
Linus Torvalds1da177e2005-04-16 15:20:36 -07003651/*
3652 */
3653
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003654static const char *alc880_models[ALC880_MODEL_LAST] = {
3655 [ALC880_3ST] = "3stack",
3656 [ALC880_TCL_S700] = "tcl",
3657 [ALC880_3ST_DIG] = "3stack-digout",
3658 [ALC880_CLEVO] = "clevo",
3659 [ALC880_5ST] = "5stack",
3660 [ALC880_5ST_DIG] = "5stack-digout",
3661 [ALC880_W810] = "w810",
3662 [ALC880_Z71V] = "z71v",
3663 [ALC880_6ST] = "6stack",
3664 [ALC880_6ST_DIG] = "6stack-digout",
3665 [ALC880_ASUS] = "asus",
3666 [ALC880_ASUS_W1V] = "asus-w1v",
3667 [ALC880_ASUS_DIG] = "asus-dig",
3668 [ALC880_ASUS_DIG2] = "asus-dig2",
3669 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003670 [ALC880_UNIWILL_P53] = "uniwill-p53",
3671 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003672 [ALC880_F1734] = "F1734",
3673 [ALC880_LG] = "lg",
3674 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003675 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003676#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003677 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003678#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003679 [ALC880_AUTO] = "auto",
3680};
3681
3682static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003683 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003684 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3685 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3686 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3687 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3688 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3689 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3690 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3691 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003692 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3693 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003694 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3695 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3696 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3697 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3698 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3699 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3700 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3701 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3702 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3703 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003704 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003705 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3706 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3707 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003708 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003709 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003710 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3711 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003712 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3713 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003714 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3715 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3716 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3717 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003718 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3719 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003720 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003721 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003722 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003723 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003724 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3725 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003726 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003727 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003728 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003729 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003730 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003731 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003732 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003733 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003734 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003735 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3736 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003737 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003738 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3739 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3740 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3741 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003742 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3743 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003744 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003745 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003746 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3747 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003748 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3749 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3750 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003751 /* default Intel */
3752 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003753 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3754 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003755 {}
3756};
3757
Takashi Iwai16ded522005-06-10 19:58:24 +02003758/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003759 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003760 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003761static struct alc_config_preset alc880_presets[] = {
3762 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003763 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003764 .init_verbs = { alc880_volume_init_verbs,
3765 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003766 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003767 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003768 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3769 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003770 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003771 .input_mux = &alc880_capture_source,
3772 },
3773 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003774 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003775 .init_verbs = { alc880_volume_init_verbs,
3776 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003777 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003778 .dac_nids = alc880_dac_nids,
3779 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003780 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3781 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003782 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 .input_mux = &alc880_capture_source,
3784 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003785 [ALC880_TCL_S700] = {
3786 .mixers = { alc880_tcl_s700_mixer },
3787 .init_verbs = { alc880_volume_init_verbs,
3788 alc880_pin_tcl_S700_init_verbs,
3789 alc880_gpio2_init_verbs },
3790 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3791 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003792 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3793 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003794 .hp_nid = 0x03,
3795 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3796 .channel_mode = alc880_2_jack_modes,
3797 .input_mux = &alc880_capture_source,
3798 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003799 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003800 .mixers = { alc880_three_stack_mixer,
3801 alc880_five_stack_mixer},
3802 .init_verbs = { alc880_volume_init_verbs,
3803 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003804 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3805 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003806 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3807 .channel_mode = alc880_fivestack_modes,
3808 .input_mux = &alc880_capture_source,
3809 },
3810 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003811 .mixers = { alc880_three_stack_mixer,
3812 alc880_five_stack_mixer },
3813 .init_verbs = { alc880_volume_init_verbs,
3814 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003815 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3816 .dac_nids = alc880_dac_nids,
3817 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003818 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3819 .channel_mode = alc880_fivestack_modes,
3820 .input_mux = &alc880_capture_source,
3821 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003822 [ALC880_6ST] = {
3823 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003824 .init_verbs = { alc880_volume_init_verbs,
3825 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003826 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3827 .dac_nids = alc880_6st_dac_nids,
3828 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3829 .channel_mode = alc880_sixstack_modes,
3830 .input_mux = &alc880_6stack_capture_source,
3831 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003832 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003833 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003834 .init_verbs = { alc880_volume_init_verbs,
3835 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003836 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3837 .dac_nids = alc880_6st_dac_nids,
3838 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003839 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3840 .channel_mode = alc880_sixstack_modes,
3841 .input_mux = &alc880_6stack_capture_source,
3842 },
3843 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003844 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003845 .init_verbs = { alc880_volume_init_verbs,
3846 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003847 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003848 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3849 .dac_nids = alc880_w810_dac_nids,
3850 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003851 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3852 .channel_mode = alc880_w810_modes,
3853 .input_mux = &alc880_capture_source,
3854 },
3855 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003857 .init_verbs = { alc880_volume_init_verbs,
3858 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003859 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3860 .dac_nids = alc880_z71v_dac_nids,
3861 .dig_out_nid = ALC880_DIGOUT_NID,
3862 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003863 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3864 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .input_mux = &alc880_capture_source,
3866 },
3867 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003868 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003869 .init_verbs = { alc880_volume_init_verbs,
3870 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003871 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3872 .dac_nids = alc880_f1734_dac_nids,
3873 .hp_nid = 0x02,
3874 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3875 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003876 .input_mux = &alc880_f1734_capture_source,
3877 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003878 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003879 },
3880 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003881 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003882 .init_verbs = { alc880_volume_init_verbs,
3883 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003884 alc880_gpio1_init_verbs },
3885 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3886 .dac_nids = alc880_asus_dac_nids,
3887 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3888 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003889 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003890 .input_mux = &alc880_capture_source,
3891 },
3892 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003893 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003894 .init_verbs = { alc880_volume_init_verbs,
3895 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003896 alc880_gpio1_init_verbs },
3897 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3898 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003899 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003900 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3901 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003902 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003903 .input_mux = &alc880_capture_source,
3904 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003905 [ALC880_ASUS_DIG2] = {
3906 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003907 .init_verbs = { alc880_volume_init_verbs,
3908 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003909 alc880_gpio2_init_verbs }, /* use GPIO2 */
3910 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3911 .dac_nids = alc880_asus_dac_nids,
3912 .dig_out_nid = ALC880_DIGOUT_NID,
3913 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3914 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003915 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003916 .input_mux = &alc880_capture_source,
3917 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003918 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003919 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003920 .init_verbs = { alc880_volume_init_verbs,
3921 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003922 alc880_gpio1_init_verbs },
3923 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3924 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003925 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003926 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3927 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003928 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003929 .input_mux = &alc880_capture_source,
3930 },
3931 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003932 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003933 .init_verbs = { alc880_volume_init_verbs,
3934 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3936 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003937 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003938 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3939 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003940 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003941 .input_mux = &alc880_capture_source,
3942 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003943 [ALC880_UNIWILL] = {
3944 .mixers = { alc880_uniwill_mixer },
3945 .init_verbs = { alc880_volume_init_verbs,
3946 alc880_uniwill_init_verbs },
3947 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3948 .dac_nids = alc880_asus_dac_nids,
3949 .dig_out_nid = ALC880_DIGOUT_NID,
3950 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3951 .channel_mode = alc880_threestack_modes,
3952 .need_dac_fix = 1,
3953 .input_mux = &alc880_capture_source,
3954 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003955 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003956 },
3957 [ALC880_UNIWILL_P53] = {
3958 .mixers = { alc880_uniwill_p53_mixer },
3959 .init_verbs = { alc880_volume_init_verbs,
3960 alc880_uniwill_p53_init_verbs },
3961 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3962 .dac_nids = alc880_asus_dac_nids,
3963 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003964 .channel_mode = alc880_threestack_modes,
3965 .input_mux = &alc880_capture_source,
3966 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003967 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003968 },
3969 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003970 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003971 .init_verbs = { alc880_volume_init_verbs,
3972 alc880_uniwill_p53_init_verbs,
3973 alc880_beep_init_verbs },
3974 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3975 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003976 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003977 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3978 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003979 .input_mux = &alc880_capture_source,
3980 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003981 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003983 [ALC880_CLEVO] = {
3984 .mixers = { alc880_three_stack_mixer },
3985 .init_verbs = { alc880_volume_init_verbs,
3986 alc880_pin_clevo_init_verbs },
3987 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3988 .dac_nids = alc880_dac_nids,
3989 .hp_nid = 0x03,
3990 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3991 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003992 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003993 .input_mux = &alc880_capture_source,
3994 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003995 [ALC880_LG] = {
3996 .mixers = { alc880_lg_mixer },
3997 .init_verbs = { alc880_volume_init_verbs,
3998 alc880_lg_init_verbs },
3999 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4000 .dac_nids = alc880_lg_dac_nids,
4001 .dig_out_nid = ALC880_DIGOUT_NID,
4002 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4003 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004004 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004005 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004006 .unsol_event = alc_automute_amp_unsol_event,
4007 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004008#ifdef CONFIG_SND_HDA_POWER_SAVE
4009 .loopbacks = alc880_lg_loopbacks,
4010#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004011 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004012 [ALC880_LG_LW] = {
4013 .mixers = { alc880_lg_lw_mixer },
4014 .init_verbs = { alc880_volume_init_verbs,
4015 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004016 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004017 .dac_nids = alc880_dac_nids,
4018 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004019 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4020 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004021 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004022 .unsol_event = alc_automute_amp_unsol_event,
4023 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004024 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004025 [ALC880_MEDION_RIM] = {
4026 .mixers = { alc880_medion_rim_mixer },
4027 .init_verbs = { alc880_volume_init_verbs,
4028 alc880_medion_rim_init_verbs,
4029 alc_gpio2_init_verbs },
4030 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4031 .dac_nids = alc880_dac_nids,
4032 .dig_out_nid = ALC880_DIGOUT_NID,
4033 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4034 .channel_mode = alc880_2_jack_modes,
4035 .input_mux = &alc880_medion_rim_capture_source,
4036 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004037 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004038 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004039#ifdef CONFIG_SND_DEBUG
4040 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004041 .mixers = { alc880_test_mixer },
4042 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4044 .dac_nids = alc880_test_dac_nids,
4045 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004046 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4047 .channel_mode = alc880_test_modes,
4048 .input_mux = &alc880_test_capture_source,
4049 },
4050#endif
4051};
4052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004053/*
4054 * Automatic parse of I/O pins from the BIOS configuration
4055 */
4056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057enum {
4058 ALC_CTL_WIDGET_VOL,
4059 ALC_CTL_WIDGET_MUTE,
4060 ALC_CTL_BIND_MUTE,
4061};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004062static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4064 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004065 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004066};
4067
4068/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004069static int add_control(struct alc_spec *spec, int type, const char *name,
4070 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004071{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004072 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073
Takashi Iwai603c4012008-07-30 15:01:44 +02004074 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4075 knew = snd_array_new(&spec->kctls);
4076 if (!knew)
4077 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004079 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004080 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 return -ENOMEM;
4082 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 return 0;
4084}
4085
4086#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4087#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4088#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4089#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4090#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4091#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4092#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4093#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4094#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4095#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4096#define ALC880_PIN_CD_NID 0x1c
4097
4098/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004099static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4100 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004101{
4102 hda_nid_t nid;
4103 int assigned[4];
4104 int i, j;
4105
4106 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004107 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108
4109 /* check the pins hardwired to audio widget */
4110 for (i = 0; i < cfg->line_outs; i++) {
4111 nid = cfg->line_out_pins[i];
4112 if (alc880_is_fixed_pin(nid)) {
4113 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004114 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 assigned[idx] = 1;
4116 }
4117 }
4118 /* left pins can be connect to any audio widget */
4119 for (i = 0; i < cfg->line_outs; i++) {
4120 nid = cfg->line_out_pins[i];
4121 if (alc880_is_fixed_pin(nid))
4122 continue;
4123 /* search for an empty channel */
4124 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004125 if (!assigned[j]) {
4126 spec->multiout.dac_nids[i] =
4127 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 assigned[j] = 1;
4129 break;
4130 }
4131 }
4132 }
4133 spec->multiout.num_dacs = cfg->line_outs;
4134 return 0;
4135}
4136
4137/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004138static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4139 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140{
4141 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004142 static const char *chname[4] = {
4143 "Front", "Surround", NULL /*CLFE*/, "Side"
4144 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004145 hda_nid_t nid;
4146 int i, err;
4147
4148 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004149 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004150 continue;
4151 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4152 if (i == 2) {
4153 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004154 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4155 "Center Playback Volume",
4156 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4157 HDA_OUTPUT));
4158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004160 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4161 "LFE Playback Volume",
4162 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4163 HDA_OUTPUT));
4164 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004166 err = add_control(spec, ALC_CTL_BIND_MUTE,
4167 "Center Playback Switch",
4168 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4169 HDA_INPUT));
4170 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004172 err = add_control(spec, ALC_CTL_BIND_MUTE,
4173 "LFE Playback Switch",
4174 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4175 HDA_INPUT));
4176 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177 return err;
4178 } else {
4179 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004180 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4181 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4182 HDA_OUTPUT));
4183 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004184 return err;
4185 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004186 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4187 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4188 HDA_INPUT));
4189 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004190 return err;
4191 }
4192 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193 return 0;
4194}
4195
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004196/* add playback controls for speaker and HP outputs */
4197static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4198 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199{
4200 hda_nid_t nid;
4201 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004202 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004203
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004204 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004205 return 0;
4206
4207 if (alc880_is_fixed_pin(pin)) {
4208 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004209 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004210 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004211 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004212 else
4213 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214 /* control HP volume/switch on the output mixer amp */
4215 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004216 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004217 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4218 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4219 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004221 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004222 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4223 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4224 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004225 return err;
4226 } else if (alc880_is_multi_pin(pin)) {
4227 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004229 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004230 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4231 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4232 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004233 return err;
4234 }
4235 return 0;
4236}
4237
4238/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004239static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4240 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004241 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242{
4243 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004244 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004245
4246 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004247 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4248 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4249 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 return err;
4251 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004252 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4253 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4254 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004255 return err;
4256 return 0;
4257}
4258
4259/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004260static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4261 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004263 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004264 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265
4266 for (i = 0; i < AUTO_PIN_LAST; i++) {
4267 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004268 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004269 err = new_analog_input(spec, cfg->input_pins[i],
4270 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004271 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004272 if (err < 0)
4273 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004274 imux->items[imux->num_items].label =
4275 auto_pin_cfg_labels[i];
4276 imux->items[imux->num_items].index =
4277 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 imux->num_items++;
4279 }
4280 }
4281 return 0;
4282}
4283
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004284static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4285 unsigned int pin_type)
4286{
4287 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4288 pin_type);
4289 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004290 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4291 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004292}
4293
Kailang Yangdf694da2005-12-05 19:42:22 +01004294static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4295 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296 int dac_idx)
4297{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004298 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299 /* need the manual connection? */
4300 if (alc880_is_multi_pin(nid)) {
4301 struct alc_spec *spec = codec->spec;
4302 int idx = alc880_multi_pin_idx(nid);
4303 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4304 AC_VERB_SET_CONNECT_SEL,
4305 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4306 }
4307}
4308
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004309static int get_pin_type(int line_out_type)
4310{
4311 if (line_out_type == AUTO_PIN_HP_OUT)
4312 return PIN_HP;
4313 else
4314 return PIN_OUT;
4315}
4316
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317static void alc880_auto_init_multi_out(struct hda_codec *codec)
4318{
4319 struct alc_spec *spec = codec->spec;
4320 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004321
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 for (i = 0; i < spec->autocfg.line_outs; i++) {
4323 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004324 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4325 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 }
4327}
4328
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004329static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330{
4331 struct alc_spec *spec = codec->spec;
4332 hda_nid_t pin;
4333
Takashi Iwai82bc9552006-03-21 11:24:42 +01004334 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004335 if (pin) /* connect to front */
4336 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004337 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004338 if (pin) /* connect to front */
4339 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4340}
4341
4342static void alc880_auto_init_analog_input(struct hda_codec *codec)
4343{
4344 struct alc_spec *spec = codec->spec;
4345 int i;
4346
4347 for (i = 0; i < AUTO_PIN_LAST; i++) {
4348 hda_nid_t nid = spec->autocfg.input_pins[i];
4349 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004350 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004351 if (nid != ALC880_PIN_CD_NID &&
4352 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004353 snd_hda_codec_write(codec, nid, 0,
4354 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355 AMP_OUT_MUTE);
4356 }
4357 }
4358}
4359
4360/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004361/* return 1 if successful, 0 if the proper config is not found,
4362 * or a negative error code
4363 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364static int alc880_parse_auto_config(struct hda_codec *codec)
4365{
4366 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004367 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004368 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004370 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4371 alc880_ignore);
4372 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004374 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004375 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004376
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4378 if (err < 0)
4379 return err;
4380 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4381 if (err < 0)
4382 return err;
4383 err = alc880_auto_create_extra_out(spec,
4384 spec->autocfg.speaker_pins[0],
4385 "Speaker");
4386 if (err < 0)
4387 return err;
4388 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4389 "Headphone");
4390 if (err < 0)
4391 return err;
4392 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4393 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 return err;
4395
4396 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4397
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004398 /* check multiple SPDIF-out (for recent codecs) */
4399 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4400 hda_nid_t dig_nid;
4401 err = snd_hda_get_connections(codec,
4402 spec->autocfg.dig_out_pins[i],
4403 &dig_nid, 1);
4404 if (err < 0)
4405 continue;
4406 if (!i)
4407 spec->multiout.dig_out_nid = dig_nid;
4408 else {
4409 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4410 spec->slave_dig_outs[i - 1] = dig_nid;
4411 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4412 break;
4413 }
4414 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415 if (spec->autocfg.dig_in_pin)
4416 spec->dig_in_nid = ALC880_DIGIN_NID;
4417
Takashi Iwai603c4012008-07-30 15:01:44 +02004418 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004419 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420
Takashi Iwaid88897e2008-10-31 15:01:37 +01004421 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004423 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004424 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004426 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 return 1;
4429}
4430
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004431/* additional initialization for auto-configuration model */
4432static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004434 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004436 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004438 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004439 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440}
4441
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004442static void set_capture_mixer(struct alc_spec *spec)
4443{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004444 static struct snd_kcontrol_new *caps[2][3] = {
4445 { alc_capture_mixer_nosrc1,
4446 alc_capture_mixer_nosrc2,
4447 alc_capture_mixer_nosrc3 },
4448 { alc_capture_mixer1,
4449 alc_capture_mixer2,
4450 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004451 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004452 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4453 int mux;
4454 if (spec->input_mux && spec->input_mux->num_items > 1)
4455 mux = 1;
4456 else
4457 mux = 0;
4458 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4459 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004460}
4461
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004462#define set_beep_amp(spec, nid, idx, dir) \
4463 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4464
4465/*
4466 * OK, here we have finally the patch for ALC880
4467 */
4468
Linus Torvalds1da177e2005-04-16 15:20:36 -07004469static int patch_alc880(struct hda_codec *codec)
4470{
4471 struct alc_spec *spec;
4472 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004473 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004474
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004475 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004476 if (spec == NULL)
4477 return -ENOMEM;
4478
4479 codec->spec = spec;
4480
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004481 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4482 alc880_models,
4483 alc880_cfg_tbl);
4484 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004485 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4486 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004488 }
4489
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490 if (board_config == ALC880_AUTO) {
4491 /* automatic parse from the BIOS config */
4492 err = alc880_parse_auto_config(codec);
4493 if (err < 0) {
4494 alc_free(codec);
4495 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004496 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004497 printk(KERN_INFO
4498 "hda_codec: Cannot set up configuration "
4499 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500 board_config = ALC880_3ST;
4501 }
4502 }
4503
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004504 err = snd_hda_attach_beep_device(codec, 0x1);
4505 if (err < 0) {
4506 alc_free(codec);
4507 return err;
4508 }
4509
Kailang Yangdf694da2005-12-05 19:42:22 +01004510 if (board_config != ALC880_AUTO)
4511 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004512
Linus Torvalds1da177e2005-04-16 15:20:36 -07004513 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4514 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004515 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004516
Linus Torvalds1da177e2005-04-16 15:20:36 -07004517 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4518 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004520 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004522 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004523 /* get type */
4524 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004525 if (wcap != AC_WID_AUD_IN) {
4526 spec->adc_nids = alc880_adc_nids_alt;
4527 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004528 } else {
4529 spec->adc_nids = alc880_adc_nids;
4530 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531 }
4532 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004533 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004534 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004535
Takashi Iwai2134ea42008-01-10 16:53:55 +01004536 spec->vmaster_nid = 0x0c;
4537
Linus Torvalds1da177e2005-04-16 15:20:36 -07004538 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004540 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004541#ifdef CONFIG_SND_HDA_POWER_SAVE
4542 if (!spec->loopback.amplist)
4543 spec->loopback.amplist = alc880_loopbacks;
4544#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004545 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004546
4547 return 0;
4548}
4549
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550
Linus Torvalds1da177e2005-04-16 15:20:36 -07004551/*
4552 * ALC260 support
4553 */
4554
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555static hda_nid_t alc260_dac_nids[1] = {
4556 /* front */
4557 0x02,
4558};
4559
4560static hda_nid_t alc260_adc_nids[1] = {
4561 /* ADC0 */
4562 0x04,
4563};
4564
Kailang Yangdf694da2005-12-05 19:42:22 +01004565static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566 /* ADC1 */
4567 0x05,
4568};
4569
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004570/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4571 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4572 */
4573static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004574 /* ADC0, ADC1 */
4575 0x04, 0x05
4576};
4577
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004578#define ALC260_DIGOUT_NID 0x03
4579#define ALC260_DIGIN_NID 0x06
4580
4581static struct hda_input_mux alc260_capture_source = {
4582 .num_items = 4,
4583 .items = {
4584 { "Mic", 0x0 },
4585 { "Front Mic", 0x1 },
4586 { "Line", 0x2 },
4587 { "CD", 0x4 },
4588 },
4589};
4590
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004591/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004592 * headphone jack and the internal CD lines since these are the only pins at
4593 * which audio can appear. For flexibility, also allow the option of
4594 * recording the mixer output on the second ADC (ADC0 doesn't have a
4595 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004596 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004597static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4598 {
4599 .num_items = 3,
4600 .items = {
4601 { "Mic/Line", 0x0 },
4602 { "CD", 0x4 },
4603 { "Headphone", 0x2 },
4604 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004605 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004606 {
4607 .num_items = 4,
4608 .items = {
4609 { "Mic/Line", 0x0 },
4610 { "CD", 0x4 },
4611 { "Headphone", 0x2 },
4612 { "Mixer", 0x5 },
4613 },
4614 },
4615
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004616};
4617
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004618/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4619 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004620 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004621static struct hda_input_mux alc260_acer_capture_sources[2] = {
4622 {
4623 .num_items = 4,
4624 .items = {
4625 { "Mic", 0x0 },
4626 { "Line", 0x2 },
4627 { "CD", 0x4 },
4628 { "Headphone", 0x5 },
4629 },
4630 },
4631 {
4632 .num_items = 5,
4633 .items = {
4634 { "Mic", 0x0 },
4635 { "Line", 0x2 },
4636 { "CD", 0x4 },
4637 { "Headphone", 0x6 },
4638 { "Mixer", 0x5 },
4639 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004640 },
4641};
Michael Schwingencc959482009-02-22 18:58:45 +01004642
4643/* Maxdata Favorit 100XS */
4644static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4645 {
4646 .num_items = 2,
4647 .items = {
4648 { "Line/Mic", 0x0 },
4649 { "CD", 0x4 },
4650 },
4651 },
4652 {
4653 .num_items = 3,
4654 .items = {
4655 { "Line/Mic", 0x0 },
4656 { "CD", 0x4 },
4657 { "Mixer", 0x5 },
4658 },
4659 },
4660};
4661
Linus Torvalds1da177e2005-04-16 15:20:36 -07004662/*
4663 * This is just place-holder, so there's something for alc_build_pcms to look
4664 * at when it calculates the maximum number of channels. ALC260 has no mixer
4665 * element which allows changing the channel mode, so the verb list is
4666 * never used.
4667 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004668static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004669 { 2, NULL },
4670};
4671
Kailang Yangdf694da2005-12-05 19:42:22 +01004672
4673/* Mixer combinations
4674 *
4675 * basic: base_output + input + pc_beep + capture
4676 * HP: base_output + input + capture_alt
4677 * HP_3013: hp_3013 + input + capture
4678 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004679 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004680 */
4681
4682static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004683 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004684 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004685 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4686 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4687 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4688 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4689 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004690};
Kailang Yangdf694da2005-12-05 19:42:22 +01004691
4692static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004693 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4694 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4695 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4696 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4697 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4698 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004701 { } /* end */
4702};
4703
Takashi Iwaibec15c32008-01-28 18:16:30 +01004704/* update HP, line and mono out pins according to the master switch */
4705static void alc260_hp_master_update(struct hda_codec *codec,
4706 hda_nid_t hp, hda_nid_t line,
4707 hda_nid_t mono)
4708{
4709 struct alc_spec *spec = codec->spec;
4710 unsigned int val = spec->master_sw ? PIN_HP : 0;
4711 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004712 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004713 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004714 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004715 val);
4716 /* mono (speaker) depending on the HP jack sense */
4717 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004718 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004719 val);
4720}
4721
4722static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4723 struct snd_ctl_elem_value *ucontrol)
4724{
4725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4726 struct alc_spec *spec = codec->spec;
4727 *ucontrol->value.integer.value = spec->master_sw;
4728 return 0;
4729}
4730
4731static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4732 struct snd_ctl_elem_value *ucontrol)
4733{
4734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4735 struct alc_spec *spec = codec->spec;
4736 int val = !!*ucontrol->value.integer.value;
4737 hda_nid_t hp, line, mono;
4738
4739 if (val == spec->master_sw)
4740 return 0;
4741 spec->master_sw = val;
4742 hp = (kcontrol->private_value >> 16) & 0xff;
4743 line = (kcontrol->private_value >> 8) & 0xff;
4744 mono = kcontrol->private_value & 0xff;
4745 alc260_hp_master_update(codec, hp, line, mono);
4746 return 1;
4747}
4748
4749static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4750 {
4751 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4752 .name = "Master Playback Switch",
4753 .info = snd_ctl_boolean_mono_info,
4754 .get = alc260_hp_master_sw_get,
4755 .put = alc260_hp_master_sw_put,
4756 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4757 },
4758 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4759 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4761 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4762 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4763 HDA_OUTPUT),
4764 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4765 { } /* end */
4766};
4767
4768static struct hda_verb alc260_hp_unsol_verbs[] = {
4769 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4770 {},
4771};
4772
4773static void alc260_hp_automute(struct hda_codec *codec)
4774{
4775 struct alc_spec *spec = codec->spec;
4776 unsigned int present;
4777
4778 present = snd_hda_codec_read(codec, 0x10, 0,
4779 AC_VERB_GET_PIN_SENSE, 0);
4780 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4781 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4782}
4783
4784static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4785{
4786 if ((res >> 26) == ALC880_HP_EVENT)
4787 alc260_hp_automute(codec);
4788}
4789
Kailang Yangdf694da2005-12-05 19:42:22 +01004790static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004791 {
4792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4793 .name = "Master Playback Switch",
4794 .info = snd_ctl_boolean_mono_info,
4795 .get = alc260_hp_master_sw_get,
4796 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004797 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004798 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004799 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4800 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4801 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4802 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4803 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004805 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4806 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004807 { } /* end */
4808};
4809
Kailang Yang3f878302008-08-26 13:02:23 +02004810static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4811 .ops = &snd_hda_bind_vol,
4812 .values = {
4813 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4814 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4815 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4816 0
4817 },
4818};
4819
4820static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4821 .ops = &snd_hda_bind_sw,
4822 .values = {
4823 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4824 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4825 0
4826 },
4827};
4828
4829static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4830 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4831 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4832 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4834 { } /* end */
4835};
4836
Takashi Iwaibec15c32008-01-28 18:16:30 +01004837static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4838 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4839 {},
4840};
4841
4842static void alc260_hp_3013_automute(struct hda_codec *codec)
4843{
4844 struct alc_spec *spec = codec->spec;
4845 unsigned int present;
4846
4847 present = snd_hda_codec_read(codec, 0x15, 0,
4848 AC_VERB_GET_PIN_SENSE, 0);
4849 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004850 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004851}
4852
4853static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4854 unsigned int res)
4855{
4856 if ((res >> 26) == ALC880_HP_EVENT)
4857 alc260_hp_3013_automute(codec);
4858}
4859
Kailang Yang3f878302008-08-26 13:02:23 +02004860static void alc260_hp_3012_automute(struct hda_codec *codec)
4861{
4862 unsigned int present, bits;
4863
4864 present = snd_hda_codec_read(codec, 0x10, 0,
4865 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4866
4867 bits = present ? 0 : PIN_OUT;
4868 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4869 bits);
4870 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4871 bits);
4872 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4873 bits);
4874}
4875
4876static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4877 unsigned int res)
4878{
4879 if ((res >> 26) == ALC880_HP_EVENT)
4880 alc260_hp_3012_automute(codec);
4881}
4882
4883/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004884 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4885 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004886static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004887 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004888 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004889 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004890 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4891 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4892 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4893 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004894 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004895 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4896 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004897 { } /* end */
4898};
4899
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004900/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4901 * versions of the ALC260 don't act on requests to enable mic bias from NID
4902 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4903 * datasheet doesn't mention this restriction. At this stage it's not clear
4904 * whether this behaviour is intentional or is a hardware bug in chip
4905 * revisions available in early 2006. Therefore for now allow the
4906 * "Headphone Jack Mode" control to span all choices, but if it turns out
4907 * that the lack of mic bias for this NID is intentional we could change the
4908 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4909 *
4910 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4911 * don't appear to make the mic bias available from the "line" jack, even
4912 * though the NID used for this jack (0x14) can supply it. The theory is
4913 * that perhaps Acer have included blocking capacitors between the ALC260
4914 * and the output jack. If this turns out to be the case for all such
4915 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4916 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004917 *
4918 * The C20x Tablet series have a mono internal speaker which is controlled
4919 * via the chip's Mono sum widget and pin complex, so include the necessary
4920 * controls for such models. On models without a "mono speaker" the control
4921 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004922 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004923static struct snd_kcontrol_new alc260_acer_mixer[] = {
4924 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4925 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004926 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004927 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004928 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004929 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004930 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004931 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4934 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4935 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4936 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4937 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4938 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004939 { } /* end */
4940};
4941
Michael Schwingencc959482009-02-22 18:58:45 +01004942/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4943 */
4944static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4945 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4946 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4947 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4948 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4949 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4950 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4951 { } /* end */
4952};
4953
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004954/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4955 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4956 */
4957static struct snd_kcontrol_new alc260_will_mixer[] = {
4958 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4959 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4961 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4962 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4963 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4964 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4965 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4966 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4967 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004968 { } /* end */
4969};
4970
4971/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4972 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4973 */
4974static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4975 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4976 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4978 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4979 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4980 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4981 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4982 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4983 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4984 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4985 { } /* end */
4986};
4987
Kailang Yangdf694da2005-12-05 19:42:22 +01004988/*
4989 * initialization verbs
4990 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004991static struct hda_verb alc260_init_verbs[] = {
4992 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004994 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004997 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004999 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005000 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005001 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005002 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005003 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005004 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005005 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005006 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005007 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005008 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005009 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5010 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005011 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005012 /* set connection select to line in (default select for this ADC) */
5013 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005014 /* mute capture amp left and right */
5015 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5016 /* set connection select to line in (default select for this ADC) */
5017 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005018 /* set vol=0 Line-Out mixer amp left and right */
5019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5020 /* unmute pin widget amp left and right (no gain on this amp) */
5021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5022 /* set vol=0 HP mixer amp left and right */
5023 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5024 /* unmute pin widget amp left and right (no gain on this amp) */
5025 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5026 /* set vol=0 Mono mixer amp left and right */
5027 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5028 /* unmute pin widget amp left and right (no gain on this amp) */
5029 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5030 /* unmute LINE-2 out pin */
5031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5033 * Line In 2 = 0x03
5034 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005035 /* mute analog inputs */
5036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005042 /* mute Front out path */
5043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5045 /* mute Headphone out path */
5046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5047 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5048 /* mute Mono out path */
5049 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5050 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005051 { }
5052};
5053
Takashi Iwai474167d2006-05-17 17:17:43 +02005054#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005055static struct hda_verb alc260_hp_init_verbs[] = {
5056 /* Headphone and output */
5057 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5058 /* mono output */
5059 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5060 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5061 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5062 /* Mic2 (front panel) pin widget for input and vref at 80% */
5063 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5064 /* Line In pin widget for input */
5065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5066 /* Line-2 pin widget for output */
5067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5068 /* CD pin widget for input */
5069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5070 /* unmute amp left and right */
5071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5072 /* set connection select to line in (default select for this ADC) */
5073 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5074 /* unmute Line-Out mixer amp left and right (volume = 0) */
5075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5076 /* mute pin widget amp left and right (no gain on this amp) */
5077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5078 /* unmute HP mixer amp left and right (volume = 0) */
5079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5080 /* mute pin widget amp left and right (no gain on this amp) */
5081 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5083 * Line In 2 = 0x03
5084 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005085 /* mute analog inputs */
5086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5088 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5089 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005091 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5092 /* Unmute Front out path */
5093 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5094 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5095 /* Unmute Headphone out path */
5096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5098 /* Unmute Mono out path */
5099 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5100 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5101 { }
5102};
Takashi Iwai474167d2006-05-17 17:17:43 +02005103#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005104
5105static struct hda_verb alc260_hp_3013_init_verbs[] = {
5106 /* Line out and output */
5107 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5108 /* mono output */
5109 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5110 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5111 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5112 /* Mic2 (front panel) pin widget for input and vref at 80% */
5113 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5114 /* Line In pin widget for input */
5115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5116 /* Headphone pin widget for output */
5117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5118 /* CD pin widget for input */
5119 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5120 /* unmute amp left and right */
5121 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5122 /* set connection select to line in (default select for this ADC) */
5123 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5124 /* unmute Line-Out mixer amp left and right (volume = 0) */
5125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5126 /* mute pin widget amp left and right (no gain on this amp) */
5127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5128 /* unmute HP mixer amp left and right (volume = 0) */
5129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5130 /* mute pin widget amp left and right (no gain on this amp) */
5131 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005132 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5133 * Line In 2 = 0x03
5134 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005135 /* mute analog inputs */
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005141 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5142 /* Unmute Front out path */
5143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5145 /* Unmute Headphone out path */
5146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5148 /* Unmute Mono out path */
5149 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5150 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5151 { }
5152};
5153
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005154/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005155 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5156 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005157 */
5158static struct hda_verb alc260_fujitsu_init_verbs[] = {
5159 /* Disable all GPIOs */
5160 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5161 /* Internal speaker is connected to headphone pin */
5162 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5163 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005165 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5166 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5167 /* Ensure all other unused pins are disabled and muted. */
5168 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005170 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005171 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005172 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005173 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005176
Jonathan Woithef7ace402006-02-28 11:46:14 +01005177 /* Disable digital (SPDIF) pins */
5178 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5179 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005180
Kailang Yangea1fb292008-08-26 12:58:38 +02005181 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005182 * when acting as an output.
5183 */
5184 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5185
5186 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5193 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5194 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5195 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005196
Jonathan Woithef7ace402006-02-28 11:46:14 +01005197 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5199 /* Unmute Line1 pin widget output buffer since it starts as an output.
5200 * If the pin mode is changed by the user the pin mode control will
5201 * take care of enabling the pin's input/output buffers as needed.
5202 * Therefore there's no need to enable the input buffer at this
5203 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005204 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005205 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005206 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005207 * mixer ctrl)
5208 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005209 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005210
Jonathan Woithef7ace402006-02-28 11:46:14 +01005211 /* Mute capture amp left and right */
5212 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005213 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005214 * in (on mic1 pin)
5215 */
5216 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005217
Jonathan Woithef7ace402006-02-28 11:46:14 +01005218 /* Do the same for the second ADC: mute capture input amp and
5219 * set ADC connection to line in (on mic1 pin)
5220 */
5221 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5222 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005223
Jonathan Woithef7ace402006-02-28 11:46:14 +01005224 /* Mute all inputs to mixer widget (even unconnected ones) */
5225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005233
5234 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005235};
5236
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5238 * similar laptops (adapted from Fujitsu init verbs).
5239 */
5240static struct hda_verb alc260_acer_init_verbs[] = {
5241 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5242 * the headphone jack. Turn this on and rely on the standard mute
5243 * methods whenever the user wants to turn these outputs off.
5244 */
5245 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5246 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5247 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5248 /* Internal speaker/Headphone jack is connected to Line-out pin */
5249 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5250 /* Internal microphone/Mic jack is connected to Mic1 pin */
5251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5252 /* Line In jack is connected to Line1 pin */
5253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005254 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5255 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005256 /* Ensure all other unused pins are disabled and muted. */
5257 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005259 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5260 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5261 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5263 /* Disable digital (SPDIF) pins */
5264 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5265 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5266
Kailang Yangea1fb292008-08-26 12:58:38 +02005267 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005268 * bus when acting as outputs.
5269 */
5270 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5271 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5272
5273 /* Start with output sum widgets muted and their output gains at min */
5274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5275 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5277 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5278 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5279 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5280 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5281 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5282 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5283
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005284 /* Unmute Line-out pin widget amp left and right
5285 * (no equiv mixer ctrl)
5286 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005287 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005288 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5289 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005290 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5291 * inputs. If the pin mode is changed by the user the pin mode control
5292 * will take care of enabling the pin's input/output buffers as needed.
5293 * Therefore there's no need to enable the input buffer at this
5294 * stage.
5295 */
5296 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5298
5299 /* Mute capture amp left and right */
5300 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5301 /* Set ADC connection select to match default mixer setting - mic
5302 * (on mic1 pin)
5303 */
5304 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5305
5306 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005307 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005308 */
5309 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005310 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005311
5312 /* Mute all inputs to mixer widget (even unconnected ones) */
5313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5321
5322 { }
5323};
5324
Michael Schwingencc959482009-02-22 18:58:45 +01005325/* Initialisation sequence for Maxdata Favorit 100XS
5326 * (adapted from Acer init verbs).
5327 */
5328static struct hda_verb alc260_favorit100_init_verbs[] = {
5329 /* GPIO 0 enables the output jack.
5330 * Turn this on and rely on the standard mute
5331 * methods whenever the user wants to turn these outputs off.
5332 */
5333 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5334 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5335 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5336 /* Line/Mic input jack is connected to Mic1 pin */
5337 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5338 /* Ensure all other unused pins are disabled and muted. */
5339 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5340 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5342 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5343 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5344 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5349 /* Disable digital (SPDIF) pins */
5350 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5351 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5352
5353 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5354 * bus when acting as outputs.
5355 */
5356 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5357 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5358
5359 /* Start with output sum widgets muted and their output gains at min */
5360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5368 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5369
5370 /* Unmute Line-out pin widget amp left and right
5371 * (no equiv mixer ctrl)
5372 */
5373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5374 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5375 * inputs. If the pin mode is changed by the user the pin mode control
5376 * will take care of enabling the pin's input/output buffers as needed.
5377 * Therefore there's no need to enable the input buffer at this
5378 * stage.
5379 */
5380 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5381
5382 /* Mute capture amp left and right */
5383 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5384 /* Set ADC connection select to match default mixer setting - mic
5385 * (on mic1 pin)
5386 */
5387 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5388
5389 /* Do similar with the second ADC: mute capture input amp and
5390 * set ADC connection to mic to match ALSA's default state.
5391 */
5392 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5393 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5394
5395 /* Mute all inputs to mixer widget (even unconnected ones) */
5396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5404
5405 { }
5406};
5407
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005408static struct hda_verb alc260_will_verbs[] = {
5409 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5410 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5411 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5412 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5413 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5414 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5415 {}
5416};
5417
5418static struct hda_verb alc260_replacer_672v_verbs[] = {
5419 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5420 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5421 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5422
5423 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5424 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5425 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5426
5427 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5428 {}
5429};
5430
5431/* toggle speaker-output according to the hp-jack state */
5432static void alc260_replacer_672v_automute(struct hda_codec *codec)
5433{
5434 unsigned int present;
5435
5436 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5437 present = snd_hda_codec_read(codec, 0x0f, 0,
5438 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5439 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005440 snd_hda_codec_write_cache(codec, 0x01, 0,
5441 AC_VERB_SET_GPIO_DATA, 1);
5442 snd_hda_codec_write_cache(codec, 0x0f, 0,
5443 AC_VERB_SET_PIN_WIDGET_CONTROL,
5444 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005445 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005446 snd_hda_codec_write_cache(codec, 0x01, 0,
5447 AC_VERB_SET_GPIO_DATA, 0);
5448 snd_hda_codec_write_cache(codec, 0x0f, 0,
5449 AC_VERB_SET_PIN_WIDGET_CONTROL,
5450 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005451 }
5452}
5453
5454static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5455 unsigned int res)
5456{
5457 if ((res >> 26) == ALC880_HP_EVENT)
5458 alc260_replacer_672v_automute(codec);
5459}
5460
Kailang Yang3f878302008-08-26 13:02:23 +02005461static struct hda_verb alc260_hp_dc7600_verbs[] = {
5462 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5464 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5465 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5466 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5468 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5469 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5470 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5472 {}
5473};
5474
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005475/* Test configuration for debugging, modelled after the ALC880 test
5476 * configuration.
5477 */
5478#ifdef CONFIG_SND_DEBUG
5479static hda_nid_t alc260_test_dac_nids[1] = {
5480 0x02,
5481};
5482static hda_nid_t alc260_test_adc_nids[2] = {
5483 0x04, 0x05,
5484};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005485/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005486 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005487 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005488 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005489static struct hda_input_mux alc260_test_capture_sources[2] = {
5490 {
5491 .num_items = 7,
5492 .items = {
5493 { "MIC1 pin", 0x0 },
5494 { "MIC2 pin", 0x1 },
5495 { "LINE1 pin", 0x2 },
5496 { "LINE2 pin", 0x3 },
5497 { "CD pin", 0x4 },
5498 { "LINE-OUT pin", 0x5 },
5499 { "HP-OUT pin", 0x6 },
5500 },
5501 },
5502 {
5503 .num_items = 8,
5504 .items = {
5505 { "MIC1 pin", 0x0 },
5506 { "MIC2 pin", 0x1 },
5507 { "LINE1 pin", 0x2 },
5508 { "LINE2 pin", 0x3 },
5509 { "CD pin", 0x4 },
5510 { "Mixer", 0x5 },
5511 { "LINE-OUT pin", 0x6 },
5512 { "HP-OUT pin", 0x7 },
5513 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005514 },
5515};
5516static struct snd_kcontrol_new alc260_test_mixer[] = {
5517 /* Output driver widgets */
5518 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5519 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5520 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5521 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5522 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5523 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5524
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005525 /* Modes for retasking pin widgets
5526 * Note: the ALC260 doesn't seem to act on requests to enable mic
5527 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5528 * mention this restriction. At this stage it's not clear whether
5529 * this behaviour is intentional or is a hardware bug in chip
5530 * revisions available at least up until early 2006. Therefore for
5531 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5532 * choices, but if it turns out that the lack of mic bias for these
5533 * NIDs is intentional we could change their modes from
5534 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5535 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005536 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5537 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5538 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5539 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5540 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5541 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5542
5543 /* Loopback mixer controls */
5544 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5545 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5546 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5547 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5548 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5549 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5550 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5551 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5552 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5553 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005554 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5555 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5556 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5557 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005558
5559 /* Controls for GPIO pins, assuming they are configured as outputs */
5560 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5561 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5562 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5563 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5564
Jonathan Woithe92621f12006-02-28 11:47:47 +01005565 /* Switches to allow the digital IO pins to be enabled. The datasheet
5566 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005567 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005568 */
5569 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5570 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5571
Jonathan Woithef8225f62008-01-08 12:16:54 +01005572 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5573 * this output to turn on an external amplifier.
5574 */
5575 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5576 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5577
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005578 { } /* end */
5579};
5580static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005581 /* Enable all GPIOs as outputs with an initial value of 0 */
5582 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5583 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5584 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5585
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005586 /* Enable retasking pins as output, initially without power amp */
5587 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5588 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5591 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5592 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5593
Jonathan Woithe92621f12006-02-28 11:47:47 +01005594 /* Disable digital (SPDIF) pins initially, but users can enable
5595 * them via a mixer switch. In the case of SPDIF-out, this initverb
5596 * payload also sets the generation to 0, output to be in "consumer"
5597 * PCM format, copyright asserted, no pre-emphasis and no validity
5598 * control.
5599 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005600 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5601 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5602
Kailang Yangea1fb292008-08-26 12:58:38 +02005603 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005604 * OUT1 sum bus when acting as an output.
5605 */
5606 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5607 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5608 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5609 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5610
5611 /* Start with output sum widgets muted and their output gains at min */
5612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5618 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5620 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5621
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005622 /* Unmute retasking pin widget output buffers since the default
5623 * state appears to be output. As the pin mode is changed by the
5624 * user the pin mode control will take care of enabling the pin's
5625 * input/output buffers as needed.
5626 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005627 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5631 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5632 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5633 /* Also unmute the mono-out pin widget */
5634 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5635
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005636 /* Mute capture amp left and right */
5637 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005638 /* Set ADC connection select to match default mixer setting (mic1
5639 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005640 */
5641 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5642
5643 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005644 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005645 */
5646 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5647 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5648
5649 /* Mute all inputs to mixer widget (even unconnected ones) */
5650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5658
5659 { }
5660};
5661#endif
5662
Takashi Iwai63300792008-01-24 15:31:36 +01005663#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5664#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005665
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005666#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5667#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5668
Kailang Yangdf694da2005-12-05 19:42:22 +01005669/*
5670 * for BIOS auto-configuration
5671 */
5672
5673static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005674 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005675{
5676 hda_nid_t nid_vol;
5677 unsigned long vol_val, sw_val;
5678 char name[32];
5679 int err;
5680
5681 if (nid >= 0x0f && nid < 0x11) {
5682 nid_vol = nid - 0x7;
5683 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5684 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5685 } else if (nid == 0x11) {
5686 nid_vol = nid - 0x7;
5687 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5688 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5689 } else if (nid >= 0x12 && nid <= 0x15) {
5690 nid_vol = 0x08;
5691 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5692 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5693 } else
5694 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005695
Takashi Iwai863b4512008-10-21 17:01:47 +02005696 if (!(*vol_bits & (1 << nid_vol))) {
5697 /* first control for the volume widget */
5698 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5699 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5700 if (err < 0)
5701 return err;
5702 *vol_bits |= (1 << nid_vol);
5703 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005705 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5706 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005707 return err;
5708 return 1;
5709}
5710
5711/* add playback controls from the parsed DAC table */
5712static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5713 const struct auto_pin_cfg *cfg)
5714{
5715 hda_nid_t nid;
5716 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005717 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005718
5719 spec->multiout.num_dacs = 1;
5720 spec->multiout.dac_nids = spec->private_dac_nids;
5721 spec->multiout.dac_nids[0] = 0x02;
5722
5723 nid = cfg->line_out_pins[0];
5724 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005725 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005726 if (err < 0)
5727 return err;
5728 }
5729
Takashi Iwai82bc9552006-03-21 11:24:42 +01005730 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005732 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005733 if (err < 0)
5734 return err;
5735 }
5736
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005737 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005738 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005739 err = alc260_add_playback_controls(spec, nid, "Headphone",
5740 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005741 if (err < 0)
5742 return err;
5743 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005744 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005745}
5746
5747/* create playback/capture controls for input pins */
5748static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5749 const struct auto_pin_cfg *cfg)
5750{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005751 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005752 int i, err, idx;
5753
5754 for (i = 0; i < AUTO_PIN_LAST; i++) {
5755 if (cfg->input_pins[i] >= 0x12) {
5756 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005757 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005758 auto_pin_cfg_labels[i], idx,
5759 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005760 if (err < 0)
5761 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005762 imux->items[imux->num_items].label =
5763 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005764 imux->items[imux->num_items].index = idx;
5765 imux->num_items++;
5766 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005767 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005768 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005769 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005770 auto_pin_cfg_labels[i], idx,
5771 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005772 if (err < 0)
5773 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005774 imux->items[imux->num_items].label =
5775 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005776 imux->items[imux->num_items].index = idx;
5777 imux->num_items++;
5778 }
5779 }
5780 return 0;
5781}
5782
5783static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5784 hda_nid_t nid, int pin_type,
5785 int sel_idx)
5786{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005787 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005788 /* need the manual connection? */
5789 if (nid >= 0x12) {
5790 int idx = nid - 0x12;
5791 snd_hda_codec_write(codec, idx + 0x0b, 0,
5792 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005793 }
5794}
5795
5796static void alc260_auto_init_multi_out(struct hda_codec *codec)
5797{
5798 struct alc_spec *spec = codec->spec;
5799 hda_nid_t nid;
5800
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005801 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005802 if (nid) {
5803 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5804 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5805 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005806
Takashi Iwai82bc9552006-03-21 11:24:42 +01005807 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005808 if (nid)
5809 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5810
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005811 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005812 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005813 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005814}
Kailang Yangdf694da2005-12-05 19:42:22 +01005815
5816#define ALC260_PIN_CD_NID 0x16
5817static void alc260_auto_init_analog_input(struct hda_codec *codec)
5818{
5819 struct alc_spec *spec = codec->spec;
5820 int i;
5821
5822 for (i = 0; i < AUTO_PIN_LAST; i++) {
5823 hda_nid_t nid = spec->autocfg.input_pins[i];
5824 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005825 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005826 if (nid != ALC260_PIN_CD_NID &&
5827 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005828 snd_hda_codec_write(codec, nid, 0,
5829 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 AMP_OUT_MUTE);
5831 }
5832 }
5833}
5834
5835/*
5836 * generic initialization of ADC, input mixers and output mixers
5837 */
5838static struct hda_verb alc260_volume_init_verbs[] = {
5839 /*
5840 * Unmute ADC0-1 and set the default input to mic-in
5841 */
5842 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5843 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5844 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5845 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005846
Kailang Yangdf694da2005-12-05 19:42:22 +01005847 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5848 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005849 * Note: PASD motherboards uses the Line In 2 as the input for
5850 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005851 */
5852 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005853 /* mute analog inputs */
5854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005859
5860 /*
5861 * Set up output mixers (0x08 - 0x0a)
5862 */
5863 /* set vol=0 to output mixers */
5864 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5865 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5866 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5867 /* set up input amps for analog loopback */
5868 /* Amp Indices: DAC = 0, mixer = 1 */
5869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5870 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005875
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 { }
5877};
5878
5879static int alc260_parse_auto_config(struct hda_codec *codec)
5880{
5881 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005882 int err;
5883 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5884
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005885 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5886 alc260_ignore);
5887 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005888 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005889 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5890 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005891 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005892 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005893 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005894 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5895 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005896 return err;
5897
5898 spec->multiout.max_channels = 2;
5899
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005900 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005901 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005902 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005903 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005904
Takashi Iwaid88897e2008-10-31 15:01:37 +01005905 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005906
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005907 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005908 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005909
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005910 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5911
Kailang Yangdf694da2005-12-05 19:42:22 +01005912 return 1;
5913}
5914
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005915/* additional initialization for auto-configuration model */
5916static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005917{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005918 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005919 alc260_auto_init_multi_out(codec);
5920 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005921 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005922 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005923}
5924
Takashi Iwaicb53c622007-08-10 17:21:45 +02005925#ifdef CONFIG_SND_HDA_POWER_SAVE
5926static struct hda_amp_list alc260_loopbacks[] = {
5927 { 0x07, HDA_INPUT, 0 },
5928 { 0x07, HDA_INPUT, 1 },
5929 { 0x07, HDA_INPUT, 2 },
5930 { 0x07, HDA_INPUT, 3 },
5931 { 0x07, HDA_INPUT, 4 },
5932 { } /* end */
5933};
5934#endif
5935
Kailang Yangdf694da2005-12-05 19:42:22 +01005936/*
5937 * ALC260 configurations
5938 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005939static const char *alc260_models[ALC260_MODEL_LAST] = {
5940 [ALC260_BASIC] = "basic",
5941 [ALC260_HP] = "hp",
5942 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005943 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005944 [ALC260_FUJITSU_S702X] = "fujitsu",
5945 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005946 [ALC260_WILL] = "will",
5947 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005948 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005949#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005950 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005951#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005952 [ALC260_AUTO] = "auto",
5953};
5954
5955static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005956 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005957 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005958 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005959 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005960 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005961 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005962 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005963 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005964 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5965 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5966 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5967 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5968 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5969 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5970 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5971 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5972 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005973 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005974 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005975 {}
5976};
5977
Kailang Yangdf694da2005-12-05 19:42:22 +01005978static struct alc_config_preset alc260_presets[] = {
5979 [ALC260_BASIC] = {
5980 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005981 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005982 .init_verbs = { alc260_init_verbs },
5983 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5984 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005985 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005986 .adc_nids = alc260_adc_nids,
5987 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5988 .channel_mode = alc260_modes,
5989 .input_mux = &alc260_capture_source,
5990 },
5991 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005992 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005993 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005994 .init_verbs = { alc260_init_verbs,
5995 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005996 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5997 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005998 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5999 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006000 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6001 .channel_mode = alc260_modes,
6002 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006003 .unsol_event = alc260_hp_unsol_event,
6004 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006005 },
Kailang Yang3f878302008-08-26 13:02:23 +02006006 [ALC260_HP_DC7600] = {
6007 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006008 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006009 .init_verbs = { alc260_init_verbs,
6010 alc260_hp_dc7600_verbs },
6011 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6012 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006013 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6014 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006015 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6016 .channel_mode = alc260_modes,
6017 .input_mux = &alc260_capture_source,
6018 .unsol_event = alc260_hp_3012_unsol_event,
6019 .init_hook = alc260_hp_3012_automute,
6020 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 [ALC260_HP_3013] = {
6022 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006023 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006024 .init_verbs = { alc260_hp_3013_init_verbs,
6025 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006026 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6027 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006028 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6029 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006030 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6031 .channel_mode = alc260_modes,
6032 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006033 .unsol_event = alc260_hp_3013_unsol_event,
6034 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 },
6036 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006037 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006038 .init_verbs = { alc260_fujitsu_init_verbs },
6039 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6040 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006041 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6042 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006043 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6044 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006045 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6046 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006048 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006049 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006050 .init_verbs = { alc260_acer_init_verbs },
6051 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6052 .dac_nids = alc260_dac_nids,
6053 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6054 .adc_nids = alc260_dual_adc_nids,
6055 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6056 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006057 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6058 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006059 },
Michael Schwingencc959482009-02-22 18:58:45 +01006060 [ALC260_FAVORIT100] = {
6061 .mixers = { alc260_favorit100_mixer },
6062 .init_verbs = { alc260_favorit100_init_verbs },
6063 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6064 .dac_nids = alc260_dac_nids,
6065 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6066 .adc_nids = alc260_dual_adc_nids,
6067 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6068 .channel_mode = alc260_modes,
6069 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6070 .input_mux = alc260_favorit100_capture_sources,
6071 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006072 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006073 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006074 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6075 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6076 .dac_nids = alc260_dac_nids,
6077 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6078 .adc_nids = alc260_adc_nids,
6079 .dig_out_nid = ALC260_DIGOUT_NID,
6080 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6081 .channel_mode = alc260_modes,
6082 .input_mux = &alc260_capture_source,
6083 },
6084 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006085 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006086 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6087 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6088 .dac_nids = alc260_dac_nids,
6089 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6090 .adc_nids = alc260_adc_nids,
6091 .dig_out_nid = ALC260_DIGOUT_NID,
6092 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6093 .channel_mode = alc260_modes,
6094 .input_mux = &alc260_capture_source,
6095 .unsol_event = alc260_replacer_672v_unsol_event,
6096 .init_hook = alc260_replacer_672v_automute,
6097 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006098#ifdef CONFIG_SND_DEBUG
6099 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006100 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006101 .init_verbs = { alc260_test_init_verbs },
6102 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6103 .dac_nids = alc260_test_dac_nids,
6104 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6105 .adc_nids = alc260_test_adc_nids,
6106 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6107 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006108 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6109 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006110 },
6111#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006112};
6113
Linus Torvalds1da177e2005-04-16 15:20:36 -07006114static int patch_alc260(struct hda_codec *codec)
6115{
6116 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006117 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006118
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006119 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006120 if (spec == NULL)
6121 return -ENOMEM;
6122
6123 codec->spec = spec;
6124
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006125 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6126 alc260_models,
6127 alc260_cfg_tbl);
6128 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006129 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6130 "trying auto-probe from BIOS...\n",
6131 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006132 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006133 }
6134
Kailang Yangdf694da2005-12-05 19:42:22 +01006135 if (board_config == ALC260_AUTO) {
6136 /* automatic parse from the BIOS config */
6137 err = alc260_parse_auto_config(codec);
6138 if (err < 0) {
6139 alc_free(codec);
6140 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006142 printk(KERN_INFO
6143 "hda_codec: Cannot set up configuration "
6144 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 board_config = ALC260_BASIC;
6146 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006147 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006148
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006149 err = snd_hda_attach_beep_device(codec, 0x1);
6150 if (err < 0) {
6151 alc_free(codec);
6152 return err;
6153 }
6154
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 if (board_config != ALC260_AUTO)
6156 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006157
Linus Torvalds1da177e2005-04-16 15:20:36 -07006158 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6159 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6160
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006161 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6162 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6163
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006164 if (!spec->adc_nids && spec->input_mux) {
6165 /* check whether NID 0x04 is valid */
6166 unsigned int wcap = get_wcaps(codec, 0x04);
6167 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6168 /* get type */
6169 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6170 spec->adc_nids = alc260_adc_nids_alt;
6171 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6172 } else {
6173 spec->adc_nids = alc260_adc_nids;
6174 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6175 }
6176 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006177 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006178 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006179
Takashi Iwai2134ea42008-01-10 16:53:55 +01006180 spec->vmaster_nid = 0x08;
6181
Linus Torvalds1da177e2005-04-16 15:20:36 -07006182 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006183 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006184 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006185#ifdef CONFIG_SND_HDA_POWER_SAVE
6186 if (!spec->loopback.amplist)
6187 spec->loopback.amplist = alc260_loopbacks;
6188#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006189 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190
6191 return 0;
6192}
6193
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006194
Linus Torvalds1da177e2005-04-16 15:20:36 -07006195/*
6196 * ALC882 support
6197 *
6198 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6199 * configuration. Each pin widget can choose any input DACs and a mixer.
6200 * Each ADC is connected from a mixer of all inputs. This makes possible
6201 * 6-channel independent captures.
6202 *
6203 * In addition, an independent DAC for the multi-playback (not used in this
6204 * driver yet).
6205 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006206#define ALC882_DIGOUT_NID 0x06
6207#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006208
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006209static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006210 { 8, NULL }
6211};
6212
6213static hda_nid_t alc882_dac_nids[4] = {
6214 /* front, rear, clfe, rear_surr */
6215 0x02, 0x03, 0x04, 0x05
6216};
6217
Kailang Yangdf694da2005-12-05 19:42:22 +01006218/* identical with ALC880 */
6219#define alc882_adc_nids alc880_adc_nids
6220#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006221
Takashi Iwaie1406342008-02-11 18:32:32 +01006222static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6223static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6224
Linus Torvalds1da177e2005-04-16 15:20:36 -07006225/* input MUX */
6226/* FIXME: should be a matrix-type input source selection */
6227
6228static struct hda_input_mux alc882_capture_source = {
6229 .num_items = 4,
6230 .items = {
6231 { "Mic", 0x0 },
6232 { "Front Mic", 0x1 },
6233 { "Line", 0x2 },
6234 { "CD", 0x4 },
6235 },
6236};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006237
6238static struct hda_input_mux mb5_capture_source = {
6239 .num_items = 3,
6240 .items = {
6241 { "Mic", 0x1 },
6242 { "Line", 0x2 },
6243 { "CD", 0x4 },
6244 },
6245};
6246
Kailang Yangdf694da2005-12-05 19:42:22 +01006247/*
Kailang Yang272a5272007-05-14 11:00:38 +02006248 * 2ch mode
6249 */
6250static struct hda_verb alc882_3ST_ch2_init[] = {
6251 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6252 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6253 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6254 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6255 { } /* end */
6256};
6257
6258/*
6259 * 6ch mode
6260 */
6261static struct hda_verb alc882_3ST_ch6_init[] = {
6262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6264 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6265 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6266 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6267 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6268 { } /* end */
6269};
6270
6271static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6272 { 2, alc882_3ST_ch2_init },
6273 { 6, alc882_3ST_ch6_init },
6274};
6275
6276/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006277 * 6ch mode
6278 */
6279static struct hda_verb alc882_sixstack_ch6_init[] = {
6280 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6281 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6282 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6283 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6284 { } /* end */
6285};
6286
6287/*
6288 * 8ch mode
6289 */
6290static struct hda_verb alc882_sixstack_ch8_init[] = {
6291 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6292 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6293 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6294 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6295 { } /* end */
6296};
6297
6298static struct hda_channel_mode alc882_sixstack_modes[2] = {
6299 { 6, alc882_sixstack_ch6_init },
6300 { 8, alc882_sixstack_ch8_init },
6301};
6302
Takashi Iwai87350ad2007-08-16 18:19:38 +02006303/*
6304 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6305 */
6306
6307/*
6308 * 2ch mode
6309 */
6310static struct hda_verb alc885_mbp_ch2_init[] = {
6311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6312 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6313 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6314 { } /* end */
6315};
6316
6317/*
6318 * 6ch mode
6319 */
6320static struct hda_verb alc885_mbp_ch6_init[] = {
6321 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6322 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6323 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6324 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6325 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6326 { } /* end */
6327};
6328
6329static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6330 { 2, alc885_mbp_ch2_init },
6331 { 6, alc885_mbp_ch6_init },
6332};
6333
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006334/*
6335 * 2ch
6336 * Speakers/Woofer/HP = Front
6337 * LineIn = Input
6338 */
6339static struct hda_verb alc885_mb5_ch2_init[] = {
6340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6342 { } /* end */
6343};
6344
6345/*
6346 * 6ch mode
6347 * Speakers/HP = Front
6348 * Woofer = LFE
6349 * LineIn = Surround
6350 */
6351static struct hda_verb alc885_mb5_ch6_init[] = {
6352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6355 { } /* end */
6356};
6357
6358static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6359 { 2, alc885_mb5_ch2_init },
6360 { 6, alc885_mb5_ch6_init },
6361};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006362
Linus Torvalds1da177e2005-04-16 15:20:36 -07006363/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6364 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6365 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006366static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006368 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006369 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006370 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006371 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6372 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006373 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6374 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006375 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006376 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6385 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006386 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006387 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006388 { } /* end */
6389};
6390
Takashi Iwai87350ad2007-08-16 18:19:38 +02006391static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6393 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6394 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6395 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6397 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6399 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006400 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6402 { } /* end */
6403};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006404
6405static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6407 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6409 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6410 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6411 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6412 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6413 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006414 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6415 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6417 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6418 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6419 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6420 { } /* end */
6421};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006422
Kailang Yangbdd148a2007-05-08 15:19:08 +02006423static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6431 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006433 { } /* end */
6434};
6435
Kailang Yang272a5272007-05-14 11:00:38 +02006436static struct snd_kcontrol_new alc882_targa_mixer[] = {
6437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006446 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006449 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006450 { } /* end */
6451};
6452
6453/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6454 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6455 */
6456static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6458 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6460 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6461 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6462 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6464 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6466 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006469 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006470 { } /* end */
6471};
6472
Takashi Iwai914759b2007-09-06 14:52:04 +02006473static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6474 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6475 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6482 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006484 { } /* end */
6485};
6486
Kailang Yangdf694da2005-12-05 19:42:22 +01006487static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6488 {
6489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6490 .name = "Channel Mode",
6491 .info = alc_ch_mode_info,
6492 .get = alc_ch_mode_get,
6493 .put = alc_ch_mode_put,
6494 },
6495 { } /* end */
6496};
6497
Linus Torvalds1da177e2005-04-16 15:20:36 -07006498static struct hda_verb alc882_init_verbs[] = {
6499 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006507 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006511 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006515
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006516 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006519 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006520 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006524 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006527 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006528 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006529 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006530 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006531 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006532 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006534 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6535 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006537 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6538 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6541 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6542 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6543 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6544 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006545 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006547
6548 /* FIXME: use matrix-type input source selection */
6549 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6550 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006555 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006560 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6564 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6565 /* ADC1: mute amp left and right */
6566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006567 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006568 /* ADC2: mute amp left and right */
6569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006570 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006571 /* ADC3: mute amp left and right */
6572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006573 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006574
6575 { }
6576};
6577
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006578static struct hda_verb alc882_eapd_verbs[] = {
6579 /* change to EAPD mode */
6580 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006581 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006582 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006583};
6584
Tobin Davis9102cd12006-12-15 10:02:12 +01006585/* Mac Pro test */
6586static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6587 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6588 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006592 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006593 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6594 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006595 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006596 { } /* end */
6597};
6598
6599static struct hda_verb alc882_macpro_init_verbs[] = {
6600 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6604 /* Front Pin: output 0 (0x0c) */
6605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6607 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6608 /* Front Mic pin: input vref at 80% */
6609 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6611 /* Speaker: output */
6612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6614 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6615 /* Headphone output (output 0 - 0x0c) */
6616 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6617 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6618 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6619
6620 /* FIXME: use matrix-type input source selection */
6621 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6622 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6624 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6625 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6627 /* Input mixer2 */
6628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6632 /* Input mixer3 */
6633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6634 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6637 /* ADC1: mute amp left and right */
6638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6639 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6640 /* ADC2: mute amp left and right */
6641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6642 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6643 /* ADC3: mute amp left and right */
6644 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6645 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6646
6647 { }
6648};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006649
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006650/* Macbook 5,1 */
6651static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006652 /* DACs */
6653 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6654 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6655 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6656 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006657 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006661 /* Surround mixer */
6662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6665 /* LFE mixer */
6666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6669 /* HP mixer */
6670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6671 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6672 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6673 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006674 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006676 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6677 /* LFE Pin (0x0e) */
6678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6680 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6681 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006685 /* Front Mic pin: input vref at 80% */
6686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6688 /* Line In pin */
6689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6691
6692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6696 { }
6697};
6698
Takashi Iwai87350ad2007-08-16 18:19:38 +02006699/* Macbook Pro rev3 */
6700static struct hda_verb alc885_mbp3_init_verbs[] = {
6701 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6705 /* Rear mixer */
6706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6707 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6709 /* Front Pin: output 0 (0x0c) */
6710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6712 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6713 /* HP Pin: output 0 (0x0d) */
6714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6717 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6718 /* Mic (rear) pin: input vref at 80% */
6719 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6720 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6721 /* Front Mic pin: input vref at 80% */
6722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6724 /* Line In pin: use output 1 when in LineOut mode */
6725 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6727 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6728
6729 /* FIXME: use matrix-type input source selection */
6730 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6731 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6736 /* Input mixer2 */
6737 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6741 /* Input mixer3 */
6742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6746 /* ADC1: mute amp left and right */
6747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6748 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6749 /* ADC2: mute amp left and right */
6750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6752 /* ADC3: mute amp left and right */
6753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6755
6756 { }
6757};
6758
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006759/* iMac 24 mixer. */
6760static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6761 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6762 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6763 { } /* end */
6764};
6765
6766/* iMac 24 init verbs. */
6767static struct hda_verb alc885_imac24_init_verbs[] = {
6768 /* Internal speakers: output 0 (0x0c) */
6769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6770 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6771 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6772 /* Internal speakers: output 0 (0x0c) */
6773 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6775 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6776 /* Headphone: output 0 (0x0c) */
6777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6779 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6780 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6781 /* Front Mic: input vref at 80% */
6782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6784 { }
6785};
6786
6787/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006788static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006789{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006790 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006791
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006792 spec->autocfg.hp_pins[0] = 0x14;
6793 spec->autocfg.speaker_pins[0] = 0x18;
6794 spec->autocfg.speaker_pins[1] = 0x1a;
6795 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006796}
6797
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006798static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006799{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006800 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006801
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006802 spec->autocfg.hp_pins[0] = 0x15;
6803 spec->autocfg.speaker_pins[0] = 0x14;
6804 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006805}
6806
6807
Kailang Yang272a5272007-05-14 11:00:38 +02006808static struct hda_verb alc882_targa_verbs[] = {
6809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6811
6812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006814
Kailang Yang272a5272007-05-14 11:00:38 +02006815 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6816 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6817 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6818
6819 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6820 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6821 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6822 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6823 { } /* end */
6824};
6825
6826/* toggle speaker-output according to the hp-jack state */
6827static void alc882_targa_automute(struct hda_codec *codec)
6828{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006829 struct alc_spec *spec = codec->spec;
6830 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006831 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006832 spec->jack_present ? 1 : 3);
6833}
6834
6835static void alc882_targa_init_hook(struct hda_codec *codec)
6836{
6837 struct alc_spec *spec = codec->spec;
6838
6839 spec->autocfg.hp_pins[0] = 0x14;
6840 spec->autocfg.speaker_pins[0] = 0x1b;
6841 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006842}
6843
6844static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6845{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006846 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006847 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006848}
6849
6850static struct hda_verb alc882_asus_a7j_verbs[] = {
6851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6853
6854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006857
Kailang Yang272a5272007-05-14 11:00:38 +02006858 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6860 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6861
6862 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6863 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6864 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6865 { } /* end */
6866};
6867
Takashi Iwai914759b2007-09-06 14:52:04 +02006868static struct hda_verb alc882_asus_a7m_verbs[] = {
6869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6871
6872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006875
Takashi Iwai914759b2007-09-06 14:52:04 +02006876 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6878 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6879
6880 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6881 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6882 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6883 { } /* end */
6884};
6885
Tobin Davis9102cd12006-12-15 10:02:12 +01006886static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6887{
6888 unsigned int gpiostate, gpiomask, gpiodir;
6889
6890 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6891 AC_VERB_GET_GPIO_DATA, 0);
6892
6893 if (!muted)
6894 gpiostate |= (1 << pin);
6895 else
6896 gpiostate &= ~(1 << pin);
6897
6898 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6899 AC_VERB_GET_GPIO_MASK, 0);
6900 gpiomask |= (1 << pin);
6901
6902 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6903 AC_VERB_GET_GPIO_DIRECTION, 0);
6904 gpiodir |= (1 << pin);
6905
6906
6907 snd_hda_codec_write(codec, codec->afg, 0,
6908 AC_VERB_SET_GPIO_MASK, gpiomask);
6909 snd_hda_codec_write(codec, codec->afg, 0,
6910 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6911
6912 msleep(1);
6913
6914 snd_hda_codec_write(codec, codec->afg, 0,
6915 AC_VERB_SET_GPIO_DATA, gpiostate);
6916}
6917
Takashi Iwai7debbe52007-08-16 15:01:03 +02006918/* set up GPIO at initialization */
6919static void alc885_macpro_init_hook(struct hda_codec *codec)
6920{
6921 alc882_gpio_mute(codec, 0, 0);
6922 alc882_gpio_mute(codec, 1, 0);
6923}
6924
6925/* set up GPIO and update auto-muting at initialization */
6926static void alc885_imac24_init_hook(struct hda_codec *codec)
6927{
6928 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006929 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006930}
6931
Kailang Yangdf694da2005-12-05 19:42:22 +01006932/*
6933 * generic initialization of ADC, input mixers and output mixers
6934 */
6935static struct hda_verb alc882_auto_init_verbs[] = {
6936 /*
6937 * Unmute ADC0-2 and set the default input to mic-in
6938 */
6939 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6941 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6943 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6944 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6945
Takashi Iwaicb53c622007-08-10 17:21:45 +02006946 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006947 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006948 * Note: PASD motherboards uses the Line In 2 as the input for
6949 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006950 */
6951 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6955 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6956 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006957
6958 /*
6959 * Set up output mixers (0x0c - 0x0f)
6960 */
6961 /* set vol=0 to output mixers */
6962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6966 /* set up input amps for analog loopback */
6967 /* Amp Indices: DAC = 0, mixer = 1 */
6968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6970 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6971 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6972 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6974 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6975 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6976 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6977 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6978
6979 /* FIXME: use matrix-type input source selection */
6980 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6981 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6986 /* Input mixer2 */
6987 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6988 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6989 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6990 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6991 /* Input mixer3 */
6992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6996
6997 { }
6998};
6999
Takashi Iwaicb53c622007-08-10 17:21:45 +02007000#ifdef CONFIG_SND_HDA_POWER_SAVE
7001#define alc882_loopbacks alc880_loopbacks
7002#endif
7003
Kailang Yangdf694da2005-12-05 19:42:22 +01007004/* pcm configuration: identiacal with ALC880 */
7005#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7006#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7007#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7008#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7009
7010/*
7011 * configuration and preset
7012 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007013static const char *alc882_models[ALC882_MODEL_LAST] = {
7014 [ALC882_3ST_DIG] = "3stack-dig",
7015 [ALC882_6ST_DIG] = "6stack-dig",
7016 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007017 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007018 [ALC882_TARGA] = "targa",
7019 [ALC882_ASUS_A7J] = "asus-a7j",
7020 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007021 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007022 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007023 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007024 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007025 [ALC882_AUTO] = "auto",
7026};
7027
7028static struct snd_pci_quirk alc882_cfg_tbl[] = {
7029 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007030 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007031 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007032 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007033 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007034 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007035 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007036 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007037 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007038 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7039 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7040 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007041 {}
7042};
7043
7044static struct alc_config_preset alc882_presets[] = {
7045 [ALC882_3ST_DIG] = {
7046 .mixers = { alc882_base_mixer },
7047 .init_verbs = { alc882_init_verbs },
7048 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7049 .dac_nids = alc882_dac_nids,
7050 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007051 .dig_in_nid = ALC882_DIGIN_NID,
7052 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7053 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007054 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007055 .input_mux = &alc882_capture_source,
7056 },
7057 [ALC882_6ST_DIG] = {
7058 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7059 .init_verbs = { alc882_init_verbs },
7060 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7061 .dac_nids = alc882_dac_nids,
7062 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007063 .dig_in_nid = ALC882_DIGIN_NID,
7064 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7065 .channel_mode = alc882_sixstack_modes,
7066 .input_mux = &alc882_capture_source,
7067 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007068 [ALC882_ARIMA] = {
7069 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7070 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7071 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7072 .dac_nids = alc882_dac_nids,
7073 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7074 .channel_mode = alc882_sixstack_modes,
7075 .input_mux = &alc882_capture_source,
7076 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007077 [ALC882_W2JC] = {
7078 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7079 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7080 alc880_gpio1_init_verbs },
7081 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7082 .dac_nids = alc882_dac_nids,
7083 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7084 .channel_mode = alc880_threestack_modes,
7085 .need_dac_fix = 1,
7086 .input_mux = &alc882_capture_source,
7087 .dig_out_nid = ALC882_DIGOUT_NID,
7088 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007089 [ALC885_MBP3] = {
7090 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7091 .init_verbs = { alc885_mbp3_init_verbs,
7092 alc880_gpio1_init_verbs },
7093 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7094 .dac_nids = alc882_dac_nids,
7095 .channel_mode = alc885_mbp_6ch_modes,
7096 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7097 .input_mux = &alc882_capture_source,
7098 .dig_out_nid = ALC882_DIGOUT_NID,
7099 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007100 .unsol_event = alc_automute_amp_unsol_event,
7101 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007102 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007103 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007104 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007105 .init_verbs = { alc885_mb5_init_verbs,
7106 alc880_gpio1_init_verbs },
7107 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7108 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007109 .channel_mode = alc885_mb5_6ch_modes,
7110 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007111 .input_mux = &mb5_capture_source,
7112 .dig_out_nid = ALC882_DIGOUT_NID,
7113 .dig_in_nid = ALC882_DIGIN_NID,
7114 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007115 [ALC885_MACPRO] = {
7116 .mixers = { alc882_macpro_mixer },
7117 .init_verbs = { alc882_macpro_init_verbs },
7118 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7119 .dac_nids = alc882_dac_nids,
7120 .dig_out_nid = ALC882_DIGOUT_NID,
7121 .dig_in_nid = ALC882_DIGIN_NID,
7122 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7123 .channel_mode = alc882_ch_modes,
7124 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007125 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007126 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007127 [ALC885_IMAC24] = {
7128 .mixers = { alc885_imac24_mixer },
7129 .init_verbs = { alc885_imac24_init_verbs },
7130 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7131 .dac_nids = alc882_dac_nids,
7132 .dig_out_nid = ALC882_DIGOUT_NID,
7133 .dig_in_nid = ALC882_DIGIN_NID,
7134 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7135 .channel_mode = alc882_ch_modes,
7136 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007137 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007138 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007139 },
Kailang Yang272a5272007-05-14 11:00:38 +02007140 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007141 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007142 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7143 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7144 .dac_nids = alc882_dac_nids,
7145 .dig_out_nid = ALC882_DIGOUT_NID,
7146 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7147 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007148 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007149 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7150 .channel_mode = alc882_3ST_6ch_modes,
7151 .need_dac_fix = 1,
7152 .input_mux = &alc882_capture_source,
7153 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007154 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007155 },
7156 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007157 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007158 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7160 .dac_nids = alc882_dac_nids,
7161 .dig_out_nid = ALC882_DIGOUT_NID,
7162 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7163 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007164 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007165 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7166 .channel_mode = alc882_3ST_6ch_modes,
7167 .need_dac_fix = 1,
7168 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007169 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007170 [ALC882_ASUS_A7M] = {
7171 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7172 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7173 alc880_gpio1_init_verbs,
7174 alc882_asus_a7m_verbs },
7175 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7176 .dac_nids = alc882_dac_nids,
7177 .dig_out_nid = ALC882_DIGOUT_NID,
7178 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7179 .channel_mode = alc880_threestack_modes,
7180 .need_dac_fix = 1,
7181 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007182 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007183};
7184
7185
7186/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007187 * Pin config fixes
7188 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007189enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007190 PINFIX_ABIT_AW9D_MAX
7191};
7192
7193static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7194 { 0x15, 0x01080104 }, /* side */
7195 { 0x16, 0x01011012 }, /* rear */
7196 { 0x17, 0x01016011 }, /* clfe */
7197 { }
7198};
7199
7200static const struct alc_pincfg *alc882_pin_fixes[] = {
7201 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7202};
7203
7204static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7205 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7206 {}
7207};
7208
7209/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007210 * BIOS auto configuration
7211 */
7212static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7213 hda_nid_t nid, int pin_type,
7214 int dac_idx)
7215{
7216 /* set as output */
7217 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007218 int idx;
7219
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007220 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7222 idx = 4;
7223 else
7224 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007225 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7226
7227}
7228
7229static void alc882_auto_init_multi_out(struct hda_codec *codec)
7230{
7231 struct alc_spec *spec = codec->spec;
7232 int i;
7233
7234 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007235 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007236 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007237 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007238 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007239 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 }
7241}
7242
7243static void alc882_auto_init_hp_out(struct hda_codec *codec)
7244{
7245 struct alc_spec *spec = codec->spec;
7246 hda_nid_t pin;
7247
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007248 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007250 /* use dac 0 */
7251 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007252 pin = spec->autocfg.speaker_pins[0];
7253 if (pin)
7254 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007255}
7256
7257#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7258#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7259
7260static void alc882_auto_init_analog_input(struct hda_codec *codec)
7261{
7262 struct alc_spec *spec = codec->spec;
7263 int i;
7264
7265 for (i = 0; i < AUTO_PIN_LAST; i++) {
7266 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007267 if (!nid)
7268 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007269 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007270 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7271 snd_hda_codec_write(codec, nid, 0,
7272 AC_VERB_SET_AMP_GAIN_MUTE,
7273 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007274 }
7275}
7276
Takashi Iwaif511b012008-08-15 16:46:42 +02007277static void alc882_auto_init_input_src(struct hda_codec *codec)
7278{
7279 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007280 int c;
7281
7282 for (c = 0; c < spec->num_adc_nids; c++) {
7283 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7284 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007285 unsigned int mux_idx;
7286 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007287 int conns, mute, idx, item;
7288
7289 conns = snd_hda_get_connections(codec, nid, conn_list,
7290 ARRAY_SIZE(conn_list));
7291 if (conns < 0)
7292 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007293 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7294 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007295 for (idx = 0; idx < conns; idx++) {
7296 /* if the current connection is the selected one,
7297 * unmute it as default - otherwise mute it
7298 */
7299 mute = AMP_IN_MUTE(idx);
7300 for (item = 0; item < imux->num_items; item++) {
7301 if (imux->items[item].index == idx) {
7302 if (spec->cur_mux[c] == item)
7303 mute = AMP_IN_UNMUTE(idx);
7304 break;
7305 }
7306 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007307 /* check if we have a selector or mixer
7308 * we could check for the widget type instead, but
7309 * just check for Amp-In presence (in case of mixer
7310 * without amp-in there is something wrong, this
7311 * function shouldn't be used or capsrc nid is wrong)
7312 */
7313 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7314 snd_hda_codec_write(codec, nid, 0,
7315 AC_VERB_SET_AMP_GAIN_MUTE,
7316 mute);
7317 else if (mute != AMP_IN_MUTE(idx))
7318 snd_hda_codec_write(codec, nid, 0,
7319 AC_VERB_SET_CONNECT_SEL,
7320 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007321 }
7322 }
7323}
7324
Takashi Iwai776e1842007-08-29 15:07:11 +02007325/* add mic boosts if needed */
7326static int alc_auto_add_mic_boost(struct hda_codec *codec)
7327{
7328 struct alc_spec *spec = codec->spec;
7329 int err;
7330 hda_nid_t nid;
7331
7332 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007333 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007334 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7335 "Mic Boost",
7336 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7337 if (err < 0)
7338 return err;
7339 }
7340 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007341 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007342 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7343 "Front Mic Boost",
7344 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7345 if (err < 0)
7346 return err;
7347 }
7348 return 0;
7349}
7350
Kailang Yangdf694da2005-12-05 19:42:22 +01007351/* almost identical with ALC880 parser... */
7352static int alc882_parse_auto_config(struct hda_codec *codec)
7353{
7354 struct alc_spec *spec = codec->spec;
7355 int err = alc880_parse_auto_config(codec);
7356
7357 if (err < 0)
7358 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007359 else if (!err)
7360 return 0; /* no config found */
7361
7362 err = alc_auto_add_mic_boost(codec);
7363 if (err < 0)
7364 return err;
7365
7366 /* hack - override the init verbs */
7367 spec->init_verbs[0] = alc882_auto_init_verbs;
7368
7369 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007370}
7371
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007372/* additional initialization for auto-configuration model */
7373static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007374{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007375 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 alc882_auto_init_multi_out(codec);
7377 alc882_auto_init_hp_out(codec);
7378 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007379 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007380 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007381 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007382}
7383
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007384static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7385
Linus Torvalds1da177e2005-04-16 15:20:36 -07007386static int patch_alc882(struct hda_codec *codec)
7387{
7388 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007389 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007390
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007391 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392 if (spec == NULL)
7393 return -ENOMEM;
7394
Linus Torvalds1da177e2005-04-16 15:20:36 -07007395 codec->spec = spec;
7396
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007397 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7398 alc882_models,
7399 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007400
Kailang Yangdf694da2005-12-05 19:42:22 +01007401 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007402 /* Pick up systems that don't supply PCI SSID */
7403 switch (codec->subsystem_id) {
7404 case 0x106b0c00: /* Mac Pro */
7405 board_config = ALC885_MACPRO;
7406 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007407 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007408 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007409 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007410 board_config = ALC885_IMAC24;
7411 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007412 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007413 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007414 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007415 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007416 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007417 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007418 board_config = ALC885_MBP3;
7419 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007421 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7422 * seems not working, so apparently
7423 * no perfect solution yet
7424 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007425 board_config = ALC885_MB5;
7426 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007427 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007428 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007429 if (codec->revision_id == 0x100101 ||
7430 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007431 alc_free(codec);
7432 return patch_alc883(codec);
7433 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007434 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7435 "trying auto-probe from BIOS...\n",
7436 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007437 board_config = ALC882_AUTO;
7438 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007439 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007440
Takashi Iwaif95474e2007-07-10 00:47:43 +02007441 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7442
Kailang Yangdf694da2005-12-05 19:42:22 +01007443 if (board_config == ALC882_AUTO) {
7444 /* automatic parse from the BIOS config */
7445 err = alc882_parse_auto_config(codec);
7446 if (err < 0) {
7447 alc_free(codec);
7448 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007449 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450 printk(KERN_INFO
7451 "hda_codec: Cannot set up configuration "
7452 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007453 board_config = ALC882_3ST_DIG;
7454 }
7455 }
7456
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007457 err = snd_hda_attach_beep_device(codec, 0x1);
7458 if (err < 0) {
7459 alc_free(codec);
7460 return err;
7461 }
7462
Kailang Yangdf694da2005-12-05 19:42:22 +01007463 if (board_config != ALC882_AUTO)
7464 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007465
Kailang Yangdf694da2005-12-05 19:42:22 +01007466 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7467 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007468 /* FIXME: setup DAC5 */
7469 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7470 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007471
Kailang Yangdf694da2005-12-05 19:42:22 +01007472 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7473 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007474
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007475 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007476 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007477 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007478 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007479 /* get type */
7480 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007481 if (wcap != AC_WID_AUD_IN) {
7482 spec->adc_nids = alc882_adc_nids_alt;
7483 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007484 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007485 } else {
7486 spec->adc_nids = alc882_adc_nids;
7487 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007488 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007489 }
7490 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007491 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007492 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007493
Takashi Iwai2134ea42008-01-10 16:53:55 +01007494 spec->vmaster_nid = 0x0c;
7495
Linus Torvalds1da177e2005-04-16 15:20:36 -07007496 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007497 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007498 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007499#ifdef CONFIG_SND_HDA_POWER_SAVE
7500 if (!spec->loopback.amplist)
7501 spec->loopback.amplist = alc882_loopbacks;
7502#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007503 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007504
7505 return 0;
7506}
7507
7508/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007509 * ALC883 support
7510 *
7511 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7512 * configuration. Each pin widget can choose any input DACs and a mixer.
7513 * Each ADC is connected from a mixer of all inputs. This makes possible
7514 * 6-channel independent captures.
7515 *
7516 * In addition, an independent DAC for the multi-playback (not used in this
7517 * driver yet).
7518 */
7519#define ALC883_DIGOUT_NID 0x06
7520#define ALC883_DIGIN_NID 0x0a
7521
Wu Fengguang3ab90932008-11-17 09:51:09 +01007522#define ALC1200_DIGOUT_NID 0x10
7523
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007524static hda_nid_t alc883_dac_nids[4] = {
7525 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007526 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007527};
7528
7529static hda_nid_t alc883_adc_nids[2] = {
7530 /* ADC1-2 */
7531 0x08, 0x09,
7532};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007533
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007534static hda_nid_t alc883_adc_nids_alt[1] = {
7535 /* ADC1 */
7536 0x08,
7537};
7538
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007539static hda_nid_t alc883_adc_nids_rev[2] = {
7540 /* ADC2-1 */
7541 0x09, 0x08
7542};
7543
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007544#define alc889_adc_nids alc880_adc_nids
7545
Takashi Iwaie1406342008-02-11 18:32:32 +01007546static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7547
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007548static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7549
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007550#define alc889_capsrc_nids alc882_capsrc_nids
7551
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007552/* input MUX */
7553/* FIXME: should be a matrix-type input source selection */
7554
7555static struct hda_input_mux alc883_capture_source = {
7556 .num_items = 4,
7557 .items = {
7558 { "Mic", 0x0 },
7559 { "Front Mic", 0x1 },
7560 { "Line", 0x2 },
7561 { "CD", 0x4 },
7562 },
7563};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007564
Jiang zhe17bba1b2008-06-04 12:11:07 +02007565static struct hda_input_mux alc883_3stack_6ch_intel = {
7566 .num_items = 4,
7567 .items = {
7568 { "Mic", 0x1 },
7569 { "Front Mic", 0x0 },
7570 { "Line", 0x2 },
7571 { "CD", 0x4 },
7572 },
7573};
7574
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007575static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7576 .num_items = 2,
7577 .items = {
7578 { "Mic", 0x1 },
7579 { "Line", 0x2 },
7580 },
7581};
7582
Kailang Yang272a5272007-05-14 11:00:38 +02007583static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7584 .num_items = 4,
7585 .items = {
7586 { "Mic", 0x0 },
7587 { "iMic", 0x1 },
7588 { "Line", 0x2 },
7589 { "CD", 0x4 },
7590 },
7591};
7592
Jiang zhefb97dc62008-03-06 11:07:11 +01007593static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7594 .num_items = 2,
7595 .items = {
7596 { "Mic", 0x0 },
7597 { "Int Mic", 0x1 },
7598 },
7599};
7600
Kailang Yange2757d52008-08-26 13:17:46 +02007601static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7602 .num_items = 3,
7603 .items = {
7604 { "Mic", 0x0 },
7605 { "Front Mic", 0x1 },
7606 { "Line", 0x4 },
7607 },
7608};
7609
7610static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7611 .num_items = 2,
7612 .items = {
7613 { "Mic", 0x0 },
7614 { "Line", 0x2 },
7615 },
7616};
7617
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007618static struct hda_input_mux alc889A_mb31_capture_source = {
7619 .num_items = 2,
7620 .items = {
7621 { "Mic", 0x0 },
7622 /* Front Mic (0x01) unused */
7623 { "Line", 0x2 },
7624 /* Line 2 (0x03) unused */
7625 /* CD (0x04) unsused? */
7626 },
7627};
7628
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007629/*
7630 * 2ch mode
7631 */
7632static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7633 { 2, NULL }
7634};
7635
7636/*
7637 * 2ch mode
7638 */
7639static struct hda_verb alc883_3ST_ch2_init[] = {
7640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7642 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7643 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7644 { } /* end */
7645};
7646
7647/*
Tobin Davisb2011312007-09-17 12:45:11 +02007648 * 4ch mode
7649 */
7650static struct hda_verb alc883_3ST_ch4_init[] = {
7651 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7652 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7655 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7656 { } /* end */
7657};
7658
7659/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007660 * 6ch mode
7661 */
7662static struct hda_verb alc883_3ST_ch6_init[] = {
7663 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7665 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7666 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7667 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7668 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7669 { } /* end */
7670};
7671
Tobin Davisb2011312007-09-17 12:45:11 +02007672static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007673 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007674 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007675 { 6, alc883_3ST_ch6_init },
7676};
7677
7678/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007679 * 2ch mode
7680 */
7681static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7682 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7683 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7686 { } /* end */
7687};
7688
7689/*
7690 * 4ch mode
7691 */
7692static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7693 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7694 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7698 { } /* end */
7699};
7700
7701/*
7702 * 6ch mode
7703 */
7704static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7705 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7706 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7707 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7710 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7711 { } /* end */
7712};
7713
7714static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7715 { 2, alc883_3ST_ch2_intel_init },
7716 { 4, alc883_3ST_ch4_intel_init },
7717 { 6, alc883_3ST_ch6_intel_init },
7718};
7719
7720/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007721 * 6ch mode
7722 */
7723static struct hda_verb alc883_sixstack_ch6_init[] = {
7724 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7725 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7726 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7727 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7728 { } /* end */
7729};
7730
7731/*
7732 * 8ch mode
7733 */
7734static struct hda_verb alc883_sixstack_ch8_init[] = {
7735 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7736 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7737 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7738 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7739 { } /* end */
7740};
7741
7742static struct hda_channel_mode alc883_sixstack_modes[2] = {
7743 { 6, alc883_sixstack_ch6_init },
7744 { 8, alc883_sixstack_ch8_init },
7745};
7746
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007747/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7748static struct hda_verb alc889A_mb31_ch2_init[] = {
7749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7753 { } /* end */
7754};
7755
7756/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7757static struct hda_verb alc889A_mb31_ch4_init[] = {
7758 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7762 { } /* end */
7763};
7764
7765/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7766static struct hda_verb alc889A_mb31_ch5_init[] = {
7767 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7771 { } /* end */
7772};
7773
7774/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7775static struct hda_verb alc889A_mb31_ch6_init[] = {
7776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7777 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7780 { } /* end */
7781};
7782
7783static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7784 { 2, alc889A_mb31_ch2_init },
7785 { 4, alc889A_mb31_ch4_init },
7786 { 5, alc889A_mb31_ch5_init },
7787 { 6, alc889A_mb31_ch6_init },
7788};
7789
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007790static struct hda_verb alc883_medion_eapd_verbs[] = {
7791 /* eanable EAPD on medion laptop */
7792 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7793 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7794 { }
7795};
7796
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007797/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7798 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7799 */
7800
7801static struct snd_kcontrol_new alc883_base_mixer[] = {
7802 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7804 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7805 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7806 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7809 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7811 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7820 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007821 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007823 { } /* end */
7824};
7825
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007826static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7831 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7832 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007840 { } /* end */
7841};
7842
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007843static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007844 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7845 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7847 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7853 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007854 { } /* end */
7855};
7856
Jiang zhefb97dc62008-03-06 11:07:11 +01007857static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7861 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7866 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7867 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007868 { } /* end */
7869};
7870
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007871static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7875 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7876 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7878 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7882 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007883 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007884 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007885 { } /* end */
7886};
7887
7888static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7889 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7890 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7892 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7893 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7895 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7896 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007903 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007906 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007907 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007908 { } /* end */
7909};
7910
Jiang zhe17bba1b2008-06-04 12:11:07 +02007911static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7915 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7917 HDA_OUTPUT),
7918 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7919 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7920 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7921 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7927 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007932 { } /* end */
7933};
7934
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007935static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007938 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007939 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007940 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7941 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007942 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7943 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007950 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007953 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007955 { } /* end */
7956};
7957
Kailang Yangccc656c2006-10-17 12:32:26 +02007958static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7961 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7963 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007975 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007976};
Kailang Yangccc656c2006-10-17 12:32:26 +02007977
7978static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007987 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7989 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007990 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007991};
Kailang Yangccc656c2006-10-17 12:32:26 +02007992
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007993static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7994 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7995 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007996 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7997 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008002 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008003};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008004
Kailang Yang272a5272007-05-14 11:00:38 +02008005static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8006 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8007 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8010 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8013 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8014 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008015 { } /* end */
8016};
8017
8018static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8019 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8021 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008028 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008029};
Kailang Yang272a5272007-05-14 11:00:38 +02008030
Tobin Davis2880a8672007-08-07 11:50:26 +02008031static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008035 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8036 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008040 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008041};
Tobin Davis2880a8672007-08-07 11:50:26 +02008042
Kailang Yange2757d52008-08-26 13:17:46 +02008043static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8046 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8047 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8048 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8049 0x0d, 1, 0x0, HDA_OUTPUT),
8050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8053 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8054 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8064 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008065 { } /* end */
8066};
8067
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008068static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8069 /* Output mixers */
8070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8073 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8074 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8075 HDA_OUTPUT),
8076 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8077 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8078 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8079 /* Output switches */
8080 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8081 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8082 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8083 /* Boost mixers */
8084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8086 /* Input mixers */
8087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8091 { } /* end */
8092};
8093
Kailang Yange2757d52008-08-26 13:17:46 +02008094static struct hda_bind_ctls alc883_bind_cap_vol = {
8095 .ops = &snd_hda_bind_vol,
8096 .values = {
8097 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8098 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8099 0
8100 },
8101};
8102
8103static struct hda_bind_ctls alc883_bind_cap_switch = {
8104 .ops = &snd_hda_bind_sw,
8105 .values = {
8106 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8107 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8108 0
8109 },
8110};
8111
8112static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8117 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8119 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008121 { } /* end */
8122};
8123
8124static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008125 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8126 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8127 {
8128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8129 /* .name = "Capture Source", */
8130 .name = "Input Source",
8131 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008132 .info = alc_mux_enum_info,
8133 .get = alc_mux_enum_get,
8134 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008135 },
8136 { } /* end */
8137};
8138
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008139static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8140 {
8141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8142 .name = "Channel Mode",
8143 .info = alc_ch_mode_info,
8144 .get = alc_ch_mode_get,
8145 .put = alc_ch_mode_put,
8146 },
8147 { } /* end */
8148};
8149
8150static struct hda_verb alc883_init_verbs[] = {
8151 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008152 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008153 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8154 /* ADC2: mute amp left and right */
8155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8161 /* Rear mixer */
8162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8165 /* CLFE mixer */
8166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8168 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8169 /* Side mixer */
8170 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8173
Takashi Iwaicb53c622007-08-10 17:21:45 +02008174 /* mute analog input loopbacks */
8175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008180
8181 /* Front Pin: output 0 (0x0c) */
8182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8184 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8185 /* Rear Pin: output 1 (0x0d) */
8186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8189 /* CLFE Pin: output 2 (0x0e) */
8190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8192 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8193 /* Side Pin: output 3 (0x0f) */
8194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8196 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8197 /* Mic (rear) pin: input vref at 80% */
8198 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8200 /* Front Mic pin: input vref at 80% */
8201 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8203 /* Line In pin: input */
8204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8206 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8207 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8208 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 /* CD pin widget for input */
8211 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8212
8213 /* FIXME: use matrix-type input source selection */
8214 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8215 /* Input mixer2 */
8216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008220 /* Input mixer3 */
8221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008225 { }
8226};
8227
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008228/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008229static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008230{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008231 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008232
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008233 spec->autocfg.hp_pins[0] = 0x15;
8234 spec->autocfg.speaker_pins[0] = 0x14;
8235 spec->autocfg.speaker_pins[1] = 0x17;
8236 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008237}
8238
8239/* auto-toggle front mic */
8240/*
8241static void alc883_mitac_mic_automute(struct hda_codec *codec)
8242{
8243 unsigned int present;
8244 unsigned char bits;
8245
8246 present = snd_hda_codec_read(codec, 0x18, 0,
8247 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8248 bits = present ? HDA_AMP_MUTE : 0;
8249 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8250}
8251*/
8252
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008253static struct hda_verb alc883_mitac_verbs[] = {
8254 /* HP */
8255 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8257 /* Subwoofer */
8258 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8259 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8260
8261 /* enable unsolicited event */
8262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8263 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8264
8265 { } /* end */
8266};
8267
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008268static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008269 /* HP */
8270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8272 /* Int speaker */
8273 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8275
8276 /* enable unsolicited event */
8277 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008278 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008279
8280 { } /* end */
8281};
8282
Jiang zhefb97dc62008-03-06 11:07:11 +01008283static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8284 /* HP */
8285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8287 /* Subwoofer */
8288 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8290
8291 /* enable unsolicited event */
8292 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8293
8294 { } /* end */
8295};
8296
Kailang Yangccc656c2006-10-17 12:32:26 +02008297static struct hda_verb alc883_tagra_verbs[] = {
8298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8300
8301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8302 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008303
Kailang Yangccc656c2006-10-17 12:32:26 +02008304 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8305 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8306 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8307
8308 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008309 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8310 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8311 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008312
8313 { } /* end */
8314};
8315
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008316static struct hda_verb alc883_lenovo_101e_verbs[] = {
8317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8318 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8319 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8320 { } /* end */
8321};
8322
Kailang Yang272a5272007-05-14 11:00:38 +02008323static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8324 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8328 { } /* end */
8329};
8330
8331static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8337 { } /* end */
8338};
8339
Kailang Yang189609a2007-08-20 11:31:23 +02008340static struct hda_verb alc883_haier_w66_verbs[] = {
8341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8343
8344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8345
8346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8350 { } /* end */
8351};
8352
Kailang Yange2757d52008-08-26 13:17:46 +02008353static struct hda_verb alc888_lenovo_sky_verbs[] = {
8354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8362 { } /* end */
8363};
8364
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008365static struct hda_verb alc888_6st_dell_verbs[] = {
8366 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8367 { }
8368};
8369
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008370static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008371{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008372 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008373
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008374 spec->autocfg.hp_pins[0] = 0x1b;
8375 spec->autocfg.speaker_pins[0] = 0x14;
8376 spec->autocfg.speaker_pins[1] = 0x16;
8377 spec->autocfg.speaker_pins[2] = 0x18;
8378 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008379}
8380
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008381static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008382 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008383 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8384 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008385 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008386 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008387};
8388
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008389/*
8390 * 2ch mode
8391 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008392static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8395 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8396 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008397 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008398};
8399
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008400/*
8401 * 4ch mode
8402 */
8403static struct hda_verb alc888_3st_hp_4ch_init[] = {
8404 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8405 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8406 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8407 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8408 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8409 { } /* end */
8410};
8411
8412/*
8413 * 6ch mode
8414 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008415static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008416 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8417 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008418 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008419 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8420 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008421 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8422 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008423};
8424
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008425static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008426 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008427 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008428 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008429};
8430
Kailang Yang272a5272007-05-14 11:00:38 +02008431/* toggle front-jack and RCA according to the hp-jack state */
8432static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8433{
8434 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008435
Kailang Yang272a5272007-05-14 11:00:38 +02008436 present = snd_hda_codec_read(codec, 0x1b, 0,
8437 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008438 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8439 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8440 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8441 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008442}
8443
8444/* toggle RCA according to the front-jack state */
8445static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8446{
8447 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008448
Kailang Yang272a5272007-05-14 11:00:38 +02008449 present = snd_hda_codec_read(codec, 0x14, 0,
8450 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008451 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8452 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008453}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008454
Kailang Yang272a5272007-05-14 11:00:38 +02008455static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8456 unsigned int res)
8457{
8458 if ((res >> 26) == ALC880_HP_EVENT)
8459 alc888_lenovo_ms7195_front_automute(codec);
8460 if ((res >> 26) == ALC880_FRONT_EVENT)
8461 alc888_lenovo_ms7195_rca_automute(codec);
8462}
8463
8464static struct hda_verb alc883_medion_md2_verbs[] = {
8465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467
8468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8469
8470 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8471 { } /* end */
8472};
8473
8474/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008475static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008476{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008477 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008478
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 spec->autocfg.hp_pins[0] = 0x14;
8480 spec->autocfg.speaker_pins[0] = 0x15;
8481 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008482}
8483
Kailang Yangccc656c2006-10-17 12:32:26 +02008484/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008485#define alc883_tagra_init_hook alc882_targa_init_hook
8486#define alc883_tagra_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008487
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008488static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8489{
8490 unsigned int present;
8491
8492 present = snd_hda_codec_read(codec, 0x18, 0,
8493 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8494 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8495 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8496}
8497
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008498static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008499{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008500 struct alc_spec *spec = codec->spec;
8501
8502 spec->autocfg.hp_pins[0] = 0x15;
8503 spec->autocfg.speaker_pins[0] = 0x14;
8504 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008505 alc883_clevo_m720_mic_automute(codec);
8506}
8507
8508static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008509 unsigned int res)
8510{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008511 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008512 case ALC880_MIC_EVENT:
8513 alc883_clevo_m720_mic_automute(codec);
8514 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008515 default:
8516 alc_automute_amp_unsol_event(codec, res);
8517 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008518 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008519}
8520
Jiang zhefb97dc62008-03-06 11:07:11 +01008521/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008522static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008523{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008524 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008525
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008526 spec->autocfg.hp_pins[0] = 0x14;
8527 spec->autocfg.speaker_pins[0] = 0x15;
8528 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008529}
8530
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008531static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008533 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 spec->autocfg.hp_pins[0] = 0x1b;
8536 spec->autocfg.speaker_pins[0] = 0x14;
8537 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008538}
8539
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008540static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8541{
8542 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008543 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008544
8545 present = snd_hda_codec_read(codec, 0x14, 0,
8546 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008547 bits = present ? HDA_AMP_MUTE : 0;
8548 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8549 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008550}
8551
8552static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8553{
8554 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008555 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008556
8557 present = snd_hda_codec_read(codec, 0x1b, 0,
8558 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008559 bits = present ? HDA_AMP_MUTE : 0;
8560 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8561 HDA_AMP_MUTE, bits);
8562 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8563 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008564}
8565
8566static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8567 unsigned int res)
8568{
8569 if ((res >> 26) == ALC880_HP_EVENT)
8570 alc883_lenovo_101e_all_automute(codec);
8571 if ((res >> 26) == ALC880_FRONT_EVENT)
8572 alc883_lenovo_101e_ispeaker_automute(codec);
8573}
8574
Takashi Iwai676a9b52007-08-16 15:23:35 +02008575/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008576static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008577{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008578 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008579
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008580 spec->autocfg.hp_pins[0] = 0x14;
8581 spec->autocfg.speaker_pins[0] = 0x15;
8582 spec->autocfg.speaker_pins[1] = 0x16;
8583 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008584}
8585
Kailang Yangd1a991a2007-08-15 16:21:59 +02008586static struct hda_verb alc883_acer_eapd_verbs[] = {
8587 /* HP Pin: output 0 (0x0c) */
8588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8590 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8591 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8596 /* eanable EAPD on medion laptop */
8597 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8598 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008599 /* enable unsolicited event */
8600 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008601 { }
8602};
8603
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008607
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008608 spec->autocfg.hp_pins[0] = 0x1b;
8609 spec->autocfg.speaker_pins[0] = 0x14;
8610 spec->autocfg.speaker_pins[1] = 0x15;
8611 spec->autocfg.speaker_pins[2] = 0x16;
8612 spec->autocfg.speaker_pins[3] = 0x17;
8613 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008614}
8615
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008616static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008617{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008618 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008619
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008620 spec->autocfg.hp_pins[0] = 0x1b;
8621 spec->autocfg.speaker_pins[0] = 0x14;
8622 spec->autocfg.speaker_pins[1] = 0x15;
8623 spec->autocfg.speaker_pins[2] = 0x16;
8624 spec->autocfg.speaker_pins[3] = 0x17;
8625 spec->autocfg.speaker_pins[4] = 0x1a;
8626 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008627}
8628
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008629/*
8630 * generic initialization of ADC, input mixers and output mixers
8631 */
8632static struct hda_verb alc883_auto_init_verbs[] = {
8633 /*
8634 * Unmute ADC0-2 and set the default input to mic-in
8635 */
8636 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8638 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8640
Takashi Iwaicb53c622007-08-10 17:21:45 +02008641 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008642 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008643 * Note: PASD motherboards uses the Line In 2 as the input for
8644 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008645 */
8646 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008652
8653 /*
8654 * Set up output mixers (0x0c - 0x0f)
8655 */
8656 /* set vol=0 to output mixers */
8657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8660 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8661 /* set up input amps for analog loopback */
8662 /* Amp Indices: DAC = 0, mixer = 1 */
8663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8666 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8669 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8671 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8672 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8673
8674 /* FIXME: use matrix-type input source selection */
8675 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8676 /* Input mixer1 */
8677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008680 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8682 /* Input mixer2 */
8683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008686 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008688
8689 { }
8690};
8691
Kailang Yange2757d52008-08-26 13:17:46 +02008692static struct hda_verb alc888_asus_m90v_verbs[] = {
8693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8694 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8696 /* enable unsolicited event */
8697 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8698 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8699 { } /* end */
8700};
8701
8702static void alc883_nb_mic_automute(struct hda_codec *codec)
8703{
8704 unsigned int present;
8705
8706 present = snd_hda_codec_read(codec, 0x18, 0,
8707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8708 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8709 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8710 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8711 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8712}
8713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008715{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008716 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008717
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008718 spec->autocfg.hp_pins[0] = 0x1b;
8719 spec->autocfg.speaker_pins[0] = 0x14;
8720 spec->autocfg.speaker_pins[1] = 0x15;
8721 spec->autocfg.speaker_pins[2] = 0x16;
8722 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008723}
8724
8725static void alc883_mode2_unsol_event(struct hda_codec *codec,
8726 unsigned int res)
8727{
8728 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008729 case ALC880_MIC_EVENT:
8730 alc883_nb_mic_automute(codec);
8731 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008732 default:
8733 alc_sku_unsol_event(codec, res);
8734 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008735 }
8736}
8737
8738static void alc883_mode2_inithook(struct hda_codec *codec)
8739{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008740 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008741 alc883_nb_mic_automute(codec);
8742}
8743
8744static struct hda_verb alc888_asus_eee1601_verbs[] = {
8745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8750 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8751 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8752 /* enable unsolicited event */
8753 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8754 { } /* end */
8755};
8756
Kailang Yange2757d52008-08-26 13:17:46 +02008757static void alc883_eee1601_inithook(struct hda_codec *codec)
8758{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008759 struct alc_spec *spec = codec->spec;
8760
8761 spec->autocfg.hp_pins[0] = 0x14;
8762 spec->autocfg.speaker_pins[0] = 0x1b;
8763 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008764}
8765
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008766static struct hda_verb alc889A_mb31_verbs[] = {
8767 /* Init rear pin (used as headphone output) */
8768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8770 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8771 /* Init line pin (used as output in 4ch and 6ch mode) */
8772 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8773 /* Init line 2 pin (used as headphone out by default) */
8774 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8775 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8776 { } /* end */
8777};
8778
8779/* Mute speakers according to the headphone jack state */
8780static void alc889A_mb31_automute(struct hda_codec *codec)
8781{
8782 unsigned int present;
8783
8784 /* Mute only in 2ch or 4ch mode */
8785 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8786 == 0x00) {
8787 present = snd_hda_codec_read(codec, 0x15, 0,
8788 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8790 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8791 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8792 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8793 }
8794}
8795
8796static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8797{
8798 if ((res >> 26) == ALC880_HP_EVENT)
8799 alc889A_mb31_automute(codec);
8800}
8801
Takashi Iwaicb53c622007-08-10 17:21:45 +02008802#ifdef CONFIG_SND_HDA_POWER_SAVE
8803#define alc883_loopbacks alc880_loopbacks
8804#endif
8805
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008806/* pcm configuration: identiacal with ALC880 */
8807#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8808#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008809#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008810#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8811#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8812
8813/*
8814 * configuration and preset
8815 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008816static const char *alc883_models[ALC883_MODEL_LAST] = {
8817 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8818 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8819 [ALC883_3ST_6ch] = "3stack-6ch",
8820 [ALC883_6ST_DIG] = "6stack-dig",
8821 [ALC883_TARGA_DIG] = "targa-dig",
8822 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008823 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02008824 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008825 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Hector Martin3b315d72009-06-02 10:54:19 +02008826 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008827 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008828 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008829 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008830 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008831 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8832 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008833 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008834 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008835 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008836 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008837 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008838 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008839 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008840 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008841 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008842 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008843 [ALC889A_MB31] = "mb31",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008844 [ALC883_AUTO] = "auto",
8845};
8846
8847static struct snd_pci_quirk alc883_cfg_tbl[] = {
8848 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008849 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008850 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008851 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008852 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8853 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008854 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008855 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8856 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008857 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8858 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008859 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8860 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008861 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008862 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008863 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8864 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008865 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8866 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008867 /* default Acer -- disabled as it causes more problems.
8868 * model=auto should work fine now
8869 */
8870 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008871 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008872 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008873 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8874 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008875 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008876 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008877 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008878 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008879 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008880 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008881 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008882 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008883 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008884 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008885 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008886 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8887 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008888 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008889 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008890 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008891 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8892 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8893 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008894 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008895 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008896 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008897 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8898 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8899 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8900 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8901 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8902 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8903 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8904 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8905 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008906 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8907 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008908 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008909 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008910 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008911 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008912 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008913 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008914 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008915 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8916 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008917 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008918 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008919 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008920 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008921 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008922 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008923 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008924 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008925 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008926 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8927 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008928 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008929 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008930 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008931 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008932 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008933 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8934 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008935 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008936 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008937 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008938 {}
8939};
8940
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008941static hda_nid_t alc883_slave_dig_outs[] = {
8942 ALC1200_DIGOUT_NID, 0,
8943};
8944
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008945static hda_nid_t alc1200_slave_dig_outs[] = {
8946 ALC883_DIGOUT_NID, 0,
8947};
8948
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008949static struct alc_config_preset alc883_presets[] = {
8950 [ALC883_3ST_2ch_DIG] = {
8951 .mixers = { alc883_3ST_2ch_mixer },
8952 .init_verbs = { alc883_init_verbs },
8953 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8954 .dac_nids = alc883_dac_nids,
8955 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008956 .dig_in_nid = ALC883_DIGIN_NID,
8957 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8958 .channel_mode = alc883_3ST_2ch_modes,
8959 .input_mux = &alc883_capture_source,
8960 },
8961 [ALC883_3ST_6ch_DIG] = {
8962 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8963 .init_verbs = { alc883_init_verbs },
8964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8965 .dac_nids = alc883_dac_nids,
8966 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008967 .dig_in_nid = ALC883_DIGIN_NID,
8968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8969 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008970 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008971 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008972 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008973 [ALC883_3ST_6ch] = {
8974 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8975 .init_verbs = { alc883_init_verbs },
8976 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8977 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8979 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008980 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008981 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008982 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008983 [ALC883_3ST_6ch_INTEL] = {
8984 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8985 .init_verbs = { alc883_init_verbs },
8986 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8987 .dac_nids = alc883_dac_nids,
8988 .dig_out_nid = ALC883_DIGOUT_NID,
8989 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008990 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8992 .channel_mode = alc883_3ST_6ch_intel_modes,
8993 .need_dac_fix = 1,
8994 .input_mux = &alc883_3stack_6ch_intel,
8995 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008996 [ALC883_6ST_DIG] = {
8997 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8998 .init_verbs = { alc883_init_verbs },
8999 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9000 .dac_nids = alc883_dac_nids,
9001 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009002 .dig_in_nid = ALC883_DIGIN_NID,
9003 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9004 .channel_mode = alc883_sixstack_modes,
9005 .input_mux = &alc883_capture_source,
9006 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009007 [ALC883_TARGA_DIG] = {
9008 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
9009 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
9010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9011 .dac_nids = alc883_dac_nids,
9012 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009013 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9014 .channel_mode = alc883_3ST_6ch_modes,
9015 .need_dac_fix = 1,
9016 .input_mux = &alc883_capture_source,
9017 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009018 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009019 },
9020 [ALC883_TARGA_2ch_DIG] = {
9021 .mixers = { alc883_tagra_2ch_mixer},
9022 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
9023 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9024 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009025 .adc_nids = alc883_adc_nids_alt,
9026 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009027 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009028 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9029 .channel_mode = alc883_3ST_2ch_modes,
9030 .input_mux = &alc883_capture_source,
9031 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009032 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009033 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009034 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009035 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009036 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9037 * and the headphone jack. Turn this on and rely on the
9038 * standard mute methods whenever the user wants to turn
9039 * these outputs off.
9040 */
9041 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9042 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9043 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009044 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9045 .channel_mode = alc883_3ST_2ch_modes,
9046 .input_mux = &alc883_capture_source,
9047 },
Tobin Davis2880a8672007-08-07 11:50:26 +02009048 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009049 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009050 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02009051 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9052 .dac_nids = alc883_dac_nids,
9053 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02009054 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9055 .channel_mode = alc883_3ST_2ch_modes,
9056 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009057 .unsol_event = alc_automute_amp_unsol_event,
9058 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009059 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009060 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009061 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009062 alc883_chmode_mixer },
9063 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9064 alc888_acer_aspire_4930g_verbs },
9065 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9066 .dac_nids = alc883_dac_nids,
9067 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9068 .adc_nids = alc883_adc_nids_rev,
9069 .capsrc_nids = alc883_capsrc_nids_rev,
9070 .dig_out_nid = ALC883_DIGOUT_NID,
9071 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9072 .channel_mode = alc883_3ST_6ch_modes,
9073 .need_dac_fix = 1,
9074 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009075 ARRAY_SIZE(alc888_2_capture_sources),
9076 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009077 .unsol_event = alc_automute_amp_unsol_event,
9078 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009079 },
Hector Martin3b315d72009-06-02 10:54:19 +02009080 [ALC888_ACER_ASPIRE_8930G] = {
9081 .mixers = { alc888_base_mixer,
9082 alc883_chmode_mixer },
9083 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9084 alc888_acer_aspire_8930g_verbs },
9085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9086 .dac_nids = alc883_dac_nids,
9087 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9088 .adc_nids = alc883_adc_nids_rev,
9089 .capsrc_nids = alc883_capsrc_nids_rev,
9090 .dig_out_nid = ALC883_DIGOUT_NID,
9091 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9092 .channel_mode = alc883_3ST_6ch_modes,
9093 .need_dac_fix = 1,
9094 .const_channel_count = 6,
9095 .num_mux_defs =
9096 ARRAY_SIZE(alc888_2_capture_sources),
9097 .input_mux = alc888_2_capture_sources,
9098 .unsol_event = alc_automute_amp_unsol_event,
9099 .init_hook = alc888_acer_aspire_8930g_init_hook,
9100 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009101 [ALC883_MEDION] = {
9102 .mixers = { alc883_fivestack_mixer,
9103 alc883_chmode_mixer },
9104 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009105 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9107 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009108 .adc_nids = alc883_adc_nids_alt,
9109 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009110 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9111 .channel_mode = alc883_sixstack_modes,
9112 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009113 },
Kailang Yang272a5272007-05-14 11:00:38 +02009114 [ALC883_MEDION_MD2] = {
9115 .mixers = { alc883_medion_md2_mixer},
9116 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9118 .dac_nids = alc883_dac_nids,
9119 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009120 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9121 .channel_mode = alc883_3ST_2ch_modes,
9122 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009123 .unsol_event = alc_automute_amp_unsol_event,
9124 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009125 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009126 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009127 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009128 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9129 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9130 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009131 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9132 .channel_mode = alc883_3ST_2ch_modes,
9133 .input_mux = &alc883_capture_source,
9134 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009135 [ALC883_CLEVO_M720] = {
9136 .mixers = { alc883_clevo_m720_mixer },
9137 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9139 .dac_nids = alc883_dac_nids,
9140 .dig_out_nid = ALC883_DIGOUT_NID,
9141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9142 .channel_mode = alc883_3ST_2ch_modes,
9143 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009144 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009145 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009146 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009147 [ALC883_LENOVO_101E_2ch] = {
9148 .mixers = { alc883_lenovo_101e_2ch_mixer},
9149 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9150 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9151 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009152 .adc_nids = alc883_adc_nids_alt,
9153 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9155 .channel_mode = alc883_3ST_2ch_modes,
9156 .input_mux = &alc883_lenovo_101e_capture_source,
9157 .unsol_event = alc883_lenovo_101e_unsol_event,
9158 .init_hook = alc883_lenovo_101e_all_automute,
9159 },
Kailang Yang272a5272007-05-14 11:00:38 +02009160 [ALC883_LENOVO_NB0763] = {
9161 .mixers = { alc883_lenovo_nb0763_mixer },
9162 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9163 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9164 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009165 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9166 .channel_mode = alc883_3ST_2ch_modes,
9167 .need_dac_fix = 1,
9168 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009169 .unsol_event = alc_automute_amp_unsol_event,
9170 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009171 },
9172 [ALC888_LENOVO_MS7195_DIG] = {
9173 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9174 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9175 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9176 .dac_nids = alc883_dac_nids,
9177 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009178 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9179 .channel_mode = alc883_3ST_6ch_modes,
9180 .need_dac_fix = 1,
9181 .input_mux = &alc883_capture_source,
9182 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9183 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009184 },
9185 [ALC883_HAIER_W66] = {
9186 .mixers = { alc883_tagra_2ch_mixer},
9187 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9189 .dac_nids = alc883_dac_nids,
9190 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9192 .channel_mode = alc883_3ST_2ch_modes,
9193 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009194 .unsol_event = alc_automute_amp_unsol_event,
9195 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009196 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009197 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009198 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009199 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009202 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9203 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009204 .need_dac_fix = 1,
9205 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009206 .unsol_event = alc_automute_amp_unsol_event,
9207 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009208 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009209 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009210 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009211 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9213 .dac_nids = alc883_dac_nids,
9214 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009215 .dig_in_nid = ALC883_DIGIN_NID,
9216 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9217 .channel_mode = alc883_sixstack_modes,
9218 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009219 .unsol_event = alc_automute_amp_unsol_event,
9220 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009221 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009222 [ALC883_MITAC] = {
9223 .mixers = { alc883_mitac_mixer },
9224 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9225 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9226 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9228 .channel_mode = alc883_3ST_2ch_modes,
9229 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009230 .unsol_event = alc_automute_amp_unsol_event,
9231 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009232 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009233 [ALC883_FUJITSU_PI2515] = {
9234 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9235 .init_verbs = { alc883_init_verbs,
9236 alc883_2ch_fujitsu_pi2515_verbs},
9237 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9238 .dac_nids = alc883_dac_nids,
9239 .dig_out_nid = ALC883_DIGOUT_NID,
9240 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9241 .channel_mode = alc883_3ST_2ch_modes,
9242 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009243 .unsol_event = alc_automute_amp_unsol_event,
9244 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009245 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009246 [ALC888_FUJITSU_XA3530] = {
9247 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9248 .init_verbs = { alc883_init_verbs,
9249 alc888_fujitsu_xa3530_verbs },
9250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9251 .dac_nids = alc883_dac_nids,
9252 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9253 .adc_nids = alc883_adc_nids_rev,
9254 .capsrc_nids = alc883_capsrc_nids_rev,
9255 .dig_out_nid = ALC883_DIGOUT_NID,
9256 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9257 .channel_mode = alc888_4ST_8ch_intel_modes,
9258 .num_mux_defs =
9259 ARRAY_SIZE(alc888_2_capture_sources),
9260 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009261 .unsol_event = alc_automute_amp_unsol_event,
9262 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009263 },
Kailang Yange2757d52008-08-26 13:17:46 +02009264 [ALC888_LENOVO_SKY] = {
9265 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9266 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9268 .dac_nids = alc883_dac_nids,
9269 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009270 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9271 .channel_mode = alc883_sixstack_modes,
9272 .need_dac_fix = 1,
9273 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009274 .unsol_event = alc_automute_amp_unsol_event,
9275 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009276 },
9277 [ALC888_ASUS_M90V] = {
9278 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9279 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9280 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9281 .dac_nids = alc883_dac_nids,
9282 .dig_out_nid = ALC883_DIGOUT_NID,
9283 .dig_in_nid = ALC883_DIGIN_NID,
9284 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9285 .channel_mode = alc883_3ST_6ch_modes,
9286 .need_dac_fix = 1,
9287 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9288 .unsol_event = alc883_mode2_unsol_event,
9289 .init_hook = alc883_mode2_inithook,
9290 },
9291 [ALC888_ASUS_EEE1601] = {
9292 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009293 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009294 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9295 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9296 .dac_nids = alc883_dac_nids,
9297 .dig_out_nid = ALC883_DIGOUT_NID,
9298 .dig_in_nid = ALC883_DIGIN_NID,
9299 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9300 .channel_mode = alc883_3ST_2ch_modes,
9301 .need_dac_fix = 1,
9302 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009303 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009304 .init_hook = alc883_eee1601_inithook,
9305 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009306 [ALC1200_ASUS_P5Q] = {
9307 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9308 .init_verbs = { alc883_init_verbs },
9309 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9310 .dac_nids = alc883_dac_nids,
9311 .dig_out_nid = ALC1200_DIGOUT_NID,
9312 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009313 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009314 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9315 .channel_mode = alc883_sixstack_modes,
9316 .input_mux = &alc883_capture_source,
9317 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009318 [ALC889A_MB31] = {
9319 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9320 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9321 alc880_gpio1_init_verbs },
9322 .adc_nids = alc883_adc_nids,
9323 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9324 .dac_nids = alc883_dac_nids,
9325 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9326 .channel_mode = alc889A_mb31_6ch_modes,
9327 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9328 .input_mux = &alc889A_mb31_capture_source,
9329 .dig_out_nid = ALC883_DIGOUT_NID,
9330 .unsol_event = alc889A_mb31_unsol_event,
9331 .init_hook = alc889A_mb31_automute,
9332 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009333};
9334
9335
9336/*
9337 * BIOS auto configuration
9338 */
9339static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9340 hda_nid_t nid, int pin_type,
9341 int dac_idx)
9342{
9343 /* set as output */
9344 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009345 int idx;
9346
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009347 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009348 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9349 idx = 4;
9350 else
9351 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009352 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9353
9354}
9355
9356static void alc883_auto_init_multi_out(struct hda_codec *codec)
9357{
9358 struct alc_spec *spec = codec->spec;
9359 int i;
9360
9361 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009362 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009363 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009364 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009365 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009366 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009367 }
9368}
9369
9370static void alc883_auto_init_hp_out(struct hda_codec *codec)
9371{
9372 struct alc_spec *spec = codec->spec;
9373 hda_nid_t pin;
9374
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009375 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009376 if (pin) /* connect to front */
9377 /* use dac 0 */
9378 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009379 pin = spec->autocfg.speaker_pins[0];
9380 if (pin)
9381 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009382}
9383
9384#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9385#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9386
9387static void alc883_auto_init_analog_input(struct hda_codec *codec)
9388{
9389 struct alc_spec *spec = codec->spec;
9390 int i;
9391
9392 for (i = 0; i < AUTO_PIN_LAST; i++) {
9393 hda_nid_t nid = spec->autocfg.input_pins[i];
9394 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009395 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009396 if (nid != ALC883_PIN_CD_NID &&
9397 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009398 snd_hda_codec_write(codec, nid, 0,
9399 AC_VERB_SET_AMP_GAIN_MUTE,
9400 AMP_OUT_MUTE);
9401 }
9402 }
9403}
9404
Takashi Iwaif511b012008-08-15 16:46:42 +02009405#define alc883_auto_init_input_src alc882_auto_init_input_src
9406
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009407/* almost identical with ALC880 parser... */
9408static int alc883_parse_auto_config(struct hda_codec *codec)
9409{
9410 struct alc_spec *spec = codec->spec;
9411 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009412 struct auto_pin_cfg *cfg = &spec->autocfg;
9413 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009414
9415 if (err < 0)
9416 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009417 else if (!err)
9418 return 0; /* no config found */
9419
9420 err = alc_auto_add_mic_boost(codec);
9421 if (err < 0)
9422 return err;
9423
9424 /* hack - override the init verbs */
9425 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009426
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009427 /* setup input_mux for ALC889 */
9428 if (codec->vendor_id == 0x10ec0889) {
9429 /* digital-mic input pin is excluded in alc880_auto_create..()
9430 * because it's under 0x18
9431 */
9432 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9433 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9434 struct hda_input_mux *imux = &spec->private_imux[0];
9435 for (i = 1; i < 3; i++)
9436 memcpy(&spec->private_imux[i],
9437 &spec->private_imux[0],
9438 sizeof(spec->private_imux[0]));
9439 imux->items[imux->num_items].label = "Int DMic";
9440 imux->items[imux->num_items].index = 0x0b;
9441 imux->num_items++;
9442 spec->num_mux_defs = 3;
9443 spec->input_mux = spec->private_imux;
9444 }
9445 }
9446
Takashi Iwai776e1842007-08-29 15:07:11 +02009447 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009448}
9449
9450/* additional initialization for auto-configuration model */
9451static void alc883_auto_init(struct hda_codec *codec)
9452{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009453 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009454 alc883_auto_init_multi_out(codec);
9455 alc883_auto_init_hp_out(codec);
9456 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009457 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009458 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009459 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009460}
9461
9462static int patch_alc883(struct hda_codec *codec)
9463{
9464 struct alc_spec *spec;
9465 int err, board_config;
9466
9467 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9468 if (spec == NULL)
9469 return -ENOMEM;
9470
9471 codec->spec = spec;
9472
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009473 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9474
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009475 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9476 alc883_models,
9477 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009478 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9479 /* Pick up systems that don't supply PCI SSID */
9480 switch (codec->subsystem_id) {
9481 case 0x106b3600: /* Macbook 3.1 */
9482 board_config = ALC889A_MB31;
9483 break;
9484 default:
9485 printk(KERN_INFO
9486 "hda_codec: Unknown model for %s, trying "
9487 "auto-probe from BIOS...\n", codec->chip_name);
9488 board_config = ALC883_AUTO;
9489 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009490 }
9491
9492 if (board_config == ALC883_AUTO) {
9493 /* automatic parse from the BIOS config */
9494 err = alc883_parse_auto_config(codec);
9495 if (err < 0) {
9496 alc_free(codec);
9497 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009498 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499 printk(KERN_INFO
9500 "hda_codec: Cannot set up configuration "
9501 "from BIOS. Using base mode...\n");
9502 board_config = ALC883_3ST_2ch_DIG;
9503 }
9504 }
9505
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009506 err = snd_hda_attach_beep_device(codec, 0x1);
9507 if (err < 0) {
9508 alc_free(codec);
9509 return err;
9510 }
9511
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009512 if (board_config != ALC883_AUTO)
9513 setup_preset(spec, &alc883_presets[board_config]);
9514
Kailang Yang2f893282008-05-27 12:14:47 +02009515 switch (codec->vendor_id) {
9516 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009517 if (!spec->num_adc_nids) {
9518 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9519 spec->adc_nids = alc883_adc_nids;
9520 }
9521 if (!spec->capsrc_nids)
9522 spec->capsrc_nids = alc883_capsrc_nids;
9523 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009524 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009525 break;
9526 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009527 if (!spec->num_adc_nids) {
9528 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9529 spec->adc_nids = alc889_adc_nids;
9530 }
9531 if (!spec->capsrc_nids)
9532 spec->capsrc_nids = alc889_capsrc_nids;
9533 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9534 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009535 break;
9536 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009537 if (!spec->num_adc_nids) {
9538 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9539 spec->adc_nids = alc883_adc_nids;
9540 }
9541 if (!spec->capsrc_nids)
9542 spec->capsrc_nids = alc883_capsrc_nids;
9543 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009544 break;
9545 }
9546
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009547 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9548 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009549 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009550
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009551 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9552 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9553
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009554 if (!spec->cap_mixer)
9555 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009556 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557
Takashi Iwai2134ea42008-01-10 16:53:55 +01009558 spec->vmaster_nid = 0x0c;
9559
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009560 codec->patch_ops = alc_patch_ops;
9561 if (board_config == ALC883_AUTO)
9562 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009563
Takashi Iwaicb53c622007-08-10 17:21:45 +02009564#ifdef CONFIG_SND_HDA_POWER_SAVE
9565 if (!spec->loopback.amplist)
9566 spec->loopback.amplist = alc883_loopbacks;
9567#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009568 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009569
9570 return 0;
9571}
9572
9573/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009574 * ALC262 support
9575 */
9576
9577#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9578#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9579
9580#define alc262_dac_nids alc260_dac_nids
9581#define alc262_adc_nids alc882_adc_nids
9582#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009583#define alc262_capsrc_nids alc882_capsrc_nids
9584#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009585
9586#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009587#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009588
Kailang Yang4e555fe2008-08-26 13:05:55 +02009589static hda_nid_t alc262_dmic_adc_nids[1] = {
9590 /* ADC0 */
9591 0x09
9592};
9593
9594static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9595
Kailang Yangdf694da2005-12-05 19:42:22 +01009596static struct snd_kcontrol_new alc262_base_mixer[] = {
9597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9598 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009605 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009606 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9607 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009608 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9611 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9612 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009613 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009614};
9615
Takashi Iwaice875f02008-01-28 18:17:43 +01009616/* update HP, line and mono-out pins according to the master switch */
9617static void alc262_hp_master_update(struct hda_codec *codec)
9618{
9619 struct alc_spec *spec = codec->spec;
9620 int val = spec->master_sw;
9621
9622 /* HP & line-out */
9623 snd_hda_codec_write_cache(codec, 0x1b, 0,
9624 AC_VERB_SET_PIN_WIDGET_CONTROL,
9625 val ? PIN_HP : 0);
9626 snd_hda_codec_write_cache(codec, 0x15, 0,
9627 AC_VERB_SET_PIN_WIDGET_CONTROL,
9628 val ? PIN_HP : 0);
9629 /* mono (speaker) depending on the HP jack sense */
9630 val = val && !spec->jack_present;
9631 snd_hda_codec_write_cache(codec, 0x16, 0,
9632 AC_VERB_SET_PIN_WIDGET_CONTROL,
9633 val ? PIN_OUT : 0);
9634}
9635
9636static void alc262_hp_bpc_automute(struct hda_codec *codec)
9637{
9638 struct alc_spec *spec = codec->spec;
9639 unsigned int presence;
9640 presence = snd_hda_codec_read(codec, 0x1b, 0,
9641 AC_VERB_GET_PIN_SENSE, 0);
9642 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9643 alc262_hp_master_update(codec);
9644}
9645
9646static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9647{
9648 if ((res >> 26) != ALC880_HP_EVENT)
9649 return;
9650 alc262_hp_bpc_automute(codec);
9651}
9652
9653static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9654{
9655 struct alc_spec *spec = codec->spec;
9656 unsigned int presence;
9657 presence = snd_hda_codec_read(codec, 0x15, 0,
9658 AC_VERB_GET_PIN_SENSE, 0);
9659 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9660 alc262_hp_master_update(codec);
9661}
9662
9663static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9664 unsigned int res)
9665{
9666 if ((res >> 26) != ALC880_HP_EVENT)
9667 return;
9668 alc262_hp_wildwest_automute(codec);
9669}
9670
Takashi Iwaib72519b2009-05-08 14:31:55 +02009671#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009672
9673static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9674 struct snd_ctl_elem_value *ucontrol)
9675{
9676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9677 struct alc_spec *spec = codec->spec;
9678 int val = !!*ucontrol->value.integer.value;
9679
9680 if (val == spec->master_sw)
9681 return 0;
9682 spec->master_sw = val;
9683 alc262_hp_master_update(codec);
9684 return 1;
9685}
9686
Takashi Iwaib72519b2009-05-08 14:31:55 +02009687#define ALC262_HP_MASTER_SWITCH \
9688 { \
9689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9690 .name = "Master Playback Switch", \
9691 .info = snd_ctl_boolean_mono_info, \
9692 .get = alc262_hp_master_sw_get, \
9693 .put = alc262_hp_master_sw_put, \
9694 }
9695
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009696static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009697 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9699 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9700 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009701 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9702 HDA_OUTPUT),
9703 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9704 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009708 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009710 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9713 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9714 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009715 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9716 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9717 { } /* end */
9718};
9719
Kailang Yangcd7509a2007-01-26 18:33:17 +01009720static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009721 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9723 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009726 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9727 HDA_OUTPUT),
9728 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9729 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009732 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009733 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9734 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9735 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9736 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009737 { } /* end */
9738};
9739
9740static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9741 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9742 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009743 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009744 { } /* end */
9745};
9746
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009747/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009748static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009749{
9750 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009751
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009752 spec->autocfg.hp_pins[0] = 0x15;
9753 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9754 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009755}
9756
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009757static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009758 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9759 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9765 { } /* end */
9766};
9767
9768static struct hda_verb alc262_hp_t5735_verbs[] = {
9769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9771
9772 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9773 { }
9774};
9775
Kailang Yang8c427222008-01-10 13:03:59 +01009776static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009777 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009779 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9780 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9783 { } /* end */
9784};
9785
9786static struct hda_verb alc262_hp_rp5700_verbs[] = {
9787 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9790 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9792 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9796 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9797 {}
9798};
9799
9800static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9801 .num_items = 1,
9802 .items = {
9803 { "Line", 0x1 },
9804 },
9805};
9806
Takashi Iwai42171c12009-05-08 14:11:43 +02009807/* bind hp and internal speaker mute (with plug check) as master switch */
9808static void alc262_hippo_master_update(struct hda_codec *codec)
9809{
9810 struct alc_spec *spec = codec->spec;
9811 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9812 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9813 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9814 unsigned int mute;
9815
9816 /* HP */
9817 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9818 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9819 HDA_AMP_MUTE, mute);
9820 /* mute internal speaker per jack sense */
9821 if (spec->jack_present)
9822 mute = HDA_AMP_MUTE;
9823 if (line_nid)
9824 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9825 HDA_AMP_MUTE, mute);
9826 if (speaker_nid && speaker_nid != line_nid)
9827 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9828 HDA_AMP_MUTE, mute);
9829}
9830
9831#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9832
9833static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9834 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009835{
9836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009837 struct alc_spec *spec = codec->spec;
9838 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009839
Takashi Iwai42171c12009-05-08 14:11:43 +02009840 if (val == spec->master_sw)
9841 return 0;
9842 spec->master_sw = val;
9843 alc262_hippo_master_update(codec);
9844 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009845}
Takashi Iwai5b319542007-07-26 11:49:22 +02009846
Takashi Iwai42171c12009-05-08 14:11:43 +02009847#define ALC262_HIPPO_MASTER_SWITCH \
9848 { \
9849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9850 .name = "Master Playback Switch", \
9851 .info = snd_ctl_boolean_mono_info, \
9852 .get = alc262_hippo_master_sw_get, \
9853 .put = alc262_hippo_master_sw_put, \
9854 }
9855
9856static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9857 ALC262_HIPPO_MASTER_SWITCH,
9858 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9859 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9860 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9867 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9870 { } /* end */
9871};
9872
9873static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9874 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9875 ALC262_HIPPO_MASTER_SWITCH,
9876 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9877 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9878 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9879 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9883 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9884 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9885 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9886 { } /* end */
9887};
9888
9889/* mute/unmute internal speaker according to the hp jack and mute state */
9890static void alc262_hippo_automute(struct hda_codec *codec)
9891{
9892 struct alc_spec *spec = codec->spec;
9893 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9894 unsigned int present;
9895
9896 /* need to execute and sync at first */
9897 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9898 present = snd_hda_codec_read(codec, hp_nid, 0,
9899 AC_VERB_GET_PIN_SENSE, 0);
9900 spec->jack_present = (present & 0x80000000) != 0;
9901 alc262_hippo_master_update(codec);
9902}
9903
9904static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9905{
9906 if ((res >> 26) != ALC880_HP_EVENT)
9907 return;
9908 alc262_hippo_automute(codec);
9909}
9910
9911static void alc262_hippo_init_hook(struct hda_codec *codec)
9912{
9913 struct alc_spec *spec = codec->spec;
9914
9915 spec->autocfg.hp_pins[0] = 0x15;
9916 spec->autocfg.speaker_pins[0] = 0x14;
9917 alc262_hippo_automute(codec);
9918}
9919
9920static void alc262_hippo1_init_hook(struct hda_codec *codec)
9921{
9922 struct alc_spec *spec = codec->spec;
9923
9924 spec->autocfg.hp_pins[0] = 0x1b;
9925 spec->autocfg.speaker_pins[0] = 0x14;
9926 alc262_hippo_automute(codec);
9927}
9928
9929
Kailang Yang272a5272007-05-14 11:00:38 +02009930static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009931 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009932 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9935 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9936 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9937 { } /* end */
9938};
9939
Kailang Yang83c34212007-07-05 11:43:05 +02009940static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009941 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9942 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9946 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9947 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9948 { } /* end */
9949};
Kailang Yang272a5272007-05-14 11:00:38 +02009950
Tony Vroonba340e82009-02-02 19:01:30 +00009951static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9952 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9953 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9954 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9955 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9962 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9963 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9964 { } /* end */
9965};
9966
9967static struct hda_verb alc262_tyan_verbs[] = {
9968 /* Headphone automute */
9969 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9970 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9972
9973 /* P11 AUX_IN, white 4-pin connector */
9974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9975 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9976 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9977 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9978
9979 {}
9980};
9981
9982/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009983static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009984{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009985 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009986
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009987 spec->autocfg.hp_pins[0] = 0x1b;
9988 spec->autocfg.speaker_pins[0] = 0x15;
9989 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009990}
9991
Tony Vroonba340e82009-02-02 19:01:30 +00009992
Kailang Yangdf694da2005-12-05 19:42:22 +01009993#define alc262_capture_mixer alc882_capture_mixer
9994#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9995
9996/*
9997 * generic initialization of ADC, input mixers and output mixers
9998 */
9999static struct hda_verb alc262_init_verbs[] = {
10000 /*
10001 * Unmute ADC0-2 and set the default input to mic-in
10002 */
10003 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10005 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10007 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10009
Takashi Iwaicb53c622007-08-10 17:21:45 +020010010 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010011 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010012 * Note: PASD motherboards uses the Line In 2 as the input for
10013 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010014 */
10015 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010021
10022 /*
10023 * Set up output mixers (0x0c - 0x0e)
10024 */
10025 /* set vol=0 to output mixers */
10026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10028 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10029 /* set up input amps for analog loopback */
10030 /* Amp Indices: DAC = 0, mixer = 1 */
10031 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10033 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10034 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10036 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10037
10038 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10041 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10042 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10043 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10044
10045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10047 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10048 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010050
Kailang Yangdf694da2005-12-05 19:42:22 +010010051 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10052 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010053
Kailang Yangdf694da2005-12-05 19:42:22 +010010054 /* FIXME: use matrix-type input source selection */
10055 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10056 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10061 /* Input mixer2 */
10062 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10066 /* Input mixer3 */
10067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010071
10072 { }
10073};
10074
Kailang Yang4e555fe2008-08-26 13:05:55 +020010075static struct hda_verb alc262_eapd_verbs[] = {
10076 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10077 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10078 { }
10079};
10080
Kailang Yangccc656c2006-10-17 12:32:26 +020010081static struct hda_verb alc262_hippo_unsol_verbs[] = {
10082 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10084 {}
10085};
10086
10087static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10088 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10089 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10091
10092 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10094 {}
10095};
10096
Kailang Yang272a5272007-05-14 11:00:38 +020010097static struct hda_verb alc262_sony_unsol_verbs[] = {
10098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10101
10102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010104 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010105};
10106
Kailang Yang4e555fe2008-08-26 13:05:55 +020010107static struct hda_input_mux alc262_dmic_capture_source = {
10108 .num_items = 2,
10109 .items = {
10110 { "Int DMic", 0x9 },
10111 { "Mic", 0x0 },
10112 },
10113};
10114
10115static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10116 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10117 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010121 { } /* end */
10122};
10123
10124static struct hda_verb alc262_toshiba_s06_verbs[] = {
10125 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10128 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10129 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10131 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10132 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10133 {}
10134};
10135
10136static void alc262_dmic_automute(struct hda_codec *codec)
10137{
10138 unsigned int present;
10139
10140 present = snd_hda_codec_read(codec, 0x18, 0,
10141 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10142 snd_hda_codec_write(codec, 0x22, 0,
10143 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10144}
10145
Kailang Yang4e555fe2008-08-26 13:05:55 +020010146
10147/* unsolicited event for HP jack sensing */
10148static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10149 unsigned int res)
10150{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010151 if ((res >> 26) == ALC880_MIC_EVENT)
10152 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010153 else
10154 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010155}
10156
10157static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10158{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010159 struct alc_spec *spec = codec->spec;
10160
10161 spec->autocfg.hp_pins[0] = 0x15;
10162 spec->autocfg.speaker_pins[0] = 0x14;
10163 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010164 alc262_dmic_automute(codec);
10165}
10166
Takashi Iwai834be882006-03-01 14:16:17 +010010167/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010168 * nec model
10169 * 0x15 = headphone
10170 * 0x16 = internal speaker
10171 * 0x18 = external mic
10172 */
10173
10174static struct snd_kcontrol_new alc262_nec_mixer[] = {
10175 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10176 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10177
10178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10180 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10181
10182 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10184 { } /* end */
10185};
10186
10187static struct hda_verb alc262_nec_verbs[] = {
10188 /* Unmute Speaker */
10189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10190
10191 /* Headphone */
10192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10194
10195 /* External mic to headphone */
10196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10197 /* External mic to speaker */
10198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {}
10200};
10201
10202/*
Takashi Iwai834be882006-03-01 14:16:17 +010010203 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010204 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10205 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010206 */
10207
10208#define ALC_HP_EVENT 0x37
10209
10210static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10211 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010213 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010215 {}
10216};
10217
Jiang zhe0e31daf2008-03-20 12:12:39 +010010218static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10219 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10221 {}
10222};
10223
Takashi Iwai834be882006-03-01 14:16:17 +010010224static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010225 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010226 .items = {
10227 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010228 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010229 { "CD", 0x4 },
10230 },
10231};
10232
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010233static struct hda_input_mux alc262_HP_capture_source = {
10234 .num_items = 5,
10235 .items = {
10236 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010237 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010238 { "Line", 0x2 },
10239 { "CD", 0x4 },
10240 { "AUX IN", 0x6 },
10241 },
10242};
10243
zhejiangaccbe492007-08-31 12:36:05 +020010244static struct hda_input_mux alc262_HP_D7000_capture_source = {
10245 .num_items = 4,
10246 .items = {
10247 { "Mic", 0x0 },
10248 { "Front Mic", 0x2 },
10249 { "Line", 0x1 },
10250 { "CD", 0x4 },
10251 },
10252};
10253
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010254/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010255static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10256{
10257 struct alc_spec *spec = codec->spec;
10258 unsigned int mute;
10259
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010260 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010261 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010262 /* need to execute and sync at first */
10263 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010264 /* check laptop HP jack */
10265 present = snd_hda_codec_read(codec, 0x14, 0,
10266 AC_VERB_GET_PIN_SENSE, 0);
10267 /* need to execute and sync at first */
10268 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10269 /* check docking HP jack */
10270 present |= snd_hda_codec_read(codec, 0x1b, 0,
10271 AC_VERB_GET_PIN_SENSE, 0);
10272 if (present & AC_PINSENSE_PRESENCE)
10273 spec->jack_present = 1;
10274 else
10275 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010276 spec->sense_updated = 1;
10277 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010278 /* unmute internal speaker only if both HPs are unplugged and
10279 * master switch is on
10280 */
10281 if (spec->jack_present)
10282 mute = HDA_AMP_MUTE;
10283 else
Takashi Iwai834be882006-03-01 14:16:17 +010010284 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010285 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10286 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010287}
10288
10289/* unsolicited event for HP jack sensing */
10290static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10291 unsigned int res)
10292{
10293 if ((res >> 26) != ALC_HP_EVENT)
10294 return;
10295 alc262_fujitsu_automute(codec, 1);
10296}
10297
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010298static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10299{
10300 alc262_fujitsu_automute(codec, 1);
10301}
10302
Takashi Iwai834be882006-03-01 14:16:17 +010010303/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010304static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10305 .ops = &snd_hda_bind_vol,
10306 .values = {
10307 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10308 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10309 0
10310 },
10311};
Takashi Iwai834be882006-03-01 14:16:17 +010010312
Jiang zhe0e31daf2008-03-20 12:12:39 +010010313/* mute/unmute internal speaker according to the hp jack and mute state */
10314static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10315{
10316 struct alc_spec *spec = codec->spec;
10317 unsigned int mute;
10318
10319 if (force || !spec->sense_updated) {
10320 unsigned int present_int_hp;
10321 /* need to execute and sync at first */
10322 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10323 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10324 AC_VERB_GET_PIN_SENSE, 0);
10325 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10326 spec->sense_updated = 1;
10327 }
10328 if (spec->jack_present) {
10329 /* mute internal speaker */
10330 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10331 HDA_AMP_MUTE, HDA_AMP_MUTE);
10332 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10333 HDA_AMP_MUTE, HDA_AMP_MUTE);
10334 } else {
10335 /* unmute internal speaker if necessary */
10336 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10337 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10338 HDA_AMP_MUTE, mute);
10339 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10340 HDA_AMP_MUTE, mute);
10341 }
10342}
10343
10344/* unsolicited event for HP jack sensing */
10345static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10346 unsigned int res)
10347{
10348 if ((res >> 26) != ALC_HP_EVENT)
10349 return;
10350 alc262_lenovo_3000_automute(codec, 1);
10351}
10352
Takashi Iwai834be882006-03-01 14:16:17 +010010353/* bind hp and internal speaker mute (with plug check) */
10354static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10355 struct snd_ctl_elem_value *ucontrol)
10356{
10357 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10358 long *valp = ucontrol->value.integer.value;
10359 int change;
10360
Tony Vroon5d9fab22008-03-14 17:09:18 +010010361 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10362 HDA_AMP_MUTE,
10363 valp ? 0 : HDA_AMP_MUTE);
10364 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10365 HDA_AMP_MUTE,
10366 valp ? 0 : HDA_AMP_MUTE);
10367
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010368 if (change)
10369 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010370 return change;
10371}
10372
10373static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010374 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010375 {
10376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10377 .name = "Master Playback Switch",
10378 .info = snd_hda_mixer_amp_switch_info,
10379 .get = snd_hda_mixer_amp_switch_get,
10380 .put = alc262_fujitsu_master_sw_put,
10381 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10382 },
10383 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10384 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010388 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10389 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10390 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010391 { } /* end */
10392};
10393
Jiang zhe0e31daf2008-03-20 12:12:39 +010010394/* bind hp and internal speaker mute (with plug check) */
10395static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10396 struct snd_ctl_elem_value *ucontrol)
10397{
10398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10399 long *valp = ucontrol->value.integer.value;
10400 int change;
10401
10402 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10403 HDA_AMP_MUTE,
10404 valp ? 0 : HDA_AMP_MUTE);
10405
10406 if (change)
10407 alc262_lenovo_3000_automute(codec, 0);
10408 return change;
10409}
10410
10411static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10412 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10413 {
10414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10415 .name = "Master Playback Switch",
10416 .info = snd_hda_mixer_amp_switch_info,
10417 .get = snd_hda_mixer_amp_switch_get,
10418 .put = alc262_lenovo_3000_master_sw_put,
10419 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10420 },
10421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10423 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10426 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10427 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10428 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10429 { } /* end */
10430};
10431
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010432static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10433 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010434 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10437 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10438 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10440 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10441 { } /* end */
10442};
10443
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010444/* additional init verbs for Benq laptops */
10445static struct hda_verb alc262_EAPD_verbs[] = {
10446 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10447 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10448 {}
10449};
10450
Kailang Yang83c34212007-07-05 11:43:05 +020010451static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10454
10455 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10456 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10457 {}
10458};
10459
Tobin Davisf651b502007-10-26 12:40:47 +020010460/* Samsung Q1 Ultra Vista model setup */
10461static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010462 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10463 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10466 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010467 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010468 { } /* end */
10469};
10470
10471static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010472 /* output mixer */
10473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10476 /* speaker */
10477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10480 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10481 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10487 /* internal mic */
10488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10490 /* ADC, choose mic */
10491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010501 {}
10502};
10503
Tobin Davisf651b502007-10-26 12:40:47 +020010504/* mute/unmute internal speaker according to the hp jack and mute state */
10505static void alc262_ultra_automute(struct hda_codec *codec)
10506{
10507 struct alc_spec *spec = codec->spec;
10508 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010509
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010510 mute = 0;
10511 /* auto-mute only when HP is used as HP */
10512 if (!spec->cur_mux[0]) {
10513 unsigned int present;
10514 /* need to execute and sync at first */
10515 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10516 present = snd_hda_codec_read(codec, 0x15, 0,
10517 AC_VERB_GET_PIN_SENSE, 0);
10518 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10519 if (spec->jack_present)
10520 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010521 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010522 /* mute/unmute internal speaker */
10523 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10524 HDA_AMP_MUTE, mute);
10525 /* mute/unmute HP */
10526 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10527 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010528}
10529
10530/* unsolicited event for HP jack sensing */
10531static void alc262_ultra_unsol_event(struct hda_codec *codec,
10532 unsigned int res)
10533{
10534 if ((res >> 26) != ALC880_HP_EVENT)
10535 return;
10536 alc262_ultra_automute(codec);
10537}
10538
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010539static struct hda_input_mux alc262_ultra_capture_source = {
10540 .num_items = 2,
10541 .items = {
10542 { "Mic", 0x1 },
10543 { "Headphone", 0x7 },
10544 },
10545};
10546
10547static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10548 struct snd_ctl_elem_value *ucontrol)
10549{
10550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10551 struct alc_spec *spec = codec->spec;
10552 int ret;
10553
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010554 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010555 if (!ret)
10556 return 0;
10557 /* reprogram the HP pin as mic or HP according to the input source */
10558 snd_hda_codec_write_cache(codec, 0x15, 0,
10559 AC_VERB_SET_PIN_WIDGET_CONTROL,
10560 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10561 alc262_ultra_automute(codec); /* mute/unmute HP */
10562 return ret;
10563}
10564
10565static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10566 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10567 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10568 {
10569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10570 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010571 .info = alc_mux_enum_info,
10572 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010573 .put = alc262_ultra_mux_enum_put,
10574 },
10575 { } /* end */
10576};
10577
Kailang Yangdf694da2005-12-05 19:42:22 +010010578/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010579static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10580 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010581{
10582 hda_nid_t nid;
10583 int err;
10584
10585 spec->multiout.num_dacs = 1; /* only use one dac */
10586 spec->multiout.dac_nids = spec->private_dac_nids;
10587 spec->multiout.dac_nids[0] = 2;
10588
10589 nid = cfg->line_out_pins[0];
10590 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010591 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10592 "Front Playback Volume",
10593 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10594 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010596 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10597 "Front Playback Switch",
10598 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10599 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010600 return err;
10601 }
10602
Takashi Iwai82bc9552006-03-21 11:24:42 +010010603 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010604 if (nid) {
10605 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010606 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10607 "Speaker Playback Volume",
10608 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10609 HDA_OUTPUT));
10610 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010611 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010612 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10613 "Speaker Playback Switch",
10614 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10615 HDA_OUTPUT));
10616 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010617 return err;
10618 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010619 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10620 "Speaker Playback Switch",
10621 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10622 HDA_OUTPUT));
10623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010624 return err;
10625 }
10626 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010627 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010628 if (nid) {
10629 /* spec->multiout.hp_nid = 2; */
10630 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010631 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10632 "Headphone Playback Volume",
10633 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10634 HDA_OUTPUT));
10635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10638 "Headphone Playback Switch",
10639 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10640 HDA_OUTPUT));
10641 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010642 return err;
10643 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010644 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10645 "Headphone Playback Switch",
10646 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10647 HDA_OUTPUT));
10648 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010649 return err;
10650 }
10651 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010652 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010653}
10654
10655/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010656#define alc262_auto_create_analog_input_ctls \
10657 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010658
10659/*
10660 * generic initialization of ADC, input mixers and output mixers
10661 */
10662static struct hda_verb alc262_volume_init_verbs[] = {
10663 /*
10664 * Unmute ADC0-2 and set the default input to mic-in
10665 */
10666 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10668 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10670 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10672
Takashi Iwaicb53c622007-08-10 17:21:45 +020010673 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010675 * Note: PASD motherboards uses the Line In 2 as the input for
10676 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 */
10678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010684
10685 /*
10686 * Set up output mixers (0x0c - 0x0f)
10687 */
10688 /* set vol=0 to output mixers */
10689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10691 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010692
Kailang Yangdf694da2005-12-05 19:42:22 +010010693 /* set up input amps for analog loopback */
10694 /* Amp Indices: DAC = 0, mixer = 1 */
10695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10701
10702 /* FIXME: use matrix-type input source selection */
10703 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10704 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10709 /* Input mixer2 */
10710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10711 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10712 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10714 /* Input mixer3 */
10715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10719
10720 { }
10721};
10722
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010723static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10724 /*
10725 * Unmute ADC0-2 and set the default input to mic-in
10726 */
10727 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10729 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10731 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10732 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10733
Takashi Iwaicb53c622007-08-10 17:21:45 +020010734 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010735 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010736 * Note: PASD motherboards uses the Line In 2 as the input for
10737 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010738 */
10739 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010747
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010748 /*
10749 * Set up output mixers (0x0c - 0x0e)
10750 */
10751 /* set vol=0 to output mixers */
10752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10755
10756 /* set up input amps for analog loopback */
10757 /* Amp Indices: DAC = 0, mixer = 1 */
10758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10764
Takashi Iwaice875f02008-01-28 18:17:43 +010010765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10768
10769 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10771
10772 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10774
10775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10780
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010785 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10786 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10787
10788
10789 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010790 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10791 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10795 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10796 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10797 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10798 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10799 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10800 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010801 /* Input mixer2 */
10802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010811 /* Input mixer3 */
10812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010821
Takashi Iwaice875f02008-01-28 18:17:43 +010010822 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10823
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010824 { }
10825};
10826
Kailang Yangcd7509a2007-01-26 18:33:17 +010010827static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10828 /*
10829 * Unmute ADC0-2 and set the default input to mic-in
10830 */
10831 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10833 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10835 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10837
Takashi Iwaicb53c622007-08-10 17:21:45 +020010838 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010839 * mixer widget
10840 * Note: PASD motherboards uses the Line In 2 as the input for front
10841 * panel mic (mic 2)
10842 */
10843 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010852 /*
10853 * Set up output mixers (0x0c - 0x0e)
10854 */
10855 /* set vol=0 to output mixers */
10856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10859
10860 /* set up input amps for analog loopback */
10861 /* Amp Indices: DAC = 0, mixer = 1 */
10862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10868
10869
10870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10871 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10872 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10873 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10875 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10877
10878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10880
10881 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10883
10884 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10886 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10888 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10889 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10890
10891 /* FIXME: use matrix-type input source selection */
10892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10893 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10899 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10901 /* Input mixer2 */
10902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10907 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10909 /* Input mixer3 */
10910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10915 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10917
Takashi Iwaice875f02008-01-28 18:17:43 +010010918 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10919
Kailang Yangcd7509a2007-01-26 18:33:17 +010010920 { }
10921};
10922
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010923static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10924
10925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10927 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10928
10929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10931 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10933
10934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10935 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10936 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10937 {}
10938};
10939
10940
Takashi Iwaicb53c622007-08-10 17:21:45 +020010941#ifdef CONFIG_SND_HDA_POWER_SAVE
10942#define alc262_loopbacks alc880_loopbacks
10943#endif
10944
Kailang Yangdf694da2005-12-05 19:42:22 +010010945/* pcm configuration: identiacal with ALC880 */
10946#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10947#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10948#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10949#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10950
10951/*
10952 * BIOS auto configuration
10953 */
10954static int alc262_parse_auto_config(struct hda_codec *codec)
10955{
10956 struct alc_spec *spec = codec->spec;
10957 int err;
10958 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10959
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010960 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10961 alc262_ignore);
10962 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010963 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010964 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010965 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010966 spec->multiout.max_channels = 2;
10967 spec->no_analog = 1;
10968 goto dig_only;
10969 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010970 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010971 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010972 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10973 if (err < 0)
10974 return err;
10975 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10976 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010977 return err;
10978
10979 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10980
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010981 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010982 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010984 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010985 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010986 if (spec->autocfg.dig_in_pin)
10987 spec->dig_in_nid = ALC262_DIGIN_NID;
10988
Takashi Iwai603c4012008-07-30 15:01:44 +020010989 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010990 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010991
Takashi Iwaid88897e2008-10-31 15:01:37 +010010992 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010993 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010994 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010995
Takashi Iwai776e1842007-08-29 15:07:11 +020010996 err = alc_auto_add_mic_boost(codec);
10997 if (err < 0)
10998 return err;
10999
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011000 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11001
Kailang Yangdf694da2005-12-05 19:42:22 +010011002 return 1;
11003}
11004
11005#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11006#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11007#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011008#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011009
11010
11011/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011012static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011013{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011014 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011015 alc262_auto_init_multi_out(codec);
11016 alc262_auto_init_hp_out(codec);
11017 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011018 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011019 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011020 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011021}
11022
11023/*
11024 * configuration and preset
11025 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011026static const char *alc262_models[ALC262_MODEL_LAST] = {
11027 [ALC262_BASIC] = "basic",
11028 [ALC262_HIPPO] = "hippo",
11029 [ALC262_HIPPO_1] = "hippo_1",
11030 [ALC262_FUJITSU] = "fujitsu",
11031 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011032 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011033 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011034 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011035 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011036 [ALC262_BENQ_T31] = "benq-t31",
11037 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011038 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011039 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011040 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011041 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011042 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011043 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011044 [ALC262_AUTO] = "auto",
11045};
11046
11047static struct snd_pci_quirk alc262_cfg_tbl[] = {
11048 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011049 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011050 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11051 ALC262_HP_BPC),
11052 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11053 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011054 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11055 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011056 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011057 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011058 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011059 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011060 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011061 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011062 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011063 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011064 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11065 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11066 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011067 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11068 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011069 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011070 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011071 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011072 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011073 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010011074 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11075 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011076 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011077 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011078 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011079 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011080 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011081 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011082 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11083 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011084 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011085 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011086 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011087 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011088 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011089 {}
11090};
11091
11092static struct alc_config_preset alc262_presets[] = {
11093 [ALC262_BASIC] = {
11094 .mixers = { alc262_base_mixer },
11095 .init_verbs = { alc262_init_verbs },
11096 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11097 .dac_nids = alc262_dac_nids,
11098 .hp_nid = 0x03,
11099 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11100 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011101 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011102 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011103 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011104 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011105 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11106 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11107 .dac_nids = alc262_dac_nids,
11108 .hp_nid = 0x03,
11109 .dig_out_nid = ALC262_DIGOUT_NID,
11110 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11111 .channel_mode = alc262_modes,
11112 .input_mux = &alc262_capture_source,
11113 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011114 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011115 },
11116 [ALC262_HIPPO_1] = {
11117 .mixers = { alc262_hippo1_mixer },
11118 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11119 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11120 .dac_nids = alc262_dac_nids,
11121 .hp_nid = 0x02,
11122 .dig_out_nid = ALC262_DIGOUT_NID,
11123 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11124 .channel_mode = alc262_modes,
11125 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011126 .unsol_event = alc262_hippo_unsol_event,
11127 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011128 },
Takashi Iwai834be882006-03-01 14:16:17 +010011129 [ALC262_FUJITSU] = {
11130 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011131 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11132 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011133 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11134 .dac_nids = alc262_dac_nids,
11135 .hp_nid = 0x03,
11136 .dig_out_nid = ALC262_DIGOUT_NID,
11137 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11138 .channel_mode = alc262_modes,
11139 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011140 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011141 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011142 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011143 [ALC262_HP_BPC] = {
11144 .mixers = { alc262_HP_BPC_mixer },
11145 .init_verbs = { alc262_HP_BPC_init_verbs },
11146 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11147 .dac_nids = alc262_dac_nids,
11148 .hp_nid = 0x03,
11149 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11150 .channel_mode = alc262_modes,
11151 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011152 .unsol_event = alc262_hp_bpc_unsol_event,
11153 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011154 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011155 [ALC262_HP_BPC_D7000_WF] = {
11156 .mixers = { alc262_HP_BPC_WildWest_mixer },
11157 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11158 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11159 .dac_nids = alc262_dac_nids,
11160 .hp_nid = 0x03,
11161 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11162 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011163 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011164 .unsol_event = alc262_hp_wildwest_unsol_event,
11165 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011166 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011167 [ALC262_HP_BPC_D7000_WL] = {
11168 .mixers = { alc262_HP_BPC_WildWest_mixer,
11169 alc262_HP_BPC_WildWest_option_mixer },
11170 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11171 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11172 .dac_nids = alc262_dac_nids,
11173 .hp_nid = 0x03,
11174 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11175 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011176 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011177 .unsol_event = alc262_hp_wildwest_unsol_event,
11178 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011179 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011180 [ALC262_HP_TC_T5735] = {
11181 .mixers = { alc262_hp_t5735_mixer },
11182 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11183 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11184 .dac_nids = alc262_dac_nids,
11185 .hp_nid = 0x03,
11186 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11187 .channel_mode = alc262_modes,
11188 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011189 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011190 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011191 },
11192 [ALC262_HP_RP5700] = {
11193 .mixers = { alc262_hp_rp5700_mixer },
11194 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11195 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11196 .dac_nids = alc262_dac_nids,
11197 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11198 .channel_mode = alc262_modes,
11199 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011200 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011201 [ALC262_BENQ_ED8] = {
11202 .mixers = { alc262_base_mixer },
11203 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11204 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11205 .dac_nids = alc262_dac_nids,
11206 .hp_nid = 0x03,
11207 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11208 .channel_mode = alc262_modes,
11209 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011210 },
Kailang Yang272a5272007-05-14 11:00:38 +020011211 [ALC262_SONY_ASSAMD] = {
11212 .mixers = { alc262_sony_mixer },
11213 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11214 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11215 .dac_nids = alc262_dac_nids,
11216 .hp_nid = 0x02,
11217 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11218 .channel_mode = alc262_modes,
11219 .input_mux = &alc262_capture_source,
11220 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011221 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011222 },
11223 [ALC262_BENQ_T31] = {
11224 .mixers = { alc262_benq_t31_mixer },
11225 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11226 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11227 .dac_nids = alc262_dac_nids,
11228 .hp_nid = 0x03,
11229 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11230 .channel_mode = alc262_modes,
11231 .input_mux = &alc262_capture_source,
11232 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011233 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011234 },
Tobin Davisf651b502007-10-26 12:40:47 +020011235 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011236 .mixers = { alc262_ultra_mixer },
11237 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011238 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011239 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11240 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011241 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11242 .channel_mode = alc262_modes,
11243 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011244 .adc_nids = alc262_adc_nids, /* ADC0 */
11245 .capsrc_nids = alc262_capsrc_nids,
11246 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011247 .unsol_event = alc262_ultra_unsol_event,
11248 .init_hook = alc262_ultra_automute,
11249 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011250 [ALC262_LENOVO_3000] = {
11251 .mixers = { alc262_lenovo_3000_mixer },
11252 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11253 alc262_lenovo_3000_unsol_verbs },
11254 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11255 .dac_nids = alc262_dac_nids,
11256 .hp_nid = 0x03,
11257 .dig_out_nid = ALC262_DIGOUT_NID,
11258 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11259 .channel_mode = alc262_modes,
11260 .input_mux = &alc262_fujitsu_capture_source,
11261 .unsol_event = alc262_lenovo_3000_unsol_event,
11262 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011263 [ALC262_NEC] = {
11264 .mixers = { alc262_nec_mixer },
11265 .init_verbs = { alc262_nec_verbs },
11266 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11267 .dac_nids = alc262_dac_nids,
11268 .hp_nid = 0x03,
11269 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11270 .channel_mode = alc262_modes,
11271 .input_mux = &alc262_capture_source,
11272 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011273 [ALC262_TOSHIBA_S06] = {
11274 .mixers = { alc262_toshiba_s06_mixer },
11275 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11276 alc262_eapd_verbs },
11277 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11278 .capsrc_nids = alc262_dmic_capsrc_nids,
11279 .dac_nids = alc262_dac_nids,
11280 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11281 .dig_out_nid = ALC262_DIGOUT_NID,
11282 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11283 .channel_mode = alc262_modes,
11284 .input_mux = &alc262_dmic_capture_source,
11285 .unsol_event = alc262_toshiba_s06_unsol_event,
11286 .init_hook = alc262_toshiba_s06_init_hook,
11287 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011288 [ALC262_TOSHIBA_RX1] = {
11289 .mixers = { alc262_toshiba_rx1_mixer },
11290 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11291 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11292 .dac_nids = alc262_dac_nids,
11293 .hp_nid = 0x03,
11294 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11295 .channel_mode = alc262_modes,
11296 .input_mux = &alc262_capture_source,
11297 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011298 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011299 },
Tony Vroonba340e82009-02-02 19:01:30 +000011300 [ALC262_TYAN] = {
11301 .mixers = { alc262_tyan_mixer },
11302 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11303 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11304 .dac_nids = alc262_dac_nids,
11305 .hp_nid = 0x02,
11306 .dig_out_nid = ALC262_DIGOUT_NID,
11307 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11308 .channel_mode = alc262_modes,
11309 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011310 .unsol_event = alc_automute_amp_unsol_event,
11311 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011312 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011313};
11314
11315static int patch_alc262(struct hda_codec *codec)
11316{
11317 struct alc_spec *spec;
11318 int board_config;
11319 int err;
11320
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011322 if (spec == NULL)
11323 return -ENOMEM;
11324
11325 codec->spec = spec;
11326#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011327 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11328 * under-run
11329 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011330 {
11331 int tmp;
11332 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11333 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11334 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11335 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11336 }
11337#endif
11338
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011339 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11340
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011341 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11342 alc262_models,
11343 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011344
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011345 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011346 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11347 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011348 board_config = ALC262_AUTO;
11349 }
11350
11351 if (board_config == ALC262_AUTO) {
11352 /* automatic parse from the BIOS config */
11353 err = alc262_parse_auto_config(codec);
11354 if (err < 0) {
11355 alc_free(codec);
11356 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011357 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011358 printk(KERN_INFO
11359 "hda_codec: Cannot set up configuration "
11360 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011361 board_config = ALC262_BASIC;
11362 }
11363 }
11364
Takashi Iwai07eba612009-02-19 08:06:35 +010011365 if (!spec->no_analog) {
11366 err = snd_hda_attach_beep_device(codec, 0x1);
11367 if (err < 0) {
11368 alc_free(codec);
11369 return err;
11370 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011371 }
11372
Kailang Yangdf694da2005-12-05 19:42:22 +010011373 if (board_config != ALC262_AUTO)
11374 setup_preset(spec, &alc262_presets[board_config]);
11375
Kailang Yangdf694da2005-12-05 19:42:22 +010011376 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11377 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011378
Kailang Yangdf694da2005-12-05 19:42:22 +010011379 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11380 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11381
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011382 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011383 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011385 unsigned int wcap = get_wcaps(codec, 0x07);
11386
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 /* get type */
11388 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011389 if (wcap != AC_WID_AUD_IN) {
11390 spec->adc_nids = alc262_adc_nids_alt;
11391 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011392 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011393 } else {
11394 spec->adc_nids = alc262_adc_nids;
11395 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011396 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011397 }
11398 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011399 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011400 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011401 if (!spec->no_analog)
11402 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011403
Takashi Iwai2134ea42008-01-10 16:53:55 +010011404 spec->vmaster_nid = 0x0c;
11405
Kailang Yangdf694da2005-12-05 19:42:22 +010011406 codec->patch_ops = alc_patch_ops;
11407 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011408 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011409#ifdef CONFIG_SND_HDA_POWER_SAVE
11410 if (!spec->loopback.amplist)
11411 spec->loopback.amplist = alc262_loopbacks;
11412#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011413 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011414
Kailang Yangdf694da2005-12-05 19:42:22 +010011415 return 0;
11416}
11417
Kailang Yangdf694da2005-12-05 19:42:22 +010011418/*
Kailang Yanga361d842007-06-05 12:30:55 +020011419 * ALC268 channel source setting (2 channel)
11420 */
11421#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11422#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011423
Kailang Yanga361d842007-06-05 12:30:55 +020011424static hda_nid_t alc268_dac_nids[2] = {
11425 /* front, hp */
11426 0x02, 0x03
11427};
11428
11429static hda_nid_t alc268_adc_nids[2] = {
11430 /* ADC0-1 */
11431 0x08, 0x07
11432};
11433
11434static hda_nid_t alc268_adc_nids_alt[1] = {
11435 /* ADC0 */
11436 0x08
11437};
11438
Takashi Iwaie1406342008-02-11 18:32:32 +010011439static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11440
Kailang Yanga361d842007-06-05 12:30:55 +020011441static struct snd_kcontrol_new alc268_base_mixer[] = {
11442 /* output mixer control */
11443 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11444 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11445 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11446 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11449 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011450 { }
11451};
11452
Takashi Iwai42171c12009-05-08 14:11:43 +020011453static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11454 /* output mixer control */
11455 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11457 ALC262_HIPPO_MASTER_SWITCH,
11458 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11459 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11460 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11461 { }
11462};
11463
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011464/* bind Beep switches of both NID 0x0f and 0x10 */
11465static struct hda_bind_ctls alc268_bind_beep_sw = {
11466 .ops = &snd_hda_bind_sw,
11467 .values = {
11468 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11469 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11470 0
11471 },
11472};
11473
11474static struct snd_kcontrol_new alc268_beep_mixer[] = {
11475 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11476 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11477 { }
11478};
11479
Kailang Yangd1a991a2007-08-15 16:21:59 +020011480static struct hda_verb alc268_eapd_verbs[] = {
11481 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11482 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11483 { }
11484};
11485
Takashi Iwaid2738092007-08-16 14:59:45 +020011486/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011487static struct hda_verb alc268_toshiba_verbs[] = {
11488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11489 { } /* end */
11490};
11491
Kailang Yang8ef355d2008-08-26 13:10:22 +020011492static struct hda_input_mux alc268_acer_lc_capture_source = {
11493 .num_items = 2,
11494 .items = {
11495 { "i-Mic", 0x6 },
11496 { "E-Mic", 0x0 },
11497 },
11498};
11499
Takashi Iwaid2738092007-08-16 14:59:45 +020011500/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011501/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011502static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11503 .ops = &snd_hda_bind_vol,
11504 .values = {
11505 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11506 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11507 0
11508 },
11509};
11510
Takashi Iwai889c4392007-08-23 18:56:52 +020011511/* mute/unmute internal speaker according to the hp jack and mute state */
11512static void alc268_acer_automute(struct hda_codec *codec, int force)
11513{
11514 struct alc_spec *spec = codec->spec;
11515 unsigned int mute;
11516
11517 if (force || !spec->sense_updated) {
11518 unsigned int present;
11519 present = snd_hda_codec_read(codec, 0x14, 0,
11520 AC_VERB_GET_PIN_SENSE, 0);
11521 spec->jack_present = (present & 0x80000000) != 0;
11522 spec->sense_updated = 1;
11523 }
11524 if (spec->jack_present)
11525 mute = HDA_AMP_MUTE; /* mute internal speaker */
11526 else /* unmute internal speaker if necessary */
11527 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11528 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11529 HDA_AMP_MUTE, mute);
11530}
11531
11532
11533/* bind hp and internal speaker mute (with plug check) */
11534static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11535 struct snd_ctl_elem_value *ucontrol)
11536{
11537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11538 long *valp = ucontrol->value.integer.value;
11539 int change;
11540
11541 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11542 HDA_AMP_MUTE,
11543 valp[0] ? 0 : HDA_AMP_MUTE);
11544 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11545 HDA_AMP_MUTE,
11546 valp[1] ? 0 : HDA_AMP_MUTE);
11547 if (change)
11548 alc268_acer_automute(codec, 0);
11549 return change;
11550}
Takashi Iwaid2738092007-08-16 14:59:45 +020011551
Kailang Yang8ef355d2008-08-26 13:10:22 +020011552static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11553 /* output mixer control */
11554 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11555 {
11556 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11557 .name = "Master Playback Switch",
11558 .info = snd_hda_mixer_amp_switch_info,
11559 .get = snd_hda_mixer_amp_switch_get,
11560 .put = alc268_acer_master_sw_put,
11561 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11562 },
11563 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11564 { }
11565};
11566
Takashi Iwaid2738092007-08-16 14:59:45 +020011567static struct snd_kcontrol_new alc268_acer_mixer[] = {
11568 /* output mixer control */
11569 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11570 {
11571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11572 .name = "Master Playback Switch",
11573 .info = snd_hda_mixer_amp_switch_info,
11574 .get = snd_hda_mixer_amp_switch_get,
11575 .put = alc268_acer_master_sw_put,
11576 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11577 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011578 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11579 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11580 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011581 { }
11582};
11583
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011584static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11585 /* output mixer control */
11586 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11587 {
11588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11589 .name = "Master Playback Switch",
11590 .info = snd_hda_mixer_amp_switch_info,
11591 .get = snd_hda_mixer_amp_switch_get,
11592 .put = alc268_acer_master_sw_put,
11593 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11594 },
11595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11596 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11597 { }
11598};
11599
Kailang Yang8ef355d2008-08-26 13:10:22 +020011600static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11601 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11603 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11604 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11605 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11607 { }
11608};
11609
Takashi Iwaid2738092007-08-16 14:59:45 +020011610static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011611 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11612 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11616 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011617 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11618 { }
11619};
11620
11621/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011622#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11623#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011624
11625static void alc268_acer_unsol_event(struct hda_codec *codec,
11626 unsigned int res)
11627{
Takashi Iwai889c4392007-08-23 18:56:52 +020011628 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011629 return;
11630 alc268_acer_automute(codec, 1);
11631}
11632
Takashi Iwai889c4392007-08-23 18:56:52 +020011633static void alc268_acer_init_hook(struct hda_codec *codec)
11634{
11635 alc268_acer_automute(codec, 1);
11636}
11637
Kailang Yang8ef355d2008-08-26 13:10:22 +020011638/* toggle speaker-output according to the hp-jack state */
11639static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11640{
11641 unsigned int present;
11642 unsigned char bits;
11643
11644 present = snd_hda_codec_read(codec, 0x15, 0,
11645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11646 bits = present ? AMP_IN_MUTE(0) : 0;
11647 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11648 AMP_IN_MUTE(0), bits);
11649 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11650 AMP_IN_MUTE(0), bits);
11651}
11652
11653
11654static void alc268_acer_mic_automute(struct hda_codec *codec)
11655{
11656 unsigned int present;
11657
11658 present = snd_hda_codec_read(codec, 0x18, 0,
11659 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11660 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11661 present ? 0x0 : 0x6);
11662}
11663
11664static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11665 unsigned int res)
11666{
11667 if ((res >> 26) == ALC880_HP_EVENT)
11668 alc268_aspire_one_speaker_automute(codec);
11669 if ((res >> 26) == ALC880_MIC_EVENT)
11670 alc268_acer_mic_automute(codec);
11671}
11672
11673static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11674{
11675 alc268_aspire_one_speaker_automute(codec);
11676 alc268_acer_mic_automute(codec);
11677}
11678
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011679static struct snd_kcontrol_new alc268_dell_mixer[] = {
11680 /* output mixer control */
11681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11682 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11683 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11686 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11687 { }
11688};
11689
11690static struct hda_verb alc268_dell_verbs[] = {
11691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11693 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11694 { }
11695};
11696
11697/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011698static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011699{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011700 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011701
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011702 spec->autocfg.hp_pins[0] = 0x15;
11703 spec->autocfg.speaker_pins[0] = 0x14;
11704 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011705}
11706
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011707static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11708 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11709 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11710 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11712 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11713 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11714 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11715 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11716 { }
11717};
11718
11719static struct hda_verb alc267_quanta_il1_verbs[] = {
11720 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11721 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11722 { }
11723};
11724
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011725static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11726{
11727 unsigned int present;
11728
11729 present = snd_hda_codec_read(codec, 0x18, 0,
11730 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11731 snd_hda_codec_write(codec, 0x23, 0,
11732 AC_VERB_SET_CONNECT_SEL,
11733 present ? 0x00 : 0x01);
11734}
11735
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011736static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011737{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011738 struct alc_spec *spec = codec->spec;
11739
11740 spec->autocfg.hp_pins[0] = 0x15;
11741 spec->autocfg.speaker_pins[0] = 0x14;
11742 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011743 alc267_quanta_il1_mic_automute(codec);
11744}
11745
11746static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11747 unsigned int res)
11748{
11749 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011750 case ALC880_MIC_EVENT:
11751 alc267_quanta_il1_mic_automute(codec);
11752 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011753 default:
11754 alc_sku_unsol_event(codec, res);
11755 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011756 }
11757}
11758
Kailang Yanga361d842007-06-05 12:30:55 +020011759/*
11760 * generic initialization of ADC, input mixers and output mixers
11761 */
11762static struct hda_verb alc268_base_init_verbs[] = {
11763 /* Unmute DAC0-1 and set vol = 0 */
11764 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011765 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011766
11767 /*
11768 * Set up output mixers (0x0c - 0x0e)
11769 */
11770 /* set vol=0 to output mixers */
11771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011772 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11773
11774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11776
11777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11780 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11781 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11783 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11784 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11785
11786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011790 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011791
11792 /* set PCBEEP vol = 0, mute connections */
11793 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11795 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011796
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011797 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011798
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011799 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11800 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11801 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011803
Kailang Yanga361d842007-06-05 12:30:55 +020011804 { }
11805};
11806
11807/*
11808 * generic initialization of ADC, input mixers and output mixers
11809 */
11810static struct hda_verb alc268_volume_init_verbs[] = {
11811 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011812 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11813 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011814
11815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11817 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11819 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11820
Kailang Yanga361d842007-06-05 12:30:55 +020011821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11823 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11824
11825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011827
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011828 /* set PCBEEP vol = 0, mute connections */
11829 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11830 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11831 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011832
11833 { }
11834};
11835
Kailang Yanga361d842007-06-05 12:30:55 +020011836static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11837 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11838 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11839 {
11840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11841 /* The multiple "Capture Source" controls confuse alsamixer
11842 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011843 */
11844 /* .name = "Capture Source", */
11845 .name = "Input Source",
11846 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011847 .info = alc_mux_enum_info,
11848 .get = alc_mux_enum_get,
11849 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011850 },
11851 { } /* end */
11852};
11853
11854static struct snd_kcontrol_new alc268_capture_mixer[] = {
11855 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11856 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11859 {
11860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11861 /* The multiple "Capture Source" controls confuse alsamixer
11862 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011863 */
11864 /* .name = "Capture Source", */
11865 .name = "Input Source",
11866 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011867 .info = alc_mux_enum_info,
11868 .get = alc_mux_enum_get,
11869 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011870 },
11871 { } /* end */
11872};
11873
11874static struct hda_input_mux alc268_capture_source = {
11875 .num_items = 4,
11876 .items = {
11877 { "Mic", 0x0 },
11878 { "Front Mic", 0x1 },
11879 { "Line", 0x2 },
11880 { "CD", 0x3 },
11881 },
11882};
11883
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011884static struct hda_input_mux alc268_acer_capture_source = {
11885 .num_items = 3,
11886 .items = {
11887 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011888 { "Internal Mic", 0x1 },
11889 { "Line", 0x2 },
11890 },
11891};
11892
11893static struct hda_input_mux alc268_acer_dmic_capture_source = {
11894 .num_items = 3,
11895 .items = {
11896 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011897 { "Internal Mic", 0x6 },
11898 { "Line", 0x2 },
11899 },
11900};
11901
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011902#ifdef CONFIG_SND_DEBUG
11903static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011904 /* Volume widgets */
11905 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11906 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11907 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11908 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11909 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11910 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11911 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11912 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11913 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11914 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11915 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11916 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11917 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011918 /* The below appears problematic on some hardwares */
11919 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011920 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11921 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11922 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11923 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11924
11925 /* Modes for retasking pin widgets */
11926 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11927 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11928 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11929 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11930
11931 /* Controls for GPIO pins, assuming they are configured as outputs */
11932 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11933 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11934 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11935 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11936
11937 /* Switches to allow the digital SPDIF output pin to be enabled.
11938 * The ALC268 does not have an SPDIF input.
11939 */
11940 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11941
11942 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11943 * this output to turn on an external amplifier.
11944 */
11945 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11946 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11947
11948 { } /* end */
11949};
11950#endif
11951
Kailang Yanga361d842007-06-05 12:30:55 +020011952/* create input playback/capture controls for the given pin */
11953static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11954 const char *ctlname, int idx)
11955{
11956 char name[32];
11957 int err;
11958
11959 sprintf(name, "%s Playback Volume", ctlname);
11960 if (nid == 0x14) {
11961 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11962 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11963 HDA_OUTPUT));
11964 if (err < 0)
11965 return err;
11966 } else if (nid == 0x15) {
11967 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11968 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11969 HDA_OUTPUT));
11970 if (err < 0)
11971 return err;
11972 } else
11973 return -1;
11974 sprintf(name, "%s Playback Switch", ctlname);
11975 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11976 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11977 if (err < 0)
11978 return err;
11979 return 0;
11980}
11981
11982/* add playback controls from the parsed DAC table */
11983static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11984 const struct auto_pin_cfg *cfg)
11985{
11986 hda_nid_t nid;
11987 int err;
11988
11989 spec->multiout.num_dacs = 2; /* only use one dac */
11990 spec->multiout.dac_nids = spec->private_dac_nids;
11991 spec->multiout.dac_nids[0] = 2;
11992 spec->multiout.dac_nids[1] = 3;
11993
11994 nid = cfg->line_out_pins[0];
11995 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011996 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011997
11998 nid = cfg->speaker_pins[0];
11999 if (nid == 0x1d) {
12000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12001 "Speaker Playback Volume",
12002 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12003 if (err < 0)
12004 return err;
12005 }
12006 nid = cfg->hp_pins[0];
12007 if (nid)
12008 alc268_new_analog_output(spec, nid, "Headphone", 0);
12009
12010 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12011 if (nid == 0x16) {
12012 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12013 "Mono Playback Switch",
12014 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12015 if (err < 0)
12016 return err;
12017 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012018 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012019}
12020
12021/* create playback/capture controls for input pins */
12022static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12023 const struct auto_pin_cfg *cfg)
12024{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012025 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012026 int i, idx1;
12027
12028 for (i = 0; i < AUTO_PIN_LAST; i++) {
12029 switch(cfg->input_pins[i]) {
12030 case 0x18:
12031 idx1 = 0; /* Mic 1 */
12032 break;
12033 case 0x19:
12034 idx1 = 1; /* Mic 2 */
12035 break;
12036 case 0x1a:
12037 idx1 = 2; /* Line In */
12038 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012039 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012040 idx1 = 3; /* CD */
12041 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012042 case 0x12:
12043 case 0x13:
12044 idx1 = 6; /* digital mics */
12045 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012046 default:
12047 continue;
12048 }
12049 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12050 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012051 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012052 }
12053 return 0;
12054}
12055
12056static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12057{
12058 struct alc_spec *spec = codec->spec;
12059 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12060 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12061 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12062 unsigned int dac_vol1, dac_vol2;
12063
12064 if (speaker_nid) {
12065 snd_hda_codec_write(codec, speaker_nid, 0,
12066 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12067 snd_hda_codec_write(codec, 0x0f, 0,
12068 AC_VERB_SET_AMP_GAIN_MUTE,
12069 AMP_IN_UNMUTE(1));
12070 snd_hda_codec_write(codec, 0x10, 0,
12071 AC_VERB_SET_AMP_GAIN_MUTE,
12072 AMP_IN_UNMUTE(1));
12073 } else {
12074 snd_hda_codec_write(codec, 0x0f, 0,
12075 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12076 snd_hda_codec_write(codec, 0x10, 0,
12077 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12078 }
12079
12080 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012081 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012082 dac_vol2 = AMP_OUT_ZERO;
12083 else if (line_nid == 0x15)
12084 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012085 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012086 dac_vol2 = AMP_OUT_ZERO;
12087 else if (hp_nid == 0x15)
12088 dac_vol1 = AMP_OUT_ZERO;
12089 if (line_nid != 0x16 || hp_nid != 0x16 ||
12090 spec->autocfg.line_out_pins[1] != 0x16 ||
12091 spec->autocfg.line_out_pins[2] != 0x16)
12092 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12093
12094 snd_hda_codec_write(codec, 0x02, 0,
12095 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12096 snd_hda_codec_write(codec, 0x03, 0,
12097 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12098}
12099
12100/* pcm configuration: identiacal with ALC880 */
12101#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12102#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012103#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012104#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12105
12106/*
12107 * BIOS auto configuration
12108 */
12109static int alc268_parse_auto_config(struct hda_codec *codec)
12110{
12111 struct alc_spec *spec = codec->spec;
12112 int err;
12113 static hda_nid_t alc268_ignore[] = { 0 };
12114
12115 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12116 alc268_ignore);
12117 if (err < 0)
12118 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012119 if (!spec->autocfg.line_outs) {
12120 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12121 spec->multiout.max_channels = 2;
12122 spec->no_analog = 1;
12123 goto dig_only;
12124 }
Kailang Yanga361d842007-06-05 12:30:55 +020012125 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012126 }
Kailang Yanga361d842007-06-05 12:30:55 +020012127 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12128 if (err < 0)
12129 return err;
12130 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12131 if (err < 0)
12132 return err;
12133
12134 spec->multiout.max_channels = 2;
12135
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012136 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012137 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012138 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012139 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012140 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12141 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012142 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012143 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012144
Takashi Iwai892981f2009-03-02 08:04:35 +010012145 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012146 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012147
Takashi Iwaid88897e2008-10-31 15:01:37 +010012148 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012149 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012150 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012151
Takashi Iwai776e1842007-08-29 15:07:11 +020012152 err = alc_auto_add_mic_boost(codec);
12153 if (err < 0)
12154 return err;
12155
Kailang Yanga361d842007-06-05 12:30:55 +020012156 return 1;
12157}
12158
12159#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12160#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12161#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12162
12163/* init callback for auto-configuration model -- overriding the default init */
12164static void alc268_auto_init(struct hda_codec *codec)
12165{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012166 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012167 alc268_auto_init_multi_out(codec);
12168 alc268_auto_init_hp_out(codec);
12169 alc268_auto_init_mono_speaker_out(codec);
12170 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012171 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012172 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012173}
12174
12175/*
12176 * configuration and preset
12177 */
12178static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012179 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012180 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012181 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012182 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012183 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012184 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012185 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012186 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012187#ifdef CONFIG_SND_DEBUG
12188 [ALC268_TEST] = "test",
12189#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012190 [ALC268_AUTO] = "auto",
12191};
12192
12193static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012194 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012195 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012196 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012197 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012198 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012199 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12200 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012201 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012202 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012203 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12204 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012205 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012206 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12207 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12208 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012209 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012210 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012211 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012212 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012213 {}
12214};
12215
12216static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012217 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012218 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012219 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12220 alc267_quanta_il1_verbs },
12221 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12222 .dac_nids = alc268_dac_nids,
12223 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12224 .adc_nids = alc268_adc_nids_alt,
12225 .hp_nid = 0x03,
12226 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12227 .channel_mode = alc268_modes,
12228 .input_mux = &alc268_capture_source,
12229 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012230 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012231 },
Kailang Yanga361d842007-06-05 12:30:55 +020012232 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012233 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12234 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012235 .init_verbs = { alc268_base_init_verbs },
12236 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12237 .dac_nids = alc268_dac_nids,
12238 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12239 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012240 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012241 .hp_nid = 0x03,
12242 .dig_out_nid = ALC268_DIGOUT_NID,
12243 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12244 .channel_mode = alc268_modes,
12245 .input_mux = &alc268_capture_source,
12246 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012247 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012248 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012249 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012250 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12251 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012252 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12253 .dac_nids = alc268_dac_nids,
12254 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12255 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012256 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012257 .hp_nid = 0x03,
12258 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12259 .channel_mode = alc268_modes,
12260 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012261 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012262 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012263 },
12264 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012265 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12266 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012267 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12268 alc268_acer_verbs },
12269 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12270 .dac_nids = alc268_dac_nids,
12271 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12272 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012273 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012274 .hp_nid = 0x02,
12275 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12276 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012277 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012278 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012279 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012280 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012281 [ALC268_ACER_DMIC] = {
12282 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12283 alc268_beep_mixer },
12284 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12285 alc268_acer_verbs },
12286 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12287 .dac_nids = alc268_dac_nids,
12288 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12289 .adc_nids = alc268_adc_nids_alt,
12290 .capsrc_nids = alc268_capsrc_nids,
12291 .hp_nid = 0x02,
12292 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12293 .channel_mode = alc268_modes,
12294 .input_mux = &alc268_acer_dmic_capture_source,
12295 .unsol_event = alc268_acer_unsol_event,
12296 .init_hook = alc268_acer_init_hook,
12297 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012298 [ALC268_ACER_ASPIRE_ONE] = {
12299 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012300 alc268_beep_mixer,
12301 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012302 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12303 alc268_acer_aspire_one_verbs },
12304 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12305 .dac_nids = alc268_dac_nids,
12306 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12307 .adc_nids = alc268_adc_nids_alt,
12308 .capsrc_nids = alc268_capsrc_nids,
12309 .hp_nid = 0x03,
12310 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12311 .channel_mode = alc268_modes,
12312 .input_mux = &alc268_acer_lc_capture_source,
12313 .unsol_event = alc268_acer_lc_unsol_event,
12314 .init_hook = alc268_acer_lc_init_hook,
12315 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012316 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012317 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012318 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12319 alc268_dell_verbs },
12320 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12321 .dac_nids = alc268_dac_nids,
12322 .hp_nid = 0x02,
12323 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12324 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012325 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012326 .init_hook = alc268_dell_init_hook,
12327 .input_mux = &alc268_capture_source,
12328 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012329 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012330 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12331 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012332 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12333 alc268_toshiba_verbs },
12334 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12335 .dac_nids = alc268_dac_nids,
12336 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12337 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012338 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012339 .hp_nid = 0x03,
12340 .dig_out_nid = ALC268_DIGOUT_NID,
12341 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12342 .channel_mode = alc268_modes,
12343 .input_mux = &alc268_capture_source,
12344 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012345 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012346 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012347#ifdef CONFIG_SND_DEBUG
12348 [ALC268_TEST] = {
12349 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12350 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12351 alc268_volume_init_verbs },
12352 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12353 .dac_nids = alc268_dac_nids,
12354 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12355 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012356 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012357 .hp_nid = 0x03,
12358 .dig_out_nid = ALC268_DIGOUT_NID,
12359 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12360 .channel_mode = alc268_modes,
12361 .input_mux = &alc268_capture_source,
12362 },
12363#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012364};
12365
12366static int patch_alc268(struct hda_codec *codec)
12367{
12368 struct alc_spec *spec;
12369 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012370 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012371
12372 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12373 if (spec == NULL)
12374 return -ENOMEM;
12375
12376 codec->spec = spec;
12377
12378 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12379 alc268_models,
12380 alc268_cfg_tbl);
12381
12382 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012383 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12384 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012385 board_config = ALC268_AUTO;
12386 }
12387
12388 if (board_config == ALC268_AUTO) {
12389 /* automatic parse from the BIOS config */
12390 err = alc268_parse_auto_config(codec);
12391 if (err < 0) {
12392 alc_free(codec);
12393 return err;
12394 } else if (!err) {
12395 printk(KERN_INFO
12396 "hda_codec: Cannot set up configuration "
12397 "from BIOS. Using base mode...\n");
12398 board_config = ALC268_3ST;
12399 }
12400 }
12401
12402 if (board_config != ALC268_AUTO)
12403 setup_preset(spec, &alc268_presets[board_config]);
12404
Kailang Yanga361d842007-06-05 12:30:55 +020012405 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12406 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012407 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012408
Kailang Yanga361d842007-06-05 12:30:55 +020012409 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12410
Takashi Iwai22971e32009-02-10 11:56:44 +010012411 has_beep = 0;
12412 for (i = 0; i < spec->num_mixers; i++) {
12413 if (spec->mixers[i] == alc268_beep_mixer) {
12414 has_beep = 1;
12415 break;
12416 }
12417 }
12418
12419 if (has_beep) {
12420 err = snd_hda_attach_beep_device(codec, 0x1);
12421 if (err < 0) {
12422 alc_free(codec);
12423 return err;
12424 }
12425 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12426 /* override the amp caps for beep generator */
12427 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012428 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12429 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12430 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12431 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012432 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012433
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012434 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012435 /* check whether NID 0x07 is valid */
12436 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012437 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012438
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012439 /* get type */
12440 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012441 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012442 spec->adc_nids = alc268_adc_nids_alt;
12443 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012444 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012445 } else {
12446 spec->adc_nids = alc268_adc_nids;
12447 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012448 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012449 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012450 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012451 /* set default input source */
12452 for (i = 0; i < spec->num_adc_nids; i++)
12453 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12454 0, AC_VERB_SET_CONNECT_SEL,
12455 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012456 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012457
12458 spec->vmaster_nid = 0x02;
12459
Kailang Yanga361d842007-06-05 12:30:55 +020012460 codec->patch_ops = alc_patch_ops;
12461 if (board_config == ALC268_AUTO)
12462 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012463
Takashi Iwaidaead532008-11-28 12:55:36 +010012464 codec->proc_widget_hook = print_realtek_coef;
12465
Kailang Yanga361d842007-06-05 12:30:55 +020012466 return 0;
12467}
12468
12469/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012470 * ALC269 channel source setting (2 channel)
12471 */
12472#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12473
12474#define alc269_dac_nids alc260_dac_nids
12475
12476static hda_nid_t alc269_adc_nids[1] = {
12477 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012478 0x08,
12479};
12480
Takashi Iwaie01bf502008-08-21 16:25:07 +020012481static hda_nid_t alc269_capsrc_nids[1] = {
12482 0x23,
12483};
12484
12485/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12486 * not a mux!
12487 */
12488
Kailang Yangf53281e2008-07-18 12:36:43 +020012489static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12490 .num_items = 2,
12491 .items = {
12492 { "i-Mic", 0x5 },
12493 { "e-Mic", 0x0 },
12494 },
12495};
12496
12497static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12498 .num_items = 2,
12499 .items = {
12500 { "i-Mic", 0x1 },
12501 { "e-Mic", 0x0 },
12502 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012503};
12504
12505#define alc269_modes alc260_modes
12506#define alc269_capture_source alc880_lg_lw_capture_source
12507
12508static struct snd_kcontrol_new alc269_base_mixer[] = {
12509 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12510 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12511 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12512 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12516 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12520 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12521 { } /* end */
12522};
12523
Kailang Yang60db6b52008-08-26 13:13:00 +020012524static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12525 /* output mixer control */
12526 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12527 {
12528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12529 .name = "Master Playback Switch",
12530 .info = snd_hda_mixer_amp_switch_info,
12531 .get = snd_hda_mixer_amp_switch_get,
12532 .put = alc268_acer_master_sw_put,
12533 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12534 },
12535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12537 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12538 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12539 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12540 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012541 { }
12542};
12543
Tony Vroon64154832008-11-06 15:08:49 +000012544static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12545 /* output mixer control */
12546 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12547 {
12548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12549 .name = "Master Playback Switch",
12550 .info = snd_hda_mixer_amp_switch_info,
12551 .get = snd_hda_mixer_amp_switch_get,
12552 .put = alc268_acer_master_sw_put,
12553 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12554 },
12555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12557 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12558 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12559 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12560 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12561 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12562 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12563 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012564 { }
12565};
12566
Kailang Yangf53281e2008-07-18 12:36:43 +020012567/* bind volumes of both NID 0x0c and 0x0d */
12568static struct hda_bind_ctls alc269_epc_bind_vol = {
12569 .ops = &snd_hda_bind_vol,
12570 .values = {
12571 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12572 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12573 0
12574 },
12575};
12576
12577static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12578 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12579 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12580 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12581 { } /* end */
12582};
12583
Kailang Yangf6a92242007-12-13 16:52:54 +010012584/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012585static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12586 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12587 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12589 { } /* end */
12590};
12591
12592/* FSC amilo */
12593static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12594 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12596 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012597 { } /* end */
12598};
12599
Kailang Yang60db6b52008-08-26 13:13:00 +020012600static struct hda_verb alc269_quanta_fl1_verbs[] = {
12601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12602 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12605 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12606 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12607 { }
12608};
12609
Tony Vroon64154832008-11-06 15:08:49 +000012610static struct hda_verb alc269_lifebook_verbs[] = {
12611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12612 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12613 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12615 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12618 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12619 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12620 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12621 { }
12622};
12623
Kailang Yang60db6b52008-08-26 13:13:00 +020012624/* toggle speaker-output according to the hp-jack state */
12625static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12626{
12627 unsigned int present;
12628 unsigned char bits;
12629
12630 present = snd_hda_codec_read(codec, 0x15, 0,
12631 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12632 bits = present ? AMP_IN_MUTE(0) : 0;
12633 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12634 AMP_IN_MUTE(0), bits);
12635 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12636 AMP_IN_MUTE(0), bits);
12637
12638 snd_hda_codec_write(codec, 0x20, 0,
12639 AC_VERB_SET_COEF_INDEX, 0x0c);
12640 snd_hda_codec_write(codec, 0x20, 0,
12641 AC_VERB_SET_PROC_COEF, 0x680);
12642
12643 snd_hda_codec_write(codec, 0x20, 0,
12644 AC_VERB_SET_COEF_INDEX, 0x0c);
12645 snd_hda_codec_write(codec, 0x20, 0,
12646 AC_VERB_SET_PROC_COEF, 0x480);
12647}
12648
Tony Vroon64154832008-11-06 15:08:49 +000012649/* toggle speaker-output according to the hp-jacks state */
12650static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12651{
12652 unsigned int present;
12653 unsigned char bits;
12654
12655 /* Check laptop headphone socket */
12656 present = snd_hda_codec_read(codec, 0x15, 0,
12657 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12658
12659 /* Check port replicator headphone socket */
12660 present |= snd_hda_codec_read(codec, 0x1a, 0,
12661 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12662
12663 bits = present ? AMP_IN_MUTE(0) : 0;
12664 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12665 AMP_IN_MUTE(0), bits);
12666 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12667 AMP_IN_MUTE(0), bits);
12668
12669 snd_hda_codec_write(codec, 0x20, 0,
12670 AC_VERB_SET_COEF_INDEX, 0x0c);
12671 snd_hda_codec_write(codec, 0x20, 0,
12672 AC_VERB_SET_PROC_COEF, 0x680);
12673
12674 snd_hda_codec_write(codec, 0x20, 0,
12675 AC_VERB_SET_COEF_INDEX, 0x0c);
12676 snd_hda_codec_write(codec, 0x20, 0,
12677 AC_VERB_SET_PROC_COEF, 0x480);
12678}
12679
Kailang Yang60db6b52008-08-26 13:13:00 +020012680static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12681{
12682 unsigned int present;
12683
12684 present = snd_hda_codec_read(codec, 0x18, 0,
12685 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12686 snd_hda_codec_write(codec, 0x23, 0,
12687 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12688}
12689
Tony Vroon64154832008-11-06 15:08:49 +000012690static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12691{
12692 unsigned int present_laptop;
12693 unsigned int present_dock;
12694
12695 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12696 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12697
12698 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12699 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12700
12701 /* Laptop mic port overrides dock mic port, design decision */
12702 if (present_dock)
12703 snd_hda_codec_write(codec, 0x23, 0,
12704 AC_VERB_SET_CONNECT_SEL, 0x3);
12705 if (present_laptop)
12706 snd_hda_codec_write(codec, 0x23, 0,
12707 AC_VERB_SET_CONNECT_SEL, 0x0);
12708 if (!present_dock && !present_laptop)
12709 snd_hda_codec_write(codec, 0x23, 0,
12710 AC_VERB_SET_CONNECT_SEL, 0x1);
12711}
12712
Kailang Yang60db6b52008-08-26 13:13:00 +020012713static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12714 unsigned int res)
12715{
12716 if ((res >> 26) == ALC880_HP_EVENT)
12717 alc269_quanta_fl1_speaker_automute(codec);
12718 if ((res >> 26) == ALC880_MIC_EVENT)
12719 alc269_quanta_fl1_mic_automute(codec);
12720}
12721
Tony Vroon64154832008-11-06 15:08:49 +000012722static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12723 unsigned int res)
12724{
12725 if ((res >> 26) == ALC880_HP_EVENT)
12726 alc269_lifebook_speaker_automute(codec);
12727 if ((res >> 26) == ALC880_MIC_EVENT)
12728 alc269_lifebook_mic_autoswitch(codec);
12729}
12730
Kailang Yang60db6b52008-08-26 13:13:00 +020012731static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12732{
12733 alc269_quanta_fl1_speaker_automute(codec);
12734 alc269_quanta_fl1_mic_automute(codec);
12735}
12736
Tony Vroon64154832008-11-06 15:08:49 +000012737static void alc269_lifebook_init_hook(struct hda_codec *codec)
12738{
12739 alc269_lifebook_speaker_automute(codec);
12740 alc269_lifebook_mic_autoswitch(codec);
12741}
12742
Kailang Yang60db6b52008-08-26 13:13:00 +020012743static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12744 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12745 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12748 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12749 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12750 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12751 {}
12752};
12753
12754static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12756 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12757 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12759 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12760 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12761 {}
12762};
12763
12764/* toggle speaker-output according to the hp-jack state */
12765static void alc269_speaker_automute(struct hda_codec *codec)
12766{
12767 unsigned int present;
12768 unsigned char bits;
12769
12770 present = snd_hda_codec_read(codec, 0x15, 0,
12771 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12772 bits = present ? AMP_IN_MUTE(0) : 0;
12773 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12774 AMP_IN_MUTE(0), bits);
12775 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12776 AMP_IN_MUTE(0), bits);
12777}
12778
12779static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12780{
12781 unsigned int present;
12782
12783 present = snd_hda_codec_read(codec, 0x18, 0,
12784 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12785 snd_hda_codec_write(codec, 0x23, 0,
12786 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12787}
12788
12789static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12790{
12791 unsigned int present;
12792
12793 present = snd_hda_codec_read(codec, 0x18, 0,
12794 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12795 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12796 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12797 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12798 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12799}
12800
12801/* unsolicited event for HP jack sensing */
12802static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12803 unsigned int res)
12804{
12805 if ((res >> 26) == ALC880_HP_EVENT)
12806 alc269_speaker_automute(codec);
12807
12808 if ((res >> 26) == ALC880_MIC_EVENT)
12809 alc269_eeepc_dmic_automute(codec);
12810}
12811
12812static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12813{
12814 alc269_speaker_automute(codec);
12815 alc269_eeepc_dmic_automute(codec);
12816}
12817
12818/* unsolicited event for HP jack sensing */
12819static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12820 unsigned int res)
12821{
12822 if ((res >> 26) == ALC880_HP_EVENT)
12823 alc269_speaker_automute(codec);
12824
12825 if ((res >> 26) == ALC880_MIC_EVENT)
12826 alc269_eeepc_amic_automute(codec);
12827}
12828
12829static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12830{
12831 alc269_speaker_automute(codec);
12832 alc269_eeepc_amic_automute(codec);
12833}
12834
Kailang Yangf6a92242007-12-13 16:52:54 +010012835/*
12836 * generic initialization of ADC, input mixers and output mixers
12837 */
12838static struct hda_verb alc269_init_verbs[] = {
12839 /*
12840 * Unmute ADC0 and set the default input to mic-in
12841 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012843
12844 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12845 * analog-loopback mixer widget
12846 * Note: PASD motherboards uses the Line In 2 as the input for
12847 * front panel mic (mic 2)
12848 */
12849 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12855
12856 /*
12857 * Set up output mixers (0x0c - 0x0e)
12858 */
12859 /* set vol=0 to output mixers */
12860 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12861 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12862
12863 /* set up input amps for analog loopback */
12864 /* Amp Indices: DAC = 0, mixer = 1 */
12865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12870 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12871
12872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12875 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12879
12880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12887
12888 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12890
12891 /* FIXME: use matrix-type input source selection */
12892 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12893 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12898
12899 /* set EAPD */
12900 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12901 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12902 { }
12903};
12904
12905/* add playback controls from the parsed DAC table */
12906static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12907 const struct auto_pin_cfg *cfg)
12908{
12909 hda_nid_t nid;
12910 int err;
12911
12912 spec->multiout.num_dacs = 1; /* only use one dac */
12913 spec->multiout.dac_nids = spec->private_dac_nids;
12914 spec->multiout.dac_nids[0] = 2;
12915
12916 nid = cfg->line_out_pins[0];
12917 if (nid) {
12918 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12919 "Front Playback Volume",
12920 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12921 if (err < 0)
12922 return err;
12923 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12924 "Front Playback Switch",
12925 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12926 if (err < 0)
12927 return err;
12928 }
12929
12930 nid = cfg->speaker_pins[0];
12931 if (nid) {
12932 if (!cfg->line_out_pins[0]) {
12933 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12934 "Speaker Playback Volume",
12935 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12936 HDA_OUTPUT));
12937 if (err < 0)
12938 return err;
12939 }
12940 if (nid == 0x16) {
12941 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12942 "Speaker Playback Switch",
12943 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12944 HDA_OUTPUT));
12945 if (err < 0)
12946 return err;
12947 } else {
12948 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12949 "Speaker Playback Switch",
12950 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12951 HDA_OUTPUT));
12952 if (err < 0)
12953 return err;
12954 }
12955 }
12956 nid = cfg->hp_pins[0];
12957 if (nid) {
12958 /* spec->multiout.hp_nid = 2; */
12959 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12960 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12961 "Headphone Playback Volume",
12962 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12963 HDA_OUTPUT));
12964 if (err < 0)
12965 return err;
12966 }
12967 if (nid == 0x16) {
12968 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12969 "Headphone Playback Switch",
12970 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12971 HDA_OUTPUT));
12972 if (err < 0)
12973 return err;
12974 } else {
12975 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12976 "Headphone Playback Switch",
12977 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12978 HDA_OUTPUT));
12979 if (err < 0)
12980 return err;
12981 }
12982 }
12983 return 0;
12984}
12985
Takashi Iwaiee956e02008-10-31 17:16:31 +010012986static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12987 const struct auto_pin_cfg *cfg)
12988{
12989 int err;
12990
12991 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12992 if (err < 0)
12993 return err;
12994 /* digital-mic input pin is excluded in alc880_auto_create..()
12995 * because it's under 0x18
12996 */
12997 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12998 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012999 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010013000 imux->items[imux->num_items].label = "Int Mic";
13001 imux->items[imux->num_items].index = 0x05;
13002 imux->num_items++;
13003 }
13004 return 0;
13005}
Kailang Yangf6a92242007-12-13 16:52:54 +010013006
13007#ifdef CONFIG_SND_HDA_POWER_SAVE
13008#define alc269_loopbacks alc880_loopbacks
13009#endif
13010
13011/* pcm configuration: identiacal with ALC880 */
13012#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13013#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13014#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13015#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13016
Takashi Iwaif03d3112009-03-05 14:18:16 +010013017static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13018 .substreams = 1,
13019 .channels_min = 2,
13020 .channels_max = 8,
13021 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13022 /* NID is set in alc_build_pcms */
13023 .ops = {
13024 .open = alc880_playback_pcm_open,
13025 .prepare = alc880_playback_pcm_prepare,
13026 .cleanup = alc880_playback_pcm_cleanup
13027 },
13028};
13029
13030static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13031 .substreams = 1,
13032 .channels_min = 2,
13033 .channels_max = 2,
13034 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13035 /* NID is set in alc_build_pcms */
13036};
13037
Kailang Yangf6a92242007-12-13 16:52:54 +010013038/*
13039 * BIOS auto configuration
13040 */
13041static int alc269_parse_auto_config(struct hda_codec *codec)
13042{
13043 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013044 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013045 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13046
13047 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13048 alc269_ignore);
13049 if (err < 0)
13050 return err;
13051
13052 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13053 if (err < 0)
13054 return err;
13055 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13056 if (err < 0)
13057 return err;
13058
13059 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13060
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013061 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013062 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13063
Takashi Iwai603c4012008-07-30 15:01:44 +020013064 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013065 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013066
Takashi Iwaid88897e2008-10-31 15:01:37 +010013067 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013068 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013069 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013070 /* set default input source */
13071 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13072 0, AC_VERB_SET_CONNECT_SEL,
13073 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013074
13075 err = alc_auto_add_mic_boost(codec);
13076 if (err < 0)
13077 return err;
13078
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013079 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013080 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013081
Kailang Yangf6a92242007-12-13 16:52:54 +010013082 return 1;
13083}
13084
13085#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13086#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13087#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13088
13089
13090/* init callback for auto-configuration model -- overriding the default init */
13091static void alc269_auto_init(struct hda_codec *codec)
13092{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013093 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013094 alc269_auto_init_multi_out(codec);
13095 alc269_auto_init_hp_out(codec);
13096 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013097 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013098 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013099}
13100
13101/*
13102 * configuration and preset
13103 */
13104static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013105 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013106 [ALC269_QUANTA_FL1] = "quanta",
13107 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013108 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013109 [ALC269_FUJITSU] = "fujitsu",
13110 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013111};
13112
13113static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013114 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013115 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13116 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013117 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13118 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13119 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13120 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13121 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13122 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013123 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13124 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013125 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13126 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013127 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013128 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013129 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013130 {}
13131};
13132
13133static struct alc_config_preset alc269_presets[] = {
13134 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013135 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013136 .init_verbs = { alc269_init_verbs },
13137 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13138 .dac_nids = alc269_dac_nids,
13139 .hp_nid = 0x03,
13140 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13141 .channel_mode = alc269_modes,
13142 .input_mux = &alc269_capture_source,
13143 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013144 [ALC269_QUANTA_FL1] = {
13145 .mixers = { alc269_quanta_fl1_mixer },
13146 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13147 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13148 .dac_nids = alc269_dac_nids,
13149 .hp_nid = 0x03,
13150 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13151 .channel_mode = alc269_modes,
13152 .input_mux = &alc269_capture_source,
13153 .unsol_event = alc269_quanta_fl1_unsol_event,
13154 .init_hook = alc269_quanta_fl1_init_hook,
13155 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013156 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013157 .mixers = { alc269_eeepc_mixer },
13158 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013159 .init_verbs = { alc269_init_verbs,
13160 alc269_eeepc_amic_init_verbs },
13161 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13162 .dac_nids = alc269_dac_nids,
13163 .hp_nid = 0x03,
13164 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13165 .channel_mode = alc269_modes,
13166 .input_mux = &alc269_eeepc_amic_capture_source,
13167 .unsol_event = alc269_eeepc_amic_unsol_event,
13168 .init_hook = alc269_eeepc_amic_inithook,
13169 },
13170 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013171 .mixers = { alc269_eeepc_mixer },
13172 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013173 .init_verbs = { alc269_init_verbs,
13174 alc269_eeepc_dmic_init_verbs },
13175 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13176 .dac_nids = alc269_dac_nids,
13177 .hp_nid = 0x03,
13178 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13179 .channel_mode = alc269_modes,
13180 .input_mux = &alc269_eeepc_dmic_capture_source,
13181 .unsol_event = alc269_eeepc_dmic_unsol_event,
13182 .init_hook = alc269_eeepc_dmic_inithook,
13183 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013184 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013185 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013186 .cap_mixer = alc269_epc_capture_mixer,
13187 .init_verbs = { alc269_init_verbs,
13188 alc269_eeepc_dmic_init_verbs },
13189 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13190 .dac_nids = alc269_dac_nids,
13191 .hp_nid = 0x03,
13192 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13193 .channel_mode = alc269_modes,
13194 .input_mux = &alc269_eeepc_dmic_capture_source,
13195 .unsol_event = alc269_eeepc_dmic_unsol_event,
13196 .init_hook = alc269_eeepc_dmic_inithook,
13197 },
Tony Vroon64154832008-11-06 15:08:49 +000013198 [ALC269_LIFEBOOK] = {
13199 .mixers = { alc269_lifebook_mixer },
13200 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13201 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13202 .dac_nids = alc269_dac_nids,
13203 .hp_nid = 0x03,
13204 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13205 .channel_mode = alc269_modes,
13206 .input_mux = &alc269_capture_source,
13207 .unsol_event = alc269_lifebook_unsol_event,
13208 .init_hook = alc269_lifebook_init_hook,
13209 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013210};
13211
13212static int patch_alc269(struct hda_codec *codec)
13213{
13214 struct alc_spec *spec;
13215 int board_config;
13216 int err;
13217
13218 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13219 if (spec == NULL)
13220 return -ENOMEM;
13221
13222 codec->spec = spec;
13223
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013224 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13225
Kailang Yangf6a92242007-12-13 16:52:54 +010013226 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13227 alc269_models,
13228 alc269_cfg_tbl);
13229
13230 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013231 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13232 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013233 board_config = ALC269_AUTO;
13234 }
13235
13236 if (board_config == ALC269_AUTO) {
13237 /* automatic parse from the BIOS config */
13238 err = alc269_parse_auto_config(codec);
13239 if (err < 0) {
13240 alc_free(codec);
13241 return err;
13242 } else if (!err) {
13243 printk(KERN_INFO
13244 "hda_codec: Cannot set up configuration "
13245 "from BIOS. Using base mode...\n");
13246 board_config = ALC269_BASIC;
13247 }
13248 }
13249
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013250 err = snd_hda_attach_beep_device(codec, 0x1);
13251 if (err < 0) {
13252 alc_free(codec);
13253 return err;
13254 }
13255
Kailang Yangf6a92242007-12-13 16:52:54 +010013256 if (board_config != ALC269_AUTO)
13257 setup_preset(spec, &alc269_presets[board_config]);
13258
Takashi Iwaif03d3112009-03-05 14:18:16 +010013259 if (codec->subsystem_id == 0x17aa3bf8) {
13260 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13261 * fix the sample rate of analog I/O to 44.1kHz
13262 */
13263 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13264 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13265 } else {
13266 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13267 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13268 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013269 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13270 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13271
13272 spec->adc_nids = alc269_adc_nids;
13273 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013274 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013275 if (!spec->cap_mixer)
13276 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013277 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013278
13279 codec->patch_ops = alc_patch_ops;
13280 if (board_config == ALC269_AUTO)
13281 spec->init_hook = alc269_auto_init;
13282#ifdef CONFIG_SND_HDA_POWER_SAVE
13283 if (!spec->loopback.amplist)
13284 spec->loopback.amplist = alc269_loopbacks;
13285#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013286 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013287
13288 return 0;
13289}
13290
13291/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013292 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13293 */
13294
13295/*
13296 * set the path ways for 2 channel output
13297 * need to set the codec line out and mic 1 pin widgets to inputs
13298 */
13299static struct hda_verb alc861_threestack_ch2_init[] = {
13300 /* set pin widget 1Ah (line in) for input */
13301 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013302 /* set pin widget 18h (mic1/2) for input, for mic also enable
13303 * the vref
13304 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013305 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13306
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13308#if 0
13309 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13310 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13311#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013312 { } /* end */
13313};
13314/*
13315 * 6ch mode
13316 * need to set the codec line out and mic 1 pin widgets to outputs
13317 */
13318static struct hda_verb alc861_threestack_ch6_init[] = {
13319 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13320 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13321 /* set pin widget 18h (mic1) for output (CLFE)*/
13322 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13323
13324 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013325 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013326
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13328#if 0
13329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13331#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013332 { } /* end */
13333};
13334
13335static struct hda_channel_mode alc861_threestack_modes[2] = {
13336 { 2, alc861_threestack_ch2_init },
13337 { 6, alc861_threestack_ch6_init },
13338};
Takashi Iwai22309c32006-08-09 16:57:28 +020013339/* Set mic1 as input and unmute the mixer */
13340static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13341 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13342 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13343 { } /* end */
13344};
13345/* Set mic1 as output and mute mixer */
13346static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13347 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13349 { } /* end */
13350};
13351
13352static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13353 { 2, alc861_uniwill_m31_ch2_init },
13354 { 4, alc861_uniwill_m31_ch4_init },
13355};
Kailang Yangdf694da2005-12-05 19:42:22 +010013356
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013357/* Set mic1 and line-in as input and unmute the mixer */
13358static struct hda_verb alc861_asus_ch2_init[] = {
13359 /* set pin widget 1Ah (line in) for input */
13360 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013361 /* set pin widget 18h (mic1/2) for input, for mic also enable
13362 * the vref
13363 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013364 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13365
13366 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13367#if 0
13368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13369 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13370#endif
13371 { } /* end */
13372};
13373/* Set mic1 nad line-in as output and mute mixer */
13374static struct hda_verb alc861_asus_ch6_init[] = {
13375 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13376 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13377 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13378 /* set pin widget 18h (mic1) for output (CLFE)*/
13379 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13380 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13381 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13382 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13383
13384 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13385#if 0
13386 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13388#endif
13389 { } /* end */
13390};
13391
13392static struct hda_channel_mode alc861_asus_modes[2] = {
13393 { 2, alc861_asus_ch2_init },
13394 { 6, alc861_asus_ch6_init },
13395};
13396
Kailang Yangdf694da2005-12-05 19:42:22 +010013397/* patch-ALC861 */
13398
13399static struct snd_kcontrol_new alc861_base_mixer[] = {
13400 /* output mixer control */
13401 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13402 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13403 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13404 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13405 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13406
13407 /*Input mixer control */
13408 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13409 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13410 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13411 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13412 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13413 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13415 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013418
Kailang Yangdf694da2005-12-05 19:42:22 +010013419 { } /* end */
13420};
13421
13422static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13423 /* output mixer control */
13424 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13425 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13426 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13427 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13428 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13429
13430 /* Input mixer control */
13431 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13432 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13433 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13434 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13435 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13436 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13438 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013441
Kailang Yangdf694da2005-12-05 19:42:22 +010013442 {
13443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13444 .name = "Channel Mode",
13445 .info = alc_ch_mode_info,
13446 .get = alc_ch_mode_get,
13447 .put = alc_ch_mode_put,
13448 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13449 },
13450 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013451};
13452
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013453static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013454 /* output mixer control */
13455 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13457 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013458
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013459 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013460};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013461
Takashi Iwai22309c32006-08-09 16:57:28 +020013462static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13463 /* output mixer control */
13464 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13465 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13466 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13467 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13468 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13469
13470 /* Input mixer control */
13471 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13472 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13473 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13474 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13475 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13476 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13478 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13479 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013481
Takashi Iwai22309c32006-08-09 16:57:28 +020013482 {
13483 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13484 .name = "Channel Mode",
13485 .info = alc_ch_mode_info,
13486 .get = alc_ch_mode_get,
13487 .put = alc_ch_mode_put,
13488 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13489 },
13490 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013491};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013492
13493static struct snd_kcontrol_new alc861_asus_mixer[] = {
13494 /* output mixer control */
13495 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13496 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13497 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13498 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13499 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13500
13501 /* Input mixer control */
13502 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13503 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13504 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13505 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13506 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13507 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13509 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13512
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013513 {
13514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13515 .name = "Channel Mode",
13516 .info = alc_ch_mode_info,
13517 .get = alc_ch_mode_get,
13518 .put = alc_ch_mode_put,
13519 .private_value = ARRAY_SIZE(alc861_asus_modes),
13520 },
13521 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013522};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013523
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013524/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013525static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013526 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13527 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013528 { }
13529};
13530
Kailang Yangdf694da2005-12-05 19:42:22 +010013531/*
13532 * generic initialization of ADC, input mixers and output mixers
13533 */
13534static struct hda_verb alc861_base_init_verbs[] = {
13535 /*
13536 * Unmute ADC0 and set the default input to mic-in
13537 */
13538 /* port-A for surround (rear panel) */
13539 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13540 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13541 /* port-B for mic-in (rear panel) with vref */
13542 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13543 /* port-C for line-in (rear panel) */
13544 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13545 /* port-D for Front */
13546 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13547 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13548 /* port-E for HP out (front panel) */
13549 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13550 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013551 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013552 /* port-F for mic-in (front panel) with vref */
13553 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13554 /* port-G for CLFE (rear panel) */
13555 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13556 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13557 /* port-H for side (rear panel) */
13558 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13559 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13560 /* CD-in */
13561 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13562 /* route front mic to ADC1*/
13563 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13564 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013565
Kailang Yangdf694da2005-12-05 19:42:22 +010013566 /* Unmute DAC0~3 & spdif out*/
13567 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13568 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13569 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13570 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013572
Kailang Yangdf694da2005-12-05 19:42:22 +010013573 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13574 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13575 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13576 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13577 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013578
Kailang Yangdf694da2005-12-05 19:42:22 +010013579 /* Unmute Stereo Mixer 15 */
13580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013583 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013584
13585 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13586 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13587 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13588 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13592 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013593 /* hp used DAC 3 (Front) */
13594 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13596
13597 { }
13598};
13599
13600static struct hda_verb alc861_threestack_init_verbs[] = {
13601 /*
13602 * Unmute ADC0 and set the default input to mic-in
13603 */
13604 /* port-A for surround (rear panel) */
13605 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13606 /* port-B for mic-in (rear panel) with vref */
13607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 /* port-C for line-in (rear panel) */
13609 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13610 /* port-D for Front */
13611 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13612 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13613 /* port-E for HP out (front panel) */
13614 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13615 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013616 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013617 /* port-F for mic-in (front panel) with vref */
13618 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13619 /* port-G for CLFE (rear panel) */
13620 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13621 /* port-H for side (rear panel) */
13622 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13623 /* CD-in */
13624 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13625 /* route front mic to ADC1*/
13626 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13628 /* Unmute DAC0~3 & spdif out*/
13629 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13630 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13631 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13632 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013634
Kailang Yangdf694da2005-12-05 19:42:22 +010013635 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13636 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13637 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13638 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13639 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013640
Kailang Yangdf694da2005-12-05 19:42:22 +010013641 /* Unmute Stereo Mixer 15 */
13642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013646
13647 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13648 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013655 /* hp used DAC 3 (Front) */
13656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13658 { }
13659};
Takashi Iwai22309c32006-08-09 16:57:28 +020013660
13661static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13662 /*
13663 * Unmute ADC0 and set the default input to mic-in
13664 */
13665 /* port-A for surround (rear panel) */
13666 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13667 /* port-B for mic-in (rear panel) with vref */
13668 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13669 /* port-C for line-in (rear panel) */
13670 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13671 /* port-D for Front */
13672 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13673 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13674 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013675 /* this has to be set to VREF80 */
13676 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013677 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013678 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013679 /* port-F for mic-in (front panel) with vref */
13680 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13681 /* port-G for CLFE (rear panel) */
13682 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13683 /* port-H for side (rear panel) */
13684 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13685 /* CD-in */
13686 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13687 /* route front mic to ADC1*/
13688 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13689 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13690 /* Unmute DAC0~3 & spdif out*/
13691 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13693 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13694 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013696
Takashi Iwai22309c32006-08-09 16:57:28 +020013697 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13698 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13699 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13700 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13701 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013702
Takashi Iwai22309c32006-08-09 16:57:28 +020013703 /* Unmute Stereo Mixer 15 */
13704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013708
13709 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13711 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13713 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13715 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013717 /* hp used DAC 3 (Front) */
13718 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13720 { }
13721};
13722
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013723static struct hda_verb alc861_asus_init_verbs[] = {
13724 /*
13725 * Unmute ADC0 and set the default input to mic-in
13726 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013727 /* port-A for surround (rear panel)
13728 * according to codec#0 this is the HP jack
13729 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013730 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13731 /* route front PCM to HP */
13732 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13733 /* port-B for mic-in (rear panel) with vref */
13734 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13735 /* port-C for line-in (rear panel) */
13736 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13737 /* port-D for Front */
13738 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13739 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13740 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013741 /* this has to be set to VREF80 */
13742 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013743 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013744 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013745 /* port-F for mic-in (front panel) with vref */
13746 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13747 /* port-G for CLFE (rear panel) */
13748 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13749 /* port-H for side (rear panel) */
13750 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13751 /* CD-in */
13752 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13753 /* route front mic to ADC1*/
13754 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13756 /* Unmute DAC0~3 & spdif out*/
13757 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13759 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13760 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13762 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13763 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13764 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13765 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13766 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013767
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013768 /* Unmute Stereo Mixer 15 */
13769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013773
13774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13776 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13778 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013782 /* hp used DAC 3 (Front) */
13783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13785 { }
13786};
13787
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013788/* additional init verbs for ASUS laptops */
13789static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13790 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13791 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13792 { }
13793};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013794
Kailang Yangdf694da2005-12-05 19:42:22 +010013795/*
13796 * generic initialization of ADC, input mixers and output mixers
13797 */
13798static struct hda_verb alc861_auto_init_verbs[] = {
13799 /*
13800 * Unmute ADC0 and set the default input to mic-in
13801 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013802 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013804
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 /* Unmute DAC0~3 & spdif out*/
13806 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13807 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13808 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13809 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13810 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013811
Kailang Yangdf694da2005-12-05 19:42:22 +010013812 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13813 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13814 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13815 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13816 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013817
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 /* Unmute Stereo Mixer 15 */
13819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13823
13824 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13826 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13827 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13828 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13830 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13832
13833 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13838 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013839 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013841
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013842 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013843
13844 { }
13845};
13846
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013847static struct hda_verb alc861_toshiba_init_verbs[] = {
13848 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013849
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013850 { }
13851};
13852
13853/* toggle speaker-output according to the hp-jack state */
13854static void alc861_toshiba_automute(struct hda_codec *codec)
13855{
13856 unsigned int present;
13857
13858 present = snd_hda_codec_read(codec, 0x0f, 0,
13859 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013860 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13861 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13862 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13863 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013864}
13865
13866static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13867 unsigned int res)
13868{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013869 if ((res >> 26) == ALC880_HP_EVENT)
13870 alc861_toshiba_automute(codec);
13871}
13872
Kailang Yangdf694da2005-12-05 19:42:22 +010013873/* pcm configuration: identiacal with ALC880 */
13874#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13875#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13876#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13877#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13878
13879
13880#define ALC861_DIGOUT_NID 0x07
13881
13882static struct hda_channel_mode alc861_8ch_modes[1] = {
13883 { 8, NULL }
13884};
13885
13886static hda_nid_t alc861_dac_nids[4] = {
13887 /* front, surround, clfe, side */
13888 0x03, 0x06, 0x05, 0x04
13889};
13890
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013891static hda_nid_t alc660_dac_nids[3] = {
13892 /* front, clfe, surround */
13893 0x03, 0x05, 0x06
13894};
13895
Kailang Yangdf694da2005-12-05 19:42:22 +010013896static hda_nid_t alc861_adc_nids[1] = {
13897 /* ADC0-2 */
13898 0x08,
13899};
13900
13901static struct hda_input_mux alc861_capture_source = {
13902 .num_items = 5,
13903 .items = {
13904 { "Mic", 0x0 },
13905 { "Front Mic", 0x3 },
13906 { "Line", 0x1 },
13907 { "CD", 0x4 },
13908 { "Mixer", 0x5 },
13909 },
13910};
13911
13912/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013913static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13914 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013915{
13916 int i;
13917 hda_nid_t nid;
13918
13919 spec->multiout.dac_nids = spec->private_dac_nids;
13920 for (i = 0; i < cfg->line_outs; i++) {
13921 nid = cfg->line_out_pins[i];
13922 if (nid) {
13923 if (i >= ARRAY_SIZE(alc861_dac_nids))
13924 continue;
13925 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13926 }
13927 }
13928 spec->multiout.num_dacs = cfg->line_outs;
13929 return 0;
13930}
13931
13932/* add playback controls from the parsed DAC table */
13933static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13934 const struct auto_pin_cfg *cfg)
13935{
13936 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013937 static const char *chname[4] = {
13938 "Front", "Surround", NULL /*CLFE*/, "Side"
13939 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013940 hda_nid_t nid;
13941 int i, idx, err;
13942
13943 for (i = 0; i < cfg->line_outs; i++) {
13944 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013945 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013946 continue;
13947 if (nid == 0x05) {
13948 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013949 err = add_control(spec, ALC_CTL_BIND_MUTE,
13950 "Center Playback Switch",
13951 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13952 HDA_OUTPUT));
13953 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013954 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013955 err = add_control(spec, ALC_CTL_BIND_MUTE,
13956 "LFE Playback Switch",
13957 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13958 HDA_OUTPUT));
13959 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013960 return err;
13961 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013962 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13963 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013964 if (nid == alc861_dac_nids[idx])
13965 break;
13966 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013967 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13968 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13969 HDA_OUTPUT));
13970 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013971 return err;
13972 }
13973 }
13974 return 0;
13975}
13976
13977static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13978{
13979 int err;
13980 hda_nid_t nid;
13981
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013982 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013983 return 0;
13984
13985 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13986 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013987 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13988 "Headphone Playback Switch",
13989 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13990 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013991 return err;
13992 spec->multiout.hp_nid = nid;
13993 }
13994 return 0;
13995}
13996
13997/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013998static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13999 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014000{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014001 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014002 int i, err, idx, idx1;
14003
14004 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014005 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014006 case 0x0c:
14007 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014008 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014009 break;
14010 case 0x0f:
14011 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014012 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014013 break;
14014 case 0x0d:
14015 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014016 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014017 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014018 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014019 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014020 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014021 break;
14022 case 0x11:
14023 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014024 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014025 break;
14026 default:
14027 continue;
14028 }
14029
Takashi Iwai4a471b72005-12-07 13:56:29 +010014030 err = new_analog_input(spec, cfg->input_pins[i],
14031 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014032 if (err < 0)
14033 return err;
14034
Takashi Iwai4a471b72005-12-07 13:56:29 +010014035 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014036 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014037 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014038 }
14039 return 0;
14040}
14041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014042static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14043 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014044 int pin_type, int dac_idx)
14045{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014046 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14047 pin_type);
14048 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14049 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014050}
14051
14052static void alc861_auto_init_multi_out(struct hda_codec *codec)
14053{
14054 struct alc_spec *spec = codec->spec;
14055 int i;
14056
14057 for (i = 0; i < spec->autocfg.line_outs; i++) {
14058 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014059 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014060 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014061 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014062 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014063 }
14064}
14065
14066static void alc861_auto_init_hp_out(struct hda_codec *codec)
14067{
14068 struct alc_spec *spec = codec->spec;
14069 hda_nid_t pin;
14070
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014071 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014072 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014073 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14074 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014075 pin = spec->autocfg.speaker_pins[0];
14076 if (pin)
14077 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014078}
14079
14080static void alc861_auto_init_analog_input(struct hda_codec *codec)
14081{
14082 struct alc_spec *spec = codec->spec;
14083 int i;
14084
14085 for (i = 0; i < AUTO_PIN_LAST; i++) {
14086 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014087 if (nid >= 0x0c && nid <= 0x11)
14088 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014089 }
14090}
14091
14092/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014093/* return 1 if successful, 0 if the proper config is not found,
14094 * or a negative error code
14095 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014096static int alc861_parse_auto_config(struct hda_codec *codec)
14097{
14098 struct alc_spec *spec = codec->spec;
14099 int err;
14100 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14101
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014102 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14103 alc861_ignore);
14104 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014105 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014106 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014107 return 0; /* can't find valid BIOS pin config */
14108
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14110 if (err < 0)
14111 return err;
14112 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14113 if (err < 0)
14114 return err;
14115 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14116 if (err < 0)
14117 return err;
14118 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14119 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014120 return err;
14121
14122 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14123
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014124 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014125 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14126
Takashi Iwai603c4012008-07-30 15:01:44 +020014127 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014128 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014129
Takashi Iwaid88897e2008-10-31 15:01:37 +010014130 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014131
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014132 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014133 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014134
14135 spec->adc_nids = alc861_adc_nids;
14136 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014137 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014138
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014139 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14140
Kailang Yangdf694da2005-12-05 19:42:22 +010014141 return 1;
14142}
14143
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014144/* additional initialization for auto-configuration model */
14145static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014146{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014147 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014148 alc861_auto_init_multi_out(codec);
14149 alc861_auto_init_hp_out(codec);
14150 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014151 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014152 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014153}
14154
Takashi Iwaicb53c622007-08-10 17:21:45 +020014155#ifdef CONFIG_SND_HDA_POWER_SAVE
14156static struct hda_amp_list alc861_loopbacks[] = {
14157 { 0x15, HDA_INPUT, 0 },
14158 { 0x15, HDA_INPUT, 1 },
14159 { 0x15, HDA_INPUT, 2 },
14160 { 0x15, HDA_INPUT, 3 },
14161 { } /* end */
14162};
14163#endif
14164
Kailang Yangdf694da2005-12-05 19:42:22 +010014165
14166/*
14167 * configuration and preset
14168 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014169static const char *alc861_models[ALC861_MODEL_LAST] = {
14170 [ALC861_3ST] = "3stack",
14171 [ALC660_3ST] = "3stack-660",
14172 [ALC861_3ST_DIG] = "3stack-dig",
14173 [ALC861_6ST_DIG] = "6stack-dig",
14174 [ALC861_UNIWILL_M31] = "uniwill-m31",
14175 [ALC861_TOSHIBA] = "toshiba",
14176 [ALC861_ASUS] = "asus",
14177 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14178 [ALC861_AUTO] = "auto",
14179};
14180
14181static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014182 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014183 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14184 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14185 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014186 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014187 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014189 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14190 * Any other models that need this preset?
14191 */
14192 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014193 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14194 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014195 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14196 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14197 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14198 /* FIXME: the below seems conflict */
14199 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14200 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14201 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014202 {}
14203};
14204
14205static struct alc_config_preset alc861_presets[] = {
14206 [ALC861_3ST] = {
14207 .mixers = { alc861_3ST_mixer },
14208 .init_verbs = { alc861_threestack_init_verbs },
14209 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14210 .dac_nids = alc861_dac_nids,
14211 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14212 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014213 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014214 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14215 .adc_nids = alc861_adc_nids,
14216 .input_mux = &alc861_capture_source,
14217 },
14218 [ALC861_3ST_DIG] = {
14219 .mixers = { alc861_base_mixer },
14220 .init_verbs = { alc861_threestack_init_verbs },
14221 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14222 .dac_nids = alc861_dac_nids,
14223 .dig_out_nid = ALC861_DIGOUT_NID,
14224 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14225 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014226 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014227 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14228 .adc_nids = alc861_adc_nids,
14229 .input_mux = &alc861_capture_source,
14230 },
14231 [ALC861_6ST_DIG] = {
14232 .mixers = { alc861_base_mixer },
14233 .init_verbs = { alc861_base_init_verbs },
14234 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14235 .dac_nids = alc861_dac_nids,
14236 .dig_out_nid = ALC861_DIGOUT_NID,
14237 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14238 .channel_mode = alc861_8ch_modes,
14239 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14240 .adc_nids = alc861_adc_nids,
14241 .input_mux = &alc861_capture_source,
14242 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014243 [ALC660_3ST] = {
14244 .mixers = { alc861_3ST_mixer },
14245 .init_verbs = { alc861_threestack_init_verbs },
14246 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14247 .dac_nids = alc660_dac_nids,
14248 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14249 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014250 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014251 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14252 .adc_nids = alc861_adc_nids,
14253 .input_mux = &alc861_capture_source,
14254 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014255 [ALC861_UNIWILL_M31] = {
14256 .mixers = { alc861_uniwill_m31_mixer },
14257 .init_verbs = { alc861_uniwill_m31_init_verbs },
14258 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14259 .dac_nids = alc861_dac_nids,
14260 .dig_out_nid = ALC861_DIGOUT_NID,
14261 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14262 .channel_mode = alc861_uniwill_m31_modes,
14263 .need_dac_fix = 1,
14264 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14265 .adc_nids = alc861_adc_nids,
14266 .input_mux = &alc861_capture_source,
14267 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014268 [ALC861_TOSHIBA] = {
14269 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014270 .init_verbs = { alc861_base_init_verbs,
14271 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014272 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14273 .dac_nids = alc861_dac_nids,
14274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14275 .channel_mode = alc883_3ST_2ch_modes,
14276 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14277 .adc_nids = alc861_adc_nids,
14278 .input_mux = &alc861_capture_source,
14279 .unsol_event = alc861_toshiba_unsol_event,
14280 .init_hook = alc861_toshiba_automute,
14281 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014282 [ALC861_ASUS] = {
14283 .mixers = { alc861_asus_mixer },
14284 .init_verbs = { alc861_asus_init_verbs },
14285 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14286 .dac_nids = alc861_dac_nids,
14287 .dig_out_nid = ALC861_DIGOUT_NID,
14288 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14289 .channel_mode = alc861_asus_modes,
14290 .need_dac_fix = 1,
14291 .hp_nid = 0x06,
14292 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14293 .adc_nids = alc861_adc_nids,
14294 .input_mux = &alc861_capture_source,
14295 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014296 [ALC861_ASUS_LAPTOP] = {
14297 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14298 .init_verbs = { alc861_asus_init_verbs,
14299 alc861_asus_laptop_init_verbs },
14300 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14301 .dac_nids = alc861_dac_nids,
14302 .dig_out_nid = ALC861_DIGOUT_NID,
14303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14304 .channel_mode = alc883_3ST_2ch_modes,
14305 .need_dac_fix = 1,
14306 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14307 .adc_nids = alc861_adc_nids,
14308 .input_mux = &alc861_capture_source,
14309 },
14310};
Kailang Yangdf694da2005-12-05 19:42:22 +010014311
14312
14313static int patch_alc861(struct hda_codec *codec)
14314{
14315 struct alc_spec *spec;
14316 int board_config;
14317 int err;
14318
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014319 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014320 if (spec == NULL)
14321 return -ENOMEM;
14322
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014323 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014324
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014325 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14326 alc861_models,
14327 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014328
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014329 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014330 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14331 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014332 board_config = ALC861_AUTO;
14333 }
14334
14335 if (board_config == ALC861_AUTO) {
14336 /* automatic parse from the BIOS config */
14337 err = alc861_parse_auto_config(codec);
14338 if (err < 0) {
14339 alc_free(codec);
14340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014341 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014342 printk(KERN_INFO
14343 "hda_codec: Cannot set up configuration "
14344 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014345 board_config = ALC861_3ST_DIG;
14346 }
14347 }
14348
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014349 err = snd_hda_attach_beep_device(codec, 0x23);
14350 if (err < 0) {
14351 alc_free(codec);
14352 return err;
14353 }
14354
Kailang Yangdf694da2005-12-05 19:42:22 +010014355 if (board_config != ALC861_AUTO)
14356 setup_preset(spec, &alc861_presets[board_config]);
14357
Kailang Yangdf694da2005-12-05 19:42:22 +010014358 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14359 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14360
Kailang Yangdf694da2005-12-05 19:42:22 +010014361 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14362 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14363
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014364 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14365
Takashi Iwai2134ea42008-01-10 16:53:55 +010014366 spec->vmaster_nid = 0x03;
14367
Kailang Yangdf694da2005-12-05 19:42:22 +010014368 codec->patch_ops = alc_patch_ops;
14369 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014370 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014371#ifdef CONFIG_SND_HDA_POWER_SAVE
14372 if (!spec->loopback.amplist)
14373 spec->loopback.amplist = alc861_loopbacks;
14374#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014375 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014376
Kailang Yangdf694da2005-12-05 19:42:22 +010014377 return 0;
14378}
14379
14380/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014381 * ALC861-VD support
14382 *
14383 * Based on ALC882
14384 *
14385 * In addition, an independent DAC
14386 */
14387#define ALC861VD_DIGOUT_NID 0x06
14388
14389static hda_nid_t alc861vd_dac_nids[4] = {
14390 /* front, surr, clfe, side surr */
14391 0x02, 0x03, 0x04, 0x05
14392};
14393
14394/* dac_nids for ALC660vd are in a different order - according to
14395 * Realtek's driver.
14396 * This should probably tesult in a different mixer for 6stack models
14397 * of ALC660vd codecs, but for now there is only 3stack mixer
14398 * - and it is the same as in 861vd.
14399 * adc_nids in ALC660vd are (is) the same as in 861vd
14400 */
14401static hda_nid_t alc660vd_dac_nids[3] = {
14402 /* front, rear, clfe, rear_surr */
14403 0x02, 0x04, 0x03
14404};
14405
14406static hda_nid_t alc861vd_adc_nids[1] = {
14407 /* ADC0 */
14408 0x09,
14409};
14410
Takashi Iwaie1406342008-02-11 18:32:32 +010014411static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14412
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014413/* input MUX */
14414/* FIXME: should be a matrix-type input source selection */
14415static struct hda_input_mux alc861vd_capture_source = {
14416 .num_items = 4,
14417 .items = {
14418 { "Mic", 0x0 },
14419 { "Front Mic", 0x1 },
14420 { "Line", 0x2 },
14421 { "CD", 0x4 },
14422 },
14423};
14424
Kailang Yang272a5272007-05-14 11:00:38 +020014425static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014426 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014427 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014428 { "Ext Mic", 0x0 },
14429 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014430 },
14431};
14432
Kailang Yangd1a991a2007-08-15 16:21:59 +020014433static struct hda_input_mux alc861vd_hp_capture_source = {
14434 .num_items = 2,
14435 .items = {
14436 { "Front Mic", 0x0 },
14437 { "ATAPI Mic", 0x1 },
14438 },
14439};
14440
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014441/*
14442 * 2ch mode
14443 */
14444static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14445 { 2, NULL }
14446};
14447
14448/*
14449 * 6ch mode
14450 */
14451static struct hda_verb alc861vd_6stack_ch6_init[] = {
14452 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14453 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14454 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14455 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14456 { } /* end */
14457};
14458
14459/*
14460 * 8ch mode
14461 */
14462static struct hda_verb alc861vd_6stack_ch8_init[] = {
14463 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14464 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14465 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14466 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14467 { } /* end */
14468};
14469
14470static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14471 { 6, alc861vd_6stack_ch6_init },
14472 { 8, alc861vd_6stack_ch8_init },
14473};
14474
14475static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14476 {
14477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14478 .name = "Channel Mode",
14479 .info = alc_ch_mode_info,
14480 .get = alc_ch_mode_get,
14481 .put = alc_ch_mode_put,
14482 },
14483 { } /* end */
14484};
14485
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014486/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14487 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14488 */
14489static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14490 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14491 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14492
14493 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14494 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14495
14496 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14497 HDA_OUTPUT),
14498 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14499 HDA_OUTPUT),
14500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14502
14503 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14504 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14505
14506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14507
14508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14511
14512 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14513 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14515
14516 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14517 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14518
14519 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14520 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14521
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014522 { } /* end */
14523};
14524
14525static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14526 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14527 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14528
14529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14530
14531 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14534
14535 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14536 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14538
14539 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14540 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14541
14542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14543 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14544
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014545 { } /* end */
14546};
14547
Kailang Yangbdd148a2007-05-08 15:19:08 +020014548static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14549 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14550 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14551 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14552
14553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14554
14555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14558
14559 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14562
14563 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14564 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14565
14566 { } /* end */
14567};
14568
Tobin Davisb419f342008-03-07 11:57:51 +010014569/* Pin assignment: Speaker=0x14, HP = 0x15,
14570 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014571 */
14572static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014573 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14574 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14576 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014577 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14578 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14579 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14580 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14581 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14582 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014583 { } /* end */
14584};
14585
Kailang Yangd1a991a2007-08-15 16:21:59 +020014586/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14587 * Front Mic=0x18, ATAPI Mic = 0x19,
14588 */
14589static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14590 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14591 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14593 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14594 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14595 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14596 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14597 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014598
Kailang Yangd1a991a2007-08-15 16:21:59 +020014599 { } /* end */
14600};
14601
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014602/*
14603 * generic initialization of ADC, input mixers and output mixers
14604 */
14605static struct hda_verb alc861vd_volume_init_verbs[] = {
14606 /*
14607 * Unmute ADC0 and set the default input to mic-in
14608 */
14609 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14611
14612 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14613 * the analog-loopback mixer widget
14614 */
14615 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014621
14622 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014627
14628 /*
14629 * Set up output mixers (0x02 - 0x05)
14630 */
14631 /* set vol=0 to output mixers */
14632 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14635 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14636
14637 /* set up input amps for analog loopback */
14638 /* Amp Indices: DAC = 0, mixer = 1 */
14639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14641 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14643 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14644 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14647
14648 { }
14649};
14650
14651/*
14652 * 3-stack pin configuration:
14653 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14654 */
14655static struct hda_verb alc861vd_3stack_init_verbs[] = {
14656 /*
14657 * Set pin mode and muting
14658 */
14659 /* set front pin widgets 0x14 for output */
14660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14662 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14663
14664 /* Mic (rear) pin: input vref at 80% */
14665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14667 /* Front Mic pin: input vref at 80% */
14668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14670 /* Line In pin: input */
14671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14673 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14676 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14677 /* CD pin widget for input */
14678 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14679
14680 { }
14681};
14682
14683/*
14684 * 6-stack pin configuration:
14685 */
14686static struct hda_verb alc861vd_6stack_init_verbs[] = {
14687 /*
14688 * Set pin mode and muting
14689 */
14690 /* set front pin widgets 0x14 for output */
14691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14693 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14694
14695 /* Rear Pin: output 1 (0x0d) */
14696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14698 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14699 /* CLFE Pin: output 2 (0x0e) */
14700 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14702 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14703 /* Side Pin: output 3 (0x0f) */
14704 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14706 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14707
14708 /* Mic (rear) pin: input vref at 80% */
14709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14711 /* Front Mic pin: input vref at 80% */
14712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14714 /* Line In pin: input */
14715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14716 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14717 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14719 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14720 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14721 /* CD pin widget for input */
14722 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14723
14724 { }
14725};
14726
Kailang Yangbdd148a2007-05-08 15:19:08 +020014727static struct hda_verb alc861vd_eapd_verbs[] = {
14728 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14729 { }
14730};
14731
Kailang Yangf9423e72008-05-27 12:32:25 +020014732static struct hda_verb alc660vd_eapd_verbs[] = {
14733 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14734 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14735 { }
14736};
14737
Kailang Yangbdd148a2007-05-08 15:19:08 +020014738static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14742 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014743 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014744 {}
14745};
14746
Kailang Yangbdd148a2007-05-08 15:19:08 +020014747static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14748{
14749 unsigned int present;
14750 unsigned char bits;
14751
14752 present = snd_hda_codec_read(codec, 0x18, 0,
14753 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014754 bits = present ? HDA_AMP_MUTE : 0;
14755 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14756 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014757}
14758
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014759static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014760{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014761 struct alc_spec *spec = codec->spec;
14762
14763 spec->autocfg.hp_pins[0] = 0x1b;
14764 spec->autocfg.speaker_pins[0] = 0x14;
14765 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014766 alc861vd_lenovo_mic_automute(codec);
14767}
14768
14769static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14770 unsigned int res)
14771{
14772 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014773 case ALC880_MIC_EVENT:
14774 alc861vd_lenovo_mic_automute(codec);
14775 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014776 default:
14777 alc_automute_amp_unsol_event(codec, res);
14778 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014779 }
14780}
14781
Kailang Yang272a5272007-05-14 11:00:38 +020014782static struct hda_verb alc861vd_dallas_verbs[] = {
14783 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14784 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14785 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14786 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14787
14788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14790 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14793 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014796
Kailang Yang272a5272007-05-14 11:00:38 +020014797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14803 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14804 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14805
14806 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14807 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14808 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14809 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14812 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14813 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14814
14815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14819
14820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014821 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014822 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14823
14824 { } /* end */
14825};
14826
14827/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014828static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014829{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014830 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014831
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014832 spec->autocfg.hp_pins[0] = 0x15;
14833 spec->autocfg.speaker_pins[0] = 0x14;
14834 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014835}
14836
Takashi Iwaicb53c622007-08-10 17:21:45 +020014837#ifdef CONFIG_SND_HDA_POWER_SAVE
14838#define alc861vd_loopbacks alc880_loopbacks
14839#endif
14840
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841/* pcm configuration: identiacal with ALC880 */
14842#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14843#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14844#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14845#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14846
14847/*
14848 * configuration and preset
14849 */
14850static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14851 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014852 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014853 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014854 [ALC861VD_3ST] = "3stack",
14855 [ALC861VD_3ST_DIG] = "3stack-digout",
14856 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014857 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014858 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014859 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014860 [ALC861VD_AUTO] = "auto",
14861};
14862
14863static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014864 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14865 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014866 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014867 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014868 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014869 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014870 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014871 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014872 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014873 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014874 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014875 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014876 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014877 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014878 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014879 {}
14880};
14881
14882static struct alc_config_preset alc861vd_presets[] = {
14883 [ALC660VD_3ST] = {
14884 .mixers = { alc861vd_3st_mixer },
14885 .init_verbs = { alc861vd_volume_init_verbs,
14886 alc861vd_3stack_init_verbs },
14887 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14888 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14890 .channel_mode = alc861vd_3stack_2ch_modes,
14891 .input_mux = &alc861vd_capture_source,
14892 },
Mike Crash6963f842007-06-25 12:12:51 +020014893 [ALC660VD_3ST_DIG] = {
14894 .mixers = { alc861vd_3st_mixer },
14895 .init_verbs = { alc861vd_volume_init_verbs,
14896 alc861vd_3stack_init_verbs },
14897 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14898 .dac_nids = alc660vd_dac_nids,
14899 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014900 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14901 .channel_mode = alc861vd_3stack_2ch_modes,
14902 .input_mux = &alc861vd_capture_source,
14903 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014904 [ALC861VD_3ST] = {
14905 .mixers = { alc861vd_3st_mixer },
14906 .init_verbs = { alc861vd_volume_init_verbs,
14907 alc861vd_3stack_init_verbs },
14908 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14909 .dac_nids = alc861vd_dac_nids,
14910 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14911 .channel_mode = alc861vd_3stack_2ch_modes,
14912 .input_mux = &alc861vd_capture_source,
14913 },
14914 [ALC861VD_3ST_DIG] = {
14915 .mixers = { alc861vd_3st_mixer },
14916 .init_verbs = { alc861vd_volume_init_verbs,
14917 alc861vd_3stack_init_verbs },
14918 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14919 .dac_nids = alc861vd_dac_nids,
14920 .dig_out_nid = ALC861VD_DIGOUT_NID,
14921 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14922 .channel_mode = alc861vd_3stack_2ch_modes,
14923 .input_mux = &alc861vd_capture_source,
14924 },
14925 [ALC861VD_6ST_DIG] = {
14926 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14927 .init_verbs = { alc861vd_volume_init_verbs,
14928 alc861vd_6stack_init_verbs },
14929 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14930 .dac_nids = alc861vd_dac_nids,
14931 .dig_out_nid = ALC861VD_DIGOUT_NID,
14932 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14933 .channel_mode = alc861vd_6stack_modes,
14934 .input_mux = &alc861vd_capture_source,
14935 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014936 [ALC861VD_LENOVO] = {
14937 .mixers = { alc861vd_lenovo_mixer },
14938 .init_verbs = { alc861vd_volume_init_verbs,
14939 alc861vd_3stack_init_verbs,
14940 alc861vd_eapd_verbs,
14941 alc861vd_lenovo_unsol_verbs },
14942 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14943 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014944 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14945 .channel_mode = alc861vd_3stack_2ch_modes,
14946 .input_mux = &alc861vd_capture_source,
14947 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014948 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014949 },
Kailang Yang272a5272007-05-14 11:00:38 +020014950 [ALC861VD_DALLAS] = {
14951 .mixers = { alc861vd_dallas_mixer },
14952 .init_verbs = { alc861vd_dallas_verbs },
14953 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14954 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014955 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14956 .channel_mode = alc861vd_3stack_2ch_modes,
14957 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014958 .unsol_event = alc_automute_amp_unsol_event,
14959 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014960 },
14961 [ALC861VD_HP] = {
14962 .mixers = { alc861vd_hp_mixer },
14963 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14964 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14965 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014966 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014967 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14968 .channel_mode = alc861vd_3stack_2ch_modes,
14969 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014970 .unsol_event = alc_automute_amp_unsol_event,
14971 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014972 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014973 [ALC660VD_ASUS_V1S] = {
14974 .mixers = { alc861vd_lenovo_mixer },
14975 .init_verbs = { alc861vd_volume_init_verbs,
14976 alc861vd_3stack_init_verbs,
14977 alc861vd_eapd_verbs,
14978 alc861vd_lenovo_unsol_verbs },
14979 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14980 .dac_nids = alc660vd_dac_nids,
14981 .dig_out_nid = ALC861VD_DIGOUT_NID,
14982 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14983 .channel_mode = alc861vd_3stack_2ch_modes,
14984 .input_mux = &alc861vd_capture_source,
14985 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014986 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014987 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014988};
14989
14990/*
14991 * BIOS auto configuration
14992 */
14993static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14994 hda_nid_t nid, int pin_type, int dac_idx)
14995{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014996 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014997}
14998
14999static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15000{
15001 struct alc_spec *spec = codec->spec;
15002 int i;
15003
15004 for (i = 0; i <= HDA_SIDE; i++) {
15005 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015006 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015007 if (nid)
15008 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015009 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015010 }
15011}
15012
15013
15014static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15015{
15016 struct alc_spec *spec = codec->spec;
15017 hda_nid_t pin;
15018
15019 pin = spec->autocfg.hp_pins[0];
15020 if (pin) /* connect to front and use dac 0 */
15021 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015022 pin = spec->autocfg.speaker_pins[0];
15023 if (pin)
15024 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015025}
15026
15027#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15028#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15029
15030static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15031{
15032 struct alc_spec *spec = codec->spec;
15033 int i;
15034
15035 for (i = 0; i < AUTO_PIN_LAST; i++) {
15036 hda_nid_t nid = spec->autocfg.input_pins[i];
15037 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015038 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015039 if (nid != ALC861VD_PIN_CD_NID &&
15040 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015041 snd_hda_codec_write(codec, nid, 0,
15042 AC_VERB_SET_AMP_GAIN_MUTE,
15043 AMP_OUT_MUTE);
15044 }
15045 }
15046}
15047
Takashi Iwaif511b012008-08-15 16:46:42 +020015048#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15049
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15051#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15052
15053/* add playback controls from the parsed DAC table */
15054/* Based on ALC880 version. But ALC861VD has separate,
15055 * different NIDs for mute/unmute switch and volume control */
15056static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15057 const struct auto_pin_cfg *cfg)
15058{
15059 char name[32];
15060 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15061 hda_nid_t nid_v, nid_s;
15062 int i, err;
15063
15064 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015065 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015066 continue;
15067 nid_v = alc861vd_idx_to_mixer_vol(
15068 alc880_dac_to_idx(
15069 spec->multiout.dac_nids[i]));
15070 nid_s = alc861vd_idx_to_mixer_switch(
15071 alc880_dac_to_idx(
15072 spec->multiout.dac_nids[i]));
15073
15074 if (i == 2) {
15075 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015076 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15077 "Center Playback Volume",
15078 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15079 HDA_OUTPUT));
15080 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015081 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015082 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15083 "LFE Playback Volume",
15084 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15085 HDA_OUTPUT));
15086 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015087 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015088 err = add_control(spec, ALC_CTL_BIND_MUTE,
15089 "Center Playback Switch",
15090 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15091 HDA_INPUT));
15092 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015093 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015094 err = add_control(spec, ALC_CTL_BIND_MUTE,
15095 "LFE Playback Switch",
15096 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15097 HDA_INPUT));
15098 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015099 return err;
15100 } else {
15101 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015102 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15103 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15104 HDA_OUTPUT));
15105 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015106 return err;
15107 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015108 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015109 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015110 HDA_INPUT));
15111 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015112 return err;
15113 }
15114 }
15115 return 0;
15116}
15117
15118/* add playback controls for speaker and HP outputs */
15119/* Based on ALC880 version. But ALC861VD has separate,
15120 * different NIDs for mute/unmute switch and volume control */
15121static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15122 hda_nid_t pin, const char *pfx)
15123{
15124 hda_nid_t nid_v, nid_s;
15125 int err;
15126 char name[32];
15127
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015128 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 return 0;
15130
15131 if (alc880_is_fixed_pin(pin)) {
15132 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15133 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015134 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015135 spec->multiout.hp_nid = nid_v;
15136 else
15137 spec->multiout.extra_out_nid[0] = nid_v;
15138 /* control HP volume/switch on the output mixer amp */
15139 nid_v = alc861vd_idx_to_mixer_vol(
15140 alc880_fixed_pin_idx(pin));
15141 nid_s = alc861vd_idx_to_mixer_switch(
15142 alc880_fixed_pin_idx(pin));
15143
15144 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015145 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15146 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15147 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 return err;
15149 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015150 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15151 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15152 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015153 return err;
15154 } else if (alc880_is_multi_pin(pin)) {
15155 /* set manual connection */
15156 /* we have only a switch on HP-out PIN */
15157 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015158 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15159 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15160 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161 return err;
15162 }
15163 return 0;
15164}
15165
15166/* parse the BIOS configuration and set up the alc_spec
15167 * return 1 if successful, 0 if the proper config is not found,
15168 * or a negative error code
15169 * Based on ALC880 version - had to change it to override
15170 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15171static int alc861vd_parse_auto_config(struct hda_codec *codec)
15172{
15173 struct alc_spec *spec = codec->spec;
15174 int err;
15175 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15176
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15178 alc861vd_ignore);
15179 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015180 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015181 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015182 return 0; /* can't find valid BIOS pin config */
15183
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015184 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15185 if (err < 0)
15186 return err;
15187 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15188 if (err < 0)
15189 return err;
15190 err = alc861vd_auto_create_extra_out(spec,
15191 spec->autocfg.speaker_pins[0],
15192 "Speaker");
15193 if (err < 0)
15194 return err;
15195 err = alc861vd_auto_create_extra_out(spec,
15196 spec->autocfg.hp_pins[0],
15197 "Headphone");
15198 if (err < 0)
15199 return err;
15200 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15201 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015202 return err;
15203
15204 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15205
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015206 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015207 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15208
Takashi Iwai603c4012008-07-30 15:01:44 +020015209 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015210 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015211
Takashi Iwaid88897e2008-10-31 15:01:37 +010015212 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015213
15214 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015215 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015216
Takashi Iwai776e1842007-08-29 15:07:11 +020015217 err = alc_auto_add_mic_boost(codec);
15218 if (err < 0)
15219 return err;
15220
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015221 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15222
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015223 return 1;
15224}
15225
15226/* additional initialization for auto-configuration model */
15227static void alc861vd_auto_init(struct hda_codec *codec)
15228{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015229 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015230 alc861vd_auto_init_multi_out(codec);
15231 alc861vd_auto_init_hp_out(codec);
15232 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015233 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015234 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015235 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015236}
15237
15238static int patch_alc861vd(struct hda_codec *codec)
15239{
15240 struct alc_spec *spec;
15241 int err, board_config;
15242
15243 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15244 if (spec == NULL)
15245 return -ENOMEM;
15246
15247 codec->spec = spec;
15248
15249 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15250 alc861vd_models,
15251 alc861vd_cfg_tbl);
15252
15253 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015254 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15255 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015256 board_config = ALC861VD_AUTO;
15257 }
15258
15259 if (board_config == ALC861VD_AUTO) {
15260 /* automatic parse from the BIOS config */
15261 err = alc861vd_parse_auto_config(codec);
15262 if (err < 0) {
15263 alc_free(codec);
15264 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015265 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015266 printk(KERN_INFO
15267 "hda_codec: Cannot set up configuration "
15268 "from BIOS. Using base mode...\n");
15269 board_config = ALC861VD_3ST;
15270 }
15271 }
15272
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015273 err = snd_hda_attach_beep_device(codec, 0x23);
15274 if (err < 0) {
15275 alc_free(codec);
15276 return err;
15277 }
15278
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279 if (board_config != ALC861VD_AUTO)
15280 setup_preset(spec, &alc861vd_presets[board_config]);
15281
Kailang Yang2f893282008-05-27 12:14:47 +020015282 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015283 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015284 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015285 }
15286
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015287 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15288 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15289
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015290 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15291 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15292
15293 spec->adc_nids = alc861vd_adc_nids;
15294 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015295 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015296 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015298 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015299 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015300
Takashi Iwai2134ea42008-01-10 16:53:55 +010015301 spec->vmaster_nid = 0x02;
15302
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 codec->patch_ops = alc_patch_ops;
15304
15305 if (board_config == ALC861VD_AUTO)
15306 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015307#ifdef CONFIG_SND_HDA_POWER_SAVE
15308 if (!spec->loopback.amplist)
15309 spec->loopback.amplist = alc861vd_loopbacks;
15310#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015311 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015312
15313 return 0;
15314}
15315
15316/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015317 * ALC662 support
15318 *
15319 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15320 * configuration. Each pin widget can choose any input DACs and a mixer.
15321 * Each ADC is connected from a mixer of all inputs. This makes possible
15322 * 6-channel independent captures.
15323 *
15324 * In addition, an independent DAC for the multi-playback (not used in this
15325 * driver yet).
15326 */
15327#define ALC662_DIGOUT_NID 0x06
15328#define ALC662_DIGIN_NID 0x0a
15329
15330static hda_nid_t alc662_dac_nids[4] = {
15331 /* front, rear, clfe, rear_surr */
15332 0x02, 0x03, 0x04
15333};
15334
Kailang Yang622e84c2009-04-21 07:39:04 +020015335static hda_nid_t alc272_dac_nids[2] = {
15336 0x02, 0x03
15337};
15338
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015339static hda_nid_t alc662_adc_nids[1] = {
15340 /* ADC1-2 */
15341 0x09,
15342};
Takashi Iwaie1406342008-02-11 18:32:32 +010015343
Kailang Yang622e84c2009-04-21 07:39:04 +020015344static hda_nid_t alc272_adc_nids[1] = {
15345 /* ADC1-2 */
15346 0x08,
15347};
15348
Kailang Yang77a261b2008-02-19 11:38:05 +010015349static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015350static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15351
Takashi Iwaie1406342008-02-11 18:32:32 +010015352
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015353/* input MUX */
15354/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015355static struct hda_input_mux alc662_capture_source = {
15356 .num_items = 4,
15357 .items = {
15358 { "Mic", 0x0 },
15359 { "Front Mic", 0x1 },
15360 { "Line", 0x2 },
15361 { "CD", 0x4 },
15362 },
15363};
15364
15365static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15366 .num_items = 2,
15367 .items = {
15368 { "Mic", 0x1 },
15369 { "Line", 0x2 },
15370 },
15371};
Kailang Yang291702f2007-10-16 14:28:03 +020015372
15373static struct hda_input_mux alc662_eeepc_capture_source = {
15374 .num_items = 2,
15375 .items = {
15376 { "i-Mic", 0x1 },
15377 { "e-Mic", 0x0 },
15378 },
15379};
15380
Kailang Yang6dda9f42008-05-27 12:05:31 +020015381static struct hda_input_mux alc663_capture_source = {
15382 .num_items = 3,
15383 .items = {
15384 { "Mic", 0x0 },
15385 { "Front Mic", 0x1 },
15386 { "Line", 0x2 },
15387 },
15388};
15389
15390static struct hda_input_mux alc663_m51va_capture_source = {
15391 .num_items = 2,
15392 .items = {
15393 { "Ext-Mic", 0x0 },
15394 { "D-Mic", 0x9 },
15395 },
15396};
15397
Chris Pockelé9541ba12009-05-12 08:08:53 +020015398#if 1 /* set to 0 for testing other input sources below */
15399static struct hda_input_mux alc272_nc10_capture_source = {
15400 .num_items = 2,
15401 .items = {
15402 { "Autoselect Mic", 0x0 },
15403 { "Internal Mic", 0x1 },
15404 },
15405};
15406#else
15407static struct hda_input_mux alc272_nc10_capture_source = {
15408 .num_items = 16,
15409 .items = {
15410 { "Autoselect Mic", 0x0 },
15411 { "Internal Mic", 0x1 },
15412 { "In-0x02", 0x2 },
15413 { "In-0x03", 0x3 },
15414 { "In-0x04", 0x4 },
15415 { "In-0x05", 0x5 },
15416 { "In-0x06", 0x6 },
15417 { "In-0x07", 0x7 },
15418 { "In-0x08", 0x8 },
15419 { "In-0x09", 0x9 },
15420 { "In-0x0a", 0x0a },
15421 { "In-0x0b", 0x0b },
15422 { "In-0x0c", 0x0c },
15423 { "In-0x0d", 0x0d },
15424 { "In-0x0e", 0x0e },
15425 { "In-0x0f", 0x0f },
15426 },
15427};
15428#endif
15429
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015430/*
15431 * 2ch mode
15432 */
15433static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15434 { 2, NULL }
15435};
15436
15437/*
15438 * 2ch mode
15439 */
15440static struct hda_verb alc662_3ST_ch2_init[] = {
15441 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15442 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15445 { } /* end */
15446};
15447
15448/*
15449 * 6ch mode
15450 */
15451static struct hda_verb alc662_3ST_ch6_init[] = {
15452 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15453 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15454 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15455 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15456 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15457 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15458 { } /* end */
15459};
15460
15461static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15462 { 2, alc662_3ST_ch2_init },
15463 { 6, alc662_3ST_ch6_init },
15464};
15465
15466/*
15467 * 2ch mode
15468 */
15469static struct hda_verb alc662_sixstack_ch6_init[] = {
15470 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15471 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15472 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15473 { } /* end */
15474};
15475
15476/*
15477 * 6ch mode
15478 */
15479static struct hda_verb alc662_sixstack_ch8_init[] = {
15480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15483 { } /* end */
15484};
15485
15486static struct hda_channel_mode alc662_5stack_modes[2] = {
15487 { 2, alc662_sixstack_ch6_init },
15488 { 6, alc662_sixstack_ch8_init },
15489};
15490
15491/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15492 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15493 */
15494
15495static struct snd_kcontrol_new alc662_base_mixer[] = {
15496 /* output mixer control */
15497 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015498 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015499 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015500 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015501 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15502 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015503 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15504 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15506
15507 /*Input mixer control */
15508 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15509 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15511 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15512 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15513 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15514 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15515 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015516 { } /* end */
15517};
15518
15519static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15520 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015521 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15525 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15526 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15527 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15528 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15529 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015531 { } /* end */
15532};
15533
15534static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15535 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015536 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015537 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015538 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015539 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15540 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015541 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15542 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15544 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15545 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15546 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15547 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15550 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015552 { } /* end */
15553};
15554
15555static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15556 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15557 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015558 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15559 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015565 { } /* end */
15566};
15567
Kailang Yang291702f2007-10-16 14:28:03 +020015568static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015569 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15570 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015571
15572 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15573 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15574 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15575
15576 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15577 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15578 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15579 { } /* end */
15580};
15581
Kailang Yang8c427222008-01-10 13:03:59 +010015582static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015583 ALC262_HIPPO_MASTER_SWITCH,
15584 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015585 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015586 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15587 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015588 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15593 { } /* end */
15594};
15595
Kailang Yangf1d4e282008-08-26 14:03:29 +020015596static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15597 .ops = &snd_hda_bind_vol,
15598 .values = {
15599 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15600 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15601 0
15602 },
15603};
15604
15605static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15606 .ops = &snd_hda_bind_sw,
15607 .values = {
15608 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15609 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15610 0
15611 },
15612};
15613
Kailang Yang6dda9f42008-05-27 12:05:31 +020015614static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015615 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15616 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15619 { } /* end */
15620};
15621
15622static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15623 .ops = &snd_hda_bind_sw,
15624 .values = {
15625 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15626 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15627 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15628 0
15629 },
15630};
15631
15632static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15633 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15634 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15637 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15638 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15639
15640 { } /* end */
15641};
15642
15643static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15644 .ops = &snd_hda_bind_sw,
15645 .values = {
15646 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15647 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15648 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15649 0
15650 },
15651};
15652
15653static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15654 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15655 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15658 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15659 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15660 { } /* end */
15661};
15662
15663static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015664 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15665 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15669 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15670 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15671 { } /* end */
15672};
15673
15674static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15675 .ops = &snd_hda_bind_vol,
15676 .values = {
15677 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15678 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15679 0
15680 },
15681};
15682
15683static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15684 .ops = &snd_hda_bind_sw,
15685 .values = {
15686 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15687 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15688 0
15689 },
15690};
15691
15692static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15693 HDA_BIND_VOL("Master Playback Volume",
15694 &alc663_asus_two_bind_master_vol),
15695 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015700 { } /* end */
15701};
15702
15703static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15704 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15705 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015710 { } /* end */
15711};
15712
15713static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15714 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15715 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15716 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15717 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15719
15720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15722 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15723 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15724 { } /* end */
15725};
15726
15727static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15729 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15731
15732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15734 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15735 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15738 { } /* end */
15739};
15740
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015741static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15742 {
15743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15744 .name = "Channel Mode",
15745 .info = alc_ch_mode_info,
15746 .get = alc_ch_mode_get,
15747 .put = alc_ch_mode_put,
15748 },
15749 { } /* end */
15750};
15751
15752static struct hda_verb alc662_init_verbs[] = {
15753 /* ADC: mute amp left and right */
15754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15755 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15756 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15757
Takashi Iwaicb53c622007-08-10 17:21:45 +020015758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015763
Kailang Yangb60dd392007-09-20 12:50:29 +020015764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015770
15771 /* Front Pin: output 0 (0x0c) */
15772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15774
15775 /* Rear Pin: output 1 (0x0d) */
15776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15778
15779 /* CLFE Pin: output 2 (0x0e) */
15780 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15781 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15782
15783 /* Mic (rear) pin: input vref at 80% */
15784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15785 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15786 /* Front Mic pin: input vref at 80% */
15787 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15789 /* Line In pin: input */
15790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15792 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15793 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15794 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15795 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15796 /* CD pin widget for input */
15797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15798
15799 /* FIXME: use matrix-type input source selection */
15800 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15801 /* Input mixer */
15802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015804
15805 /* always trun on EAPD */
15806 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15807 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15808
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015809 { }
15810};
15811
15812static struct hda_verb alc662_sue_init_verbs[] = {
15813 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15814 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015815 {}
15816};
15817
15818static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15820 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15821 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015822};
15823
Kailang Yang8c427222008-01-10 13:03:59 +010015824/* Set Unsolicited Event*/
15825static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15826 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15827 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15828 {}
15829};
15830
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015831/*
15832 * generic initialization of ADC, input mixers and output mixers
15833 */
15834static struct hda_verb alc662_auto_init_verbs[] = {
15835 /*
15836 * Unmute ADC and set the default input to mic-in
15837 */
15838 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15839 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15840
15841 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15842 * mixer widget
15843 * Note: PASD motherboards uses the Line In 2 as the input for front
15844 * panel mic (mic 2)
15845 */
15846 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015852
15853 /*
15854 * Set up output mixers (0x0c - 0x0f)
15855 */
15856 /* set vol=0 to output mixers */
15857 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15858 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15859 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15860
15861 /* set up input amps for analog loopback */
15862 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015869
15870
15871 /* FIXME: use matrix-type input source selection */
15872 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15873 /* Input mixer */
15874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015876 { }
15877};
15878
Takashi Iwai24fb9172008-09-02 14:48:20 +020015879/* additional verbs for ALC663 */
15880static struct hda_verb alc663_auto_init_verbs[] = {
15881 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15883 { }
15884};
15885
Kailang Yang6dda9f42008-05-27 12:05:31 +020015886static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15888 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015889 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15890 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015891 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015894 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15895 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15896 {}
15897};
15898
Kailang Yangf1d4e282008-08-26 14:03:29 +020015899static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15900 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15901 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15902 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15905 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15906 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15907 {}
15908};
15909
15910static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15913 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15914 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15917 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15919 {}
15920};
15921
15922static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15930 {}
15931};
15932
15933static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15935 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15936 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15937 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15943 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15944 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15945 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15946 {}
15947};
15948
15949static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15950 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15953 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15959 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15960 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15961 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15962 {}
15963};
15964
Kailang Yang6dda9f42008-05-27 12:05:31 +020015965static struct hda_verb alc663_g71v_init_verbs[] = {
15966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15967 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15968 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15969
15970 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15971 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15972 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15973
15974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15975 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15976 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15977 {}
15978};
15979
15980static struct hda_verb alc663_g50v_init_verbs[] = {
15981 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15982 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15983 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15984
15985 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15986 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15987 {}
15988};
15989
Kailang Yangf1d4e282008-08-26 14:03:29 +020015990static struct hda_verb alc662_ecs_init_verbs[] = {
15991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15993 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15994 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15995 {}
15996};
15997
Kailang Yang622e84c2009-04-21 07:39:04 +020015998static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15999 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16000 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16001 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16002 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16003 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16004 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16005 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16008 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16009 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16010 {}
16011};
16012
16013static struct hda_verb alc272_dell_init_verbs[] = {
16014 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16015 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16017 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16018 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16019 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16020 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16021 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16022 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16023 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16024 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16025 {}
16026};
16027
Kailang Yangf1d4e282008-08-26 14:03:29 +020016028static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16029 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16030 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16031 { } /* end */
16032};
16033
Kailang Yang622e84c2009-04-21 07:39:04 +020016034static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16035 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16036 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16037 { } /* end */
16038};
16039
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016040static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16041{
16042 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016043 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044
16045 present = snd_hda_codec_read(codec, 0x14, 0,
16046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016047 bits = present ? HDA_AMP_MUTE : 0;
16048 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16049 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016050}
16051
16052static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16053{
16054 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016055 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016056
16057 present = snd_hda_codec_read(codec, 0x1b, 0,
16058 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016059 bits = present ? HDA_AMP_MUTE : 0;
16060 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16061 HDA_AMP_MUTE, bits);
16062 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16063 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016064}
16065
16066static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16067 unsigned int res)
16068{
16069 if ((res >> 26) == ALC880_HP_EVENT)
16070 alc662_lenovo_101e_all_automute(codec);
16071 if ((res >> 26) == ALC880_FRONT_EVENT)
16072 alc662_lenovo_101e_ispeaker_automute(codec);
16073}
16074
Kailang Yang291702f2007-10-16 14:28:03 +020016075static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16076{
16077 unsigned int present;
16078
16079 present = snd_hda_codec_read(codec, 0x18, 0,
16080 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16081 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16082 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16083 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16084 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16085 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16086 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16087 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16088 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16089}
16090
16091/* unsolicited event for HP jack sensing */
16092static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16093 unsigned int res)
16094{
Kailang Yang291702f2007-10-16 14:28:03 +020016095 if ((res >> 26) == ALC880_MIC_EVENT)
16096 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016097 else
16098 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016099}
16100
16101static void alc662_eeepc_inithook(struct hda_codec *codec)
16102{
Takashi Iwai42171c12009-05-08 14:11:43 +020016103 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016104 alc662_eeepc_mic_automute(codec);
16105}
16106
Kailang Yang8c427222008-01-10 13:03:59 +010016107static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16108{
Takashi Iwai42171c12009-05-08 14:11:43 +020016109 struct alc_spec *spec = codec->spec;
16110
16111 spec->autocfg.hp_pins[0] = 0x14;
16112 spec->autocfg.speaker_pins[0] = 0x1b;
16113 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016114}
16115
Kailang Yang6dda9f42008-05-27 12:05:31 +020016116static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16117{
16118 unsigned int present;
16119 unsigned char bits;
16120
16121 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016122 AC_VERB_GET_PIN_SENSE, 0)
16123 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016124 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016125 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16126 AMP_IN_MUTE(0), bits);
16127 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16128 AMP_IN_MUTE(0), bits);
16129}
16130
16131static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16132{
16133 unsigned int present;
16134 unsigned char bits;
16135
16136 present = snd_hda_codec_read(codec, 0x21, 0,
16137 AC_VERB_GET_PIN_SENSE, 0)
16138 & AC_PINSENSE_PRESENCE;
16139 bits = present ? HDA_AMP_MUTE : 0;
16140 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16141 AMP_IN_MUTE(0), bits);
16142 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16143 AMP_IN_MUTE(0), bits);
16144 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16145 AMP_IN_MUTE(0), bits);
16146 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16147 AMP_IN_MUTE(0), bits);
16148}
16149
16150static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16151{
16152 unsigned int present;
16153 unsigned char bits;
16154
16155 present = snd_hda_codec_read(codec, 0x15, 0,
16156 AC_VERB_GET_PIN_SENSE, 0)
16157 & AC_PINSENSE_PRESENCE;
16158 bits = present ? HDA_AMP_MUTE : 0;
16159 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16160 AMP_IN_MUTE(0), bits);
16161 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16162 AMP_IN_MUTE(0), bits);
16163 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16164 AMP_IN_MUTE(0), bits);
16165 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16166 AMP_IN_MUTE(0), bits);
16167}
16168
16169static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16170{
16171 unsigned int present;
16172 unsigned char bits;
16173
16174 present = snd_hda_codec_read(codec, 0x1b, 0,
16175 AC_VERB_GET_PIN_SENSE, 0)
16176 & AC_PINSENSE_PRESENCE;
16177 bits = present ? 0 : PIN_OUT;
16178 snd_hda_codec_write(codec, 0x14, 0,
16179 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16180}
16181
16182static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16183{
16184 unsigned int present1, present2;
16185
16186 present1 = snd_hda_codec_read(codec, 0x21, 0,
16187 AC_VERB_GET_PIN_SENSE, 0)
16188 & AC_PINSENSE_PRESENCE;
16189 present2 = snd_hda_codec_read(codec, 0x15, 0,
16190 AC_VERB_GET_PIN_SENSE, 0)
16191 & AC_PINSENSE_PRESENCE;
16192
16193 if (present1 || present2) {
16194 snd_hda_codec_write_cache(codec, 0x14, 0,
16195 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16196 } else {
16197 snd_hda_codec_write_cache(codec, 0x14, 0,
16198 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16199 }
16200}
16201
16202static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16203{
16204 unsigned int present1, present2;
16205
16206 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16207 AC_VERB_GET_PIN_SENSE, 0)
16208 & AC_PINSENSE_PRESENCE;
16209 present2 = snd_hda_codec_read(codec, 0x15, 0,
16210 AC_VERB_GET_PIN_SENSE, 0)
16211 & AC_PINSENSE_PRESENCE;
16212
16213 if (present1 || present2) {
16214 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16215 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16216 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16217 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16218 } else {
16219 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16220 AMP_IN_MUTE(0), 0);
16221 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16222 AMP_IN_MUTE(0), 0);
16223 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016224}
16225
16226static void alc663_m51va_mic_automute(struct hda_codec *codec)
16227{
16228 unsigned int present;
16229
16230 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016231 AC_VERB_GET_PIN_SENSE, 0)
16232 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016233 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016234 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016235 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016236 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016237 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016238 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016239 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016240 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016241}
16242
16243static void alc663_m51va_unsol_event(struct hda_codec *codec,
16244 unsigned int res)
16245{
16246 switch (res >> 26) {
16247 case ALC880_HP_EVENT:
16248 alc663_m51va_speaker_automute(codec);
16249 break;
16250 case ALC880_MIC_EVENT:
16251 alc663_m51va_mic_automute(codec);
16252 break;
16253 }
16254}
16255
16256static void alc663_m51va_inithook(struct hda_codec *codec)
16257{
16258 alc663_m51va_speaker_automute(codec);
16259 alc663_m51va_mic_automute(codec);
16260}
16261
Kailang Yangf1d4e282008-08-26 14:03:29 +020016262/* ***************** Mode1 ******************************/
16263static void alc663_mode1_unsol_event(struct hda_codec *codec,
16264 unsigned int res)
16265{
16266 switch (res >> 26) {
16267 case ALC880_HP_EVENT:
16268 alc663_m51va_speaker_automute(codec);
16269 break;
16270 case ALC880_MIC_EVENT:
16271 alc662_eeepc_mic_automute(codec);
16272 break;
16273 }
16274}
16275
16276static void alc663_mode1_inithook(struct hda_codec *codec)
16277{
16278 alc663_m51va_speaker_automute(codec);
16279 alc662_eeepc_mic_automute(codec);
16280}
16281/* ***************** Mode2 ******************************/
16282static void alc662_mode2_unsol_event(struct hda_codec *codec,
16283 unsigned int res)
16284{
16285 switch (res >> 26) {
16286 case ALC880_HP_EVENT:
16287 alc662_f5z_speaker_automute(codec);
16288 break;
16289 case ALC880_MIC_EVENT:
16290 alc662_eeepc_mic_automute(codec);
16291 break;
16292 }
16293}
16294
16295static void alc662_mode2_inithook(struct hda_codec *codec)
16296{
16297 alc662_f5z_speaker_automute(codec);
16298 alc662_eeepc_mic_automute(codec);
16299}
16300/* ***************** Mode3 ******************************/
16301static void alc663_mode3_unsol_event(struct hda_codec *codec,
16302 unsigned int res)
16303{
16304 switch (res >> 26) {
16305 case ALC880_HP_EVENT:
16306 alc663_two_hp_m1_speaker_automute(codec);
16307 break;
16308 case ALC880_MIC_EVENT:
16309 alc662_eeepc_mic_automute(codec);
16310 break;
16311 }
16312}
16313
16314static void alc663_mode3_inithook(struct hda_codec *codec)
16315{
16316 alc663_two_hp_m1_speaker_automute(codec);
16317 alc662_eeepc_mic_automute(codec);
16318}
16319/* ***************** Mode4 ******************************/
16320static void alc663_mode4_unsol_event(struct hda_codec *codec,
16321 unsigned int res)
16322{
16323 switch (res >> 26) {
16324 case ALC880_HP_EVENT:
16325 alc663_21jd_two_speaker_automute(codec);
16326 break;
16327 case ALC880_MIC_EVENT:
16328 alc662_eeepc_mic_automute(codec);
16329 break;
16330 }
16331}
16332
16333static void alc663_mode4_inithook(struct hda_codec *codec)
16334{
16335 alc663_21jd_two_speaker_automute(codec);
16336 alc662_eeepc_mic_automute(codec);
16337}
16338/* ***************** Mode5 ******************************/
16339static void alc663_mode5_unsol_event(struct hda_codec *codec,
16340 unsigned int res)
16341{
16342 switch (res >> 26) {
16343 case ALC880_HP_EVENT:
16344 alc663_15jd_two_speaker_automute(codec);
16345 break;
16346 case ALC880_MIC_EVENT:
16347 alc662_eeepc_mic_automute(codec);
16348 break;
16349 }
16350}
16351
16352static void alc663_mode5_inithook(struct hda_codec *codec)
16353{
16354 alc663_15jd_two_speaker_automute(codec);
16355 alc662_eeepc_mic_automute(codec);
16356}
16357/* ***************** Mode6 ******************************/
16358static void alc663_mode6_unsol_event(struct hda_codec *codec,
16359 unsigned int res)
16360{
16361 switch (res >> 26) {
16362 case ALC880_HP_EVENT:
16363 alc663_two_hp_m2_speaker_automute(codec);
16364 break;
16365 case ALC880_MIC_EVENT:
16366 alc662_eeepc_mic_automute(codec);
16367 break;
16368 }
16369}
16370
16371static void alc663_mode6_inithook(struct hda_codec *codec)
16372{
16373 alc663_two_hp_m2_speaker_automute(codec);
16374 alc662_eeepc_mic_automute(codec);
16375}
16376
Kailang Yang6dda9f42008-05-27 12:05:31 +020016377static void alc663_g71v_hp_automute(struct hda_codec *codec)
16378{
16379 unsigned int present;
16380 unsigned char bits;
16381
16382 present = snd_hda_codec_read(codec, 0x21, 0,
16383 AC_VERB_GET_PIN_SENSE, 0)
16384 & AC_PINSENSE_PRESENCE;
16385 bits = present ? HDA_AMP_MUTE : 0;
16386 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16387 HDA_AMP_MUTE, bits);
16388 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16389 HDA_AMP_MUTE, bits);
16390}
16391
16392static void alc663_g71v_front_automute(struct hda_codec *codec)
16393{
16394 unsigned int present;
16395 unsigned char bits;
16396
16397 present = snd_hda_codec_read(codec, 0x15, 0,
16398 AC_VERB_GET_PIN_SENSE, 0)
16399 & AC_PINSENSE_PRESENCE;
16400 bits = present ? HDA_AMP_MUTE : 0;
16401 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16402 HDA_AMP_MUTE, bits);
16403}
16404
16405static void alc663_g71v_unsol_event(struct hda_codec *codec,
16406 unsigned int res)
16407{
16408 switch (res >> 26) {
16409 case ALC880_HP_EVENT:
16410 alc663_g71v_hp_automute(codec);
16411 break;
16412 case ALC880_FRONT_EVENT:
16413 alc663_g71v_front_automute(codec);
16414 break;
16415 case ALC880_MIC_EVENT:
16416 alc662_eeepc_mic_automute(codec);
16417 break;
16418 }
16419}
16420
16421static void alc663_g71v_inithook(struct hda_codec *codec)
16422{
16423 alc663_g71v_front_automute(codec);
16424 alc663_g71v_hp_automute(codec);
16425 alc662_eeepc_mic_automute(codec);
16426}
16427
16428static void alc663_g50v_unsol_event(struct hda_codec *codec,
16429 unsigned int res)
16430{
16431 switch (res >> 26) {
16432 case ALC880_HP_EVENT:
16433 alc663_m51va_speaker_automute(codec);
16434 break;
16435 case ALC880_MIC_EVENT:
16436 alc662_eeepc_mic_automute(codec);
16437 break;
16438 }
16439}
16440
16441static void alc663_g50v_inithook(struct hda_codec *codec)
16442{
16443 alc663_m51va_speaker_automute(codec);
16444 alc662_eeepc_mic_automute(codec);
16445}
16446
Kailang Yangf1d4e282008-08-26 14:03:29 +020016447static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16448 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016449 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016450
16451 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16452 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16453 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16454
16455 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16456 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16457 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16458 { } /* end */
16459};
16460
Chris Pockelé9541ba12009-05-12 08:08:53 +020016461static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16462 /* Master Playback automatically created from Speaker and Headphone */
16463 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16464 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16465 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16466 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16467
16468 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16469 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16470 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16471
16472 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16473 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16474 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16475 { } /* end */
16476};
16477
Takashi Iwaicb53c622007-08-10 17:21:45 +020016478#ifdef CONFIG_SND_HDA_POWER_SAVE
16479#define alc662_loopbacks alc880_loopbacks
16480#endif
16481
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016482
16483/* pcm configuration: identiacal with ALC880 */
16484#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16485#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16486#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16487#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16488
16489/*
16490 * configuration and preset
16491 */
16492static const char *alc662_models[ALC662_MODEL_LAST] = {
16493 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16494 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16495 [ALC662_3ST_6ch] = "3stack-6ch",
16496 [ALC662_5ST_DIG] = "6stack-dig",
16497 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016498 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016499 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016500 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016501 [ALC663_ASUS_M51VA] = "m51va",
16502 [ALC663_ASUS_G71V] = "g71v",
16503 [ALC663_ASUS_H13] = "h13",
16504 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016505 [ALC663_ASUS_MODE1] = "asus-mode1",
16506 [ALC662_ASUS_MODE2] = "asus-mode2",
16507 [ALC663_ASUS_MODE3] = "asus-mode3",
16508 [ALC663_ASUS_MODE4] = "asus-mode4",
16509 [ALC663_ASUS_MODE5] = "asus-mode5",
16510 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016511 [ALC272_DELL] = "dell",
16512 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016513 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016514 [ALC662_AUTO] = "auto",
16515};
16516
16517static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016518 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016519 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16520 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016521 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16522 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16523 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16524 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16525 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16526 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16527 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16528 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16529 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16530 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16531 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16532 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016533 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16534 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16535 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016536 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16537 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16538 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16539 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016540 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016541 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16542 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016543 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016544 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16545 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16546 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016547 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16548 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16549 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016550 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16551 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16552 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016553 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016554 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16555 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016556 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016557 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016558 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016559 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16560 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16561 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016562 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016563 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16564 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016565 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016566 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016567 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016568 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016569 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16570 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016571 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016572 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16573 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016574 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016575 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016576 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016577 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016578 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016579 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16580 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016581 {}
16582};
16583
16584static struct alc_config_preset alc662_presets[] = {
16585 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016586 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016587 .init_verbs = { alc662_init_verbs },
16588 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16589 .dac_nids = alc662_dac_nids,
16590 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016591 .dig_in_nid = ALC662_DIGIN_NID,
16592 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16593 .channel_mode = alc662_3ST_2ch_modes,
16594 .input_mux = &alc662_capture_source,
16595 },
16596 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016597 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 .init_verbs = { alc662_init_verbs },
16599 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16600 .dac_nids = alc662_dac_nids,
16601 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016602 .dig_in_nid = ALC662_DIGIN_NID,
16603 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16604 .channel_mode = alc662_3ST_6ch_modes,
16605 .need_dac_fix = 1,
16606 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016607 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016608 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016609 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016610 .init_verbs = { alc662_init_verbs },
16611 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16612 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016613 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16614 .channel_mode = alc662_3ST_6ch_modes,
16615 .need_dac_fix = 1,
16616 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016617 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016618 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016619 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016620 .init_verbs = { alc662_init_verbs },
16621 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16622 .dac_nids = alc662_dac_nids,
16623 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016624 .dig_in_nid = ALC662_DIGIN_NID,
16625 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16626 .channel_mode = alc662_5stack_modes,
16627 .input_mux = &alc662_capture_source,
16628 },
16629 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016630 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016631 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16632 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16633 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016634 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16635 .channel_mode = alc662_3ST_2ch_modes,
16636 .input_mux = &alc662_lenovo_101e_capture_source,
16637 .unsol_event = alc662_lenovo_101e_unsol_event,
16638 .init_hook = alc662_lenovo_101e_all_automute,
16639 },
Kailang Yang291702f2007-10-16 14:28:03 +020016640 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016641 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016642 .init_verbs = { alc662_init_verbs,
16643 alc662_eeepc_sue_init_verbs },
16644 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16645 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16647 .channel_mode = alc662_3ST_2ch_modes,
16648 .input_mux = &alc662_eeepc_capture_source,
16649 .unsol_event = alc662_eeepc_unsol_event,
16650 .init_hook = alc662_eeepc_inithook,
16651 },
Kailang Yang8c427222008-01-10 13:03:59 +010016652 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016653 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016654 alc662_chmode_mixer },
16655 .init_verbs = { alc662_init_verbs,
16656 alc662_eeepc_ep20_sue_init_verbs },
16657 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16658 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016659 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16660 .channel_mode = alc662_3ST_6ch_modes,
16661 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016662 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016663 .init_hook = alc662_eeepc_ep20_inithook,
16664 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016665 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016666 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016667 .init_verbs = { alc662_init_verbs,
16668 alc662_ecs_init_verbs },
16669 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16670 .dac_nids = alc662_dac_nids,
16671 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16672 .channel_mode = alc662_3ST_2ch_modes,
16673 .input_mux = &alc662_eeepc_capture_source,
16674 .unsol_event = alc662_eeepc_unsol_event,
16675 .init_hook = alc662_eeepc_inithook,
16676 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016677 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016678 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016679 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16680 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16681 .dac_nids = alc662_dac_nids,
16682 .dig_out_nid = ALC662_DIGOUT_NID,
16683 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16684 .channel_mode = alc662_3ST_2ch_modes,
16685 .input_mux = &alc663_m51va_capture_source,
16686 .unsol_event = alc663_m51va_unsol_event,
16687 .init_hook = alc663_m51va_inithook,
16688 },
16689 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016690 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016691 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16692 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16693 .dac_nids = alc662_dac_nids,
16694 .dig_out_nid = ALC662_DIGOUT_NID,
16695 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16696 .channel_mode = alc662_3ST_2ch_modes,
16697 .input_mux = &alc662_eeepc_capture_source,
16698 .unsol_event = alc663_g71v_unsol_event,
16699 .init_hook = alc663_g71v_inithook,
16700 },
16701 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016702 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016703 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16704 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16705 .dac_nids = alc662_dac_nids,
16706 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16707 .channel_mode = alc662_3ST_2ch_modes,
16708 .input_mux = &alc663_m51va_capture_source,
16709 .unsol_event = alc663_m51va_unsol_event,
16710 .init_hook = alc663_m51va_inithook,
16711 },
16712 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016713 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016714 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16715 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16716 .dac_nids = alc662_dac_nids,
16717 .dig_out_nid = ALC662_DIGOUT_NID,
16718 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16719 .channel_mode = alc662_3ST_6ch_modes,
16720 .input_mux = &alc663_capture_source,
16721 .unsol_event = alc663_g50v_unsol_event,
16722 .init_hook = alc663_g50v_inithook,
16723 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016724 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016725 .mixers = { alc663_m51va_mixer },
16726 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016727 .init_verbs = { alc662_init_verbs,
16728 alc663_21jd_amic_init_verbs },
16729 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16730 .hp_nid = 0x03,
16731 .dac_nids = alc662_dac_nids,
16732 .dig_out_nid = ALC662_DIGOUT_NID,
16733 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16734 .channel_mode = alc662_3ST_2ch_modes,
16735 .input_mux = &alc662_eeepc_capture_source,
16736 .unsol_event = alc663_mode1_unsol_event,
16737 .init_hook = alc663_mode1_inithook,
16738 },
16739 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016740 .mixers = { alc662_1bjd_mixer },
16741 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016742 .init_verbs = { alc662_init_verbs,
16743 alc662_1bjd_amic_init_verbs },
16744 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16745 .dac_nids = alc662_dac_nids,
16746 .dig_out_nid = ALC662_DIGOUT_NID,
16747 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16748 .channel_mode = alc662_3ST_2ch_modes,
16749 .input_mux = &alc662_eeepc_capture_source,
16750 .unsol_event = alc662_mode2_unsol_event,
16751 .init_hook = alc662_mode2_inithook,
16752 },
16753 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016754 .mixers = { alc663_two_hp_m1_mixer },
16755 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016756 .init_verbs = { alc662_init_verbs,
16757 alc663_two_hp_amic_m1_init_verbs },
16758 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16759 .hp_nid = 0x03,
16760 .dac_nids = alc662_dac_nids,
16761 .dig_out_nid = ALC662_DIGOUT_NID,
16762 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16763 .channel_mode = alc662_3ST_2ch_modes,
16764 .input_mux = &alc662_eeepc_capture_source,
16765 .unsol_event = alc663_mode3_unsol_event,
16766 .init_hook = alc663_mode3_inithook,
16767 },
16768 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016769 .mixers = { alc663_asus_21jd_clfe_mixer },
16770 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016771 .init_verbs = { alc662_init_verbs,
16772 alc663_21jd_amic_init_verbs},
16773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16774 .hp_nid = 0x03,
16775 .dac_nids = alc662_dac_nids,
16776 .dig_out_nid = ALC662_DIGOUT_NID,
16777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16778 .channel_mode = alc662_3ST_2ch_modes,
16779 .input_mux = &alc662_eeepc_capture_source,
16780 .unsol_event = alc663_mode4_unsol_event,
16781 .init_hook = alc663_mode4_inithook,
16782 },
16783 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016784 .mixers = { alc663_asus_15jd_clfe_mixer },
16785 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016786 .init_verbs = { alc662_init_verbs,
16787 alc663_15jd_amic_init_verbs },
16788 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16789 .hp_nid = 0x03,
16790 .dac_nids = alc662_dac_nids,
16791 .dig_out_nid = ALC662_DIGOUT_NID,
16792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16793 .channel_mode = alc662_3ST_2ch_modes,
16794 .input_mux = &alc662_eeepc_capture_source,
16795 .unsol_event = alc663_mode5_unsol_event,
16796 .init_hook = alc663_mode5_inithook,
16797 },
16798 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016799 .mixers = { alc663_two_hp_m2_mixer },
16800 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016801 .init_verbs = { alc662_init_verbs,
16802 alc663_two_hp_amic_m2_init_verbs },
16803 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16804 .hp_nid = 0x03,
16805 .dac_nids = alc662_dac_nids,
16806 .dig_out_nid = ALC662_DIGOUT_NID,
16807 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16808 .channel_mode = alc662_3ST_2ch_modes,
16809 .input_mux = &alc662_eeepc_capture_source,
16810 .unsol_event = alc663_mode6_unsol_event,
16811 .init_hook = alc663_mode6_inithook,
16812 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016813 [ALC272_DELL] = {
16814 .mixers = { alc663_m51va_mixer },
16815 .cap_mixer = alc272_auto_capture_mixer,
16816 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16817 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16818 .dac_nids = alc662_dac_nids,
16819 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16820 .adc_nids = alc272_adc_nids,
16821 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16822 .capsrc_nids = alc272_capsrc_nids,
16823 .channel_mode = alc662_3ST_2ch_modes,
16824 .input_mux = &alc663_m51va_capture_source,
16825 .unsol_event = alc663_m51va_unsol_event,
16826 .init_hook = alc663_m51va_inithook,
16827 },
16828 [ALC272_DELL_ZM1] = {
16829 .mixers = { alc663_m51va_mixer },
16830 .cap_mixer = alc662_auto_capture_mixer,
16831 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16832 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16833 .dac_nids = alc662_dac_nids,
16834 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16835 .adc_nids = alc662_adc_nids,
16836 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16837 .capsrc_nids = alc662_capsrc_nids,
16838 .channel_mode = alc662_3ST_2ch_modes,
16839 .input_mux = &alc663_m51va_capture_source,
16840 .unsol_event = alc663_m51va_unsol_event,
16841 .init_hook = alc663_m51va_inithook,
16842 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016843 [ALC272_SAMSUNG_NC10] = {
16844 .mixers = { alc272_nc10_mixer },
16845 .init_verbs = { alc662_init_verbs,
16846 alc663_21jd_amic_init_verbs },
16847 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16848 .dac_nids = alc272_dac_nids,
16849 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16850 .channel_mode = alc662_3ST_2ch_modes,
16851 .input_mux = &alc272_nc10_capture_source,
16852 .unsol_event = alc663_mode4_unsol_event,
16853 .init_hook = alc663_mode4_inithook,
16854 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855};
16856
16857
16858/*
16859 * BIOS auto configuration
16860 */
16861
16862/* add playback controls from the parsed DAC table */
16863static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16864 const struct auto_pin_cfg *cfg)
16865{
16866 char name[32];
16867 static const char *chname[4] = {
16868 "Front", "Surround", NULL /*CLFE*/, "Side"
16869 };
16870 hda_nid_t nid;
16871 int i, err;
16872
16873 for (i = 0; i < cfg->line_outs; i++) {
16874 if (!spec->multiout.dac_nids[i])
16875 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016876 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016877 if (i == 2) {
16878 /* Center/LFE */
16879 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16880 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016881 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16882 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 if (err < 0)
16884 return err;
16885 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16886 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016887 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16888 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 if (err < 0)
16890 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016891 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016892 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016893 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016894 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 if (err < 0)
16896 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016897 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016898 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016899 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016900 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901 if (err < 0)
16902 return err;
16903 } else {
16904 sprintf(name, "%s Playback Volume", chname[i]);
16905 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016906 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16907 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016908 if (err < 0)
16909 return err;
16910 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016911 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16912 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16913 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914 if (err < 0)
16915 return err;
16916 }
16917 }
16918 return 0;
16919}
16920
16921/* add playback controls for speaker and HP outputs */
16922static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16923 const char *pfx)
16924{
16925 hda_nid_t nid;
16926 int err;
16927 char name[32];
16928
16929 if (!pin)
16930 return 0;
16931
Takashi Iwai24fb9172008-09-02 14:48:20 +020016932 if (pin == 0x17) {
16933 /* ALC663 has a mono output pin on 0x17 */
16934 sprintf(name, "%s Playback Switch", pfx);
16935 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16936 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16937 return err;
16938 }
16939
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016940 if (alc880_is_fixed_pin(pin)) {
16941 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016942 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016943 /* specify the DAC as the extra output */
16944 if (!spec->multiout.hp_nid)
16945 spec->multiout.hp_nid = nid;
16946 else
16947 spec->multiout.extra_out_nid[0] = nid;
16948 /* control HP volume/switch on the output mixer amp */
16949 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16950 sprintf(name, "%s Playback Volume", pfx);
16951 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16952 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16953 if (err < 0)
16954 return err;
16955 sprintf(name, "%s Playback Switch", pfx);
16956 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16957 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16958 if (err < 0)
16959 return err;
16960 } else if (alc880_is_multi_pin(pin)) {
16961 /* set manual connection */
16962 /* we have only a switch on HP-out PIN */
16963 sprintf(name, "%s Playback Switch", pfx);
16964 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16965 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16966 if (err < 0)
16967 return err;
16968 }
16969 return 0;
16970}
16971
Takashi Iwai2d864c42009-03-20 12:52:47 +010016972/* return the index of the src widget from the connection list of the nid.
16973 * return -1 if not found
16974 */
16975static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16976 hda_nid_t src)
16977{
16978 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16979 int i, conns;
16980
16981 conns = snd_hda_get_connections(codec, nid, conn_list,
16982 ARRAY_SIZE(conn_list));
16983 if (conns < 0)
16984 return -1;
16985 for (i = 0; i < conns; i++)
16986 if (conn_list[i] == src)
16987 return i;
16988 return -1;
16989}
16990
16991static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16992{
Takashi Iwai1327a322009-03-23 13:07:47 +010016993 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016994 return (pincap & AC_PINCAP_IN) != 0;
16995}
16996
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016997/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016998static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016999 const struct auto_pin_cfg *cfg)
17000{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017001 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017002 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017003 int i, err, idx;
17004
17005 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017006 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17007 idx = alc662_input_pin_idx(codec, 0x0b,
17008 cfg->input_pins[i]);
17009 if (idx >= 0) {
17010 err = new_analog_input(spec, cfg->input_pins[i],
17011 auto_pin_cfg_labels[i],
17012 idx, 0x0b);
17013 if (err < 0)
17014 return err;
17015 }
17016 idx = alc662_input_pin_idx(codec, 0x22,
17017 cfg->input_pins[i]);
17018 if (idx >= 0) {
17019 imux->items[imux->num_items].label =
17020 auto_pin_cfg_labels[i];
17021 imux->items[imux->num_items].index = idx;
17022 imux->num_items++;
17023 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017024 }
17025 }
17026 return 0;
17027}
17028
17029static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17030 hda_nid_t nid, int pin_type,
17031 int dac_idx)
17032{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017033 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017034 /* need the manual connection? */
17035 if (alc880_is_multi_pin(nid)) {
17036 struct alc_spec *spec = codec->spec;
17037 int idx = alc880_multi_pin_idx(nid);
17038 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17039 AC_VERB_SET_CONNECT_SEL,
17040 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17041 }
17042}
17043
17044static void alc662_auto_init_multi_out(struct hda_codec *codec)
17045{
17046 struct alc_spec *spec = codec->spec;
17047 int i;
17048
17049 for (i = 0; i <= HDA_SIDE; i++) {
17050 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017051 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017052 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017053 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017054 i);
17055 }
17056}
17057
17058static void alc662_auto_init_hp_out(struct hda_codec *codec)
17059{
17060 struct alc_spec *spec = codec->spec;
17061 hda_nid_t pin;
17062
17063 pin = spec->autocfg.hp_pins[0];
17064 if (pin) /* connect to front */
17065 /* use dac 0 */
17066 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017067 pin = spec->autocfg.speaker_pins[0];
17068 if (pin)
17069 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017070}
17071
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017072#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17073
17074static void alc662_auto_init_analog_input(struct hda_codec *codec)
17075{
17076 struct alc_spec *spec = codec->spec;
17077 int i;
17078
17079 for (i = 0; i < AUTO_PIN_LAST; i++) {
17080 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017081 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017082 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017083 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017084 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017085 snd_hda_codec_write(codec, nid, 0,
17086 AC_VERB_SET_AMP_GAIN_MUTE,
17087 AMP_OUT_MUTE);
17088 }
17089 }
17090}
17091
Takashi Iwaif511b012008-08-15 16:46:42 +020017092#define alc662_auto_init_input_src alc882_auto_init_input_src
17093
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017094static int alc662_parse_auto_config(struct hda_codec *codec)
17095{
17096 struct alc_spec *spec = codec->spec;
17097 int err;
17098 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17099
17100 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17101 alc662_ignore);
17102 if (err < 0)
17103 return err;
17104 if (!spec->autocfg.line_outs)
17105 return 0; /* can't find valid BIOS pin config */
17106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017107 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17108 if (err < 0)
17109 return err;
17110 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17111 if (err < 0)
17112 return err;
17113 err = alc662_auto_create_extra_out(spec,
17114 spec->autocfg.speaker_pins[0],
17115 "Speaker");
17116 if (err < 0)
17117 return err;
17118 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17119 "Headphone");
17120 if (err < 0)
17121 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017122 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017123 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017124 return err;
17125
17126 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17127
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017128 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017129 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17130
Takashi Iwai603c4012008-07-30 15:01:44 +020017131 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017132 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017133
17134 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017135 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017136
Takashi Iwaid88897e2008-10-31 15:01:37 +010017137 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017138 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017139 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017140
17141 err = alc_auto_add_mic_boost(codec);
17142 if (err < 0)
17143 return err;
17144
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017145 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17146
Takashi Iwai8c872862007-06-19 12:11:16 +020017147 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017148}
17149
17150/* additional initialization for auto-configuration model */
17151static void alc662_auto_init(struct hda_codec *codec)
17152{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017153 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017154 alc662_auto_init_multi_out(codec);
17155 alc662_auto_init_hp_out(codec);
17156 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017157 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017158 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017159 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160}
17161
17162static int patch_alc662(struct hda_codec *codec)
17163{
17164 struct alc_spec *spec;
17165 int err, board_config;
17166
17167 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17168 if (!spec)
17169 return -ENOMEM;
17170
17171 codec->spec = spec;
17172
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017173 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17174
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017175 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17176 alc662_models,
17177 alc662_cfg_tbl);
17178 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017179 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17180 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017181 board_config = ALC662_AUTO;
17182 }
17183
17184 if (board_config == ALC662_AUTO) {
17185 /* automatic parse from the BIOS config */
17186 err = alc662_parse_auto_config(codec);
17187 if (err < 0) {
17188 alc_free(codec);
17189 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017190 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017191 printk(KERN_INFO
17192 "hda_codec: Cannot set up configuration "
17193 "from BIOS. Using base mode...\n");
17194 board_config = ALC662_3ST_2ch_DIG;
17195 }
17196 }
17197
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017198 err = snd_hda_attach_beep_device(codec, 0x1);
17199 if (err < 0) {
17200 alc_free(codec);
17201 return err;
17202 }
17203
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017204 if (board_config != ALC662_AUTO)
17205 setup_preset(spec, &alc662_presets[board_config]);
17206
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017207 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17208 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17209
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017210 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17211 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17212
Takashi Iwaie1406342008-02-11 18:32:32 +010017213 spec->adc_nids = alc662_adc_nids;
17214 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17215 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017216 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017217
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017218 if (!spec->cap_mixer)
17219 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017220 if (codec->vendor_id == 0x10ec0662)
17221 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17222 else
17223 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017224
Takashi Iwai2134ea42008-01-10 16:53:55 +010017225 spec->vmaster_nid = 0x02;
17226
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017227 codec->patch_ops = alc_patch_ops;
17228 if (board_config == ALC662_AUTO)
17229 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017230#ifdef CONFIG_SND_HDA_POWER_SAVE
17231 if (!spec->loopback.amplist)
17232 spec->loopback.amplist = alc662_loopbacks;
17233#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017234 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017235
17236 return 0;
17237}
17238
17239/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017240 * patch entries
17241 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017242static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017243 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017244 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017245 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017246 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017247 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017248 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017250 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017251 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17252 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17253 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017254 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17255 .patch = patch_alc883 },
17256 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17257 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017258 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017260 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017261 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017262 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17263 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017264 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017265 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017266 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017267 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017268 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17269 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017270 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017271 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017272 {} /* terminator */
17273};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017274
17275MODULE_ALIAS("snd-hda-codec-id:10ec*");
17276
17277MODULE_LICENSE("GPL");
17278MODULE_DESCRIPTION("Realtek HD-audio codec");
17279
17280static struct hda_codec_preset_list realtek_list = {
17281 .preset = snd_hda_preset_realtek,
17282 .owner = THIS_MODULE,
17283};
17284
17285static int __init patch_realtek_init(void)
17286{
17287 return snd_hda_add_codec_preset(&realtek_list);
17288}
17289
17290static void __exit patch_realtek_exit(void)
17291{
17292 snd_hda_delete_codec_preset(&realtek_list);
17293}
17294
17295module_init(patch_realtek_init)
17296module_exit(patch_realtek_exit)