blob: 7967f8f1a34733108c0e5c580bcc3f4d977f0193 [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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200238 ALC888_ASUS_M90V,
239 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200240 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100241 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200242 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200243 ALC882_AUTO,
244 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200245};
246
Kailang Yangdf694da2005-12-05 19:42:22 +0100247/* for GPIO Poll */
248#define GPIO_MASK 0x03
249
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200250/* extra amp-initialization sequence types */
251enum {
252 ALC_INIT_NONE,
253 ALC_INIT_DEFAULT,
254 ALC_INIT_GPIO1,
255 ALC_INIT_GPIO2,
256 ALC_INIT_GPIO3,
257};
258
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259struct alc_spec {
260 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100263 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100264 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Kailang Yangdf694da2005-12-05 19:42:22 +0100266 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200267 * don't forget NULL
268 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200269 */
270 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200272 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 struct hda_pcm_stream *stream_analog_playback;
274 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100275 struct hda_pcm_stream *stream_analog_alt_playback;
276 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200278 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 struct hda_pcm_stream *stream_digital_playback;
280 struct hda_pcm_stream *stream_digital_capture;
281
282 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200283 struct hda_multi_out multiout; /* playback set-up
284 * max_channels, dacs must be set
285 * dig_out_nid and hp_nid are optional
286 */
Takashi Iwai63300792008-01-24 15:31:36 +0100287 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100288 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100289 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
291 /* capture */
292 unsigned int num_adc_nids;
293 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100294 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200295 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200298 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 const struct hda_input_mux *input_mux;
300 unsigned int cur_mux[3];
301
302 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100303 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200305 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200306 int const_channel_count;
307 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100310 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200311
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200312 /* dynamic controls, init_verbs and input_mux */
313 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200314 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200315 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200316 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200317 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
318 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100319
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100320 /* hooks */
321 void (*init_hook)(struct hda_codec *codec);
322 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
323
Takashi Iwai834be882006-03-01 14:16:17 +0100324 /* for pin sensing */
325 unsigned int sense_updated: 1;
326 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100327 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200328
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100329 /* other flags */
330 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200331 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100332
Takashi Iwai2134ea42008-01-10 16:53:55 +0100333 /* for virtual master */
334 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200335#ifdef CONFIG_SND_HDA_POWER_SAVE
336 struct hda_loopback_check loopback;
337#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200338
339 /* for PLL fix */
340 hda_nid_t pll_nid;
341 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100342};
343
344/*
345 * configuration template - to be copied to the spec instance
346 */
347struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200348 struct snd_kcontrol_new *mixers[5]; /* should be identical size
349 * with spec
350 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100351 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100352 const struct hda_verb *init_verbs[5];
353 unsigned int num_dacs;
354 hda_nid_t *dac_nids;
355 hda_nid_t dig_out_nid; /* optional */
356 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800357 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100358 unsigned int num_adc_nids;
359 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100360 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100361 hda_nid_t dig_in_nid;
362 unsigned int num_channel_mode;
363 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200364 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200365 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200366 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100368 void (*unsol_event)(struct hda_codec *, unsigned int);
369 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200370#ifdef CONFIG_SND_HDA_POWER_SAVE
371 struct hda_amp_list *loopbacks;
372#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373};
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375
376/*
377 * input MUX handling
378 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200379static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381{
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200384 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
385 if (mux_idx >= spec->num_mux_defs)
386 mux_idx = 0;
387 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388}
389
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200390static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
394 struct alc_spec *spec = codec->spec;
395 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
396
397 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
398 return 0;
399}
400
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200401static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403{
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100406 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100408 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100409 hda_nid_t nid = spec->capsrc_nids ?
410 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200411 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Takashi Iwaicd896c32008-11-18 12:36:33 +0100413 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
414 imux = &spec->input_mux[mux_idx];
415
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200416 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
417 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100418 /* Matrix-mixer style (e.g. ALC882) */
419 unsigned int *cur_val = &spec->cur_mux[adc_idx];
420 unsigned int i, idx;
421
422 idx = ucontrol->value.enumerated.item[0];
423 if (idx >= imux->num_items)
424 idx = imux->num_items - 1;
425 if (*cur_val == idx)
426 return 0;
427 for (i = 0; i < imux->num_items; i++) {
428 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
429 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
430 imux->items[i].index,
431 HDA_AMP_MUTE, v);
432 }
433 *cur_val = idx;
434 return 1;
435 } else {
436 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100437 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100438 &spec->cur_mux[adc_idx]);
439 }
440}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442/*
443 * channel mode setting
444 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100450 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
451 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452}
453
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456{
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100459 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200460 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200461 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462}
463
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200469 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
470 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200471 &spec->ext_channel_count);
472 if (err >= 0 && !spec->const_channel_count) {
473 spec->multiout.max_channels = spec->ext_channel_count;
474 if (spec->need_dac_fix)
475 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
476 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200477 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200482 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 * being part of a format specifier. Maximum allowed length of a value is
484 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100485 *
486 * Note: some retasking pin complexes seem to ignore requests for input
487 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
488 * are requested. Therefore order this list so that this behaviour will not
489 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200490 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
491 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200492 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100493static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100494 "Mic 50pc bias", "Mic 80pc bias",
495 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496};
497static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100498 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499};
500/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200501 * in the pin being assumed to be exclusively an input or an output pin. In
502 * addition, "input" pins may or may not process the mic bias option
503 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
504 * accept requests for bias as of chip versions up to March 2006) and/or
505 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200507#define ALC_PIN_DIR_IN 0x00
508#define ALC_PIN_DIR_OUT 0x01
509#define ALC_PIN_DIR_INOUT 0x02
510#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
511#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512
Kailang Yangea1fb292008-08-26 12:58:38 +0200513/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 * For each direction the minimum and maximum values are given.
515 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200516static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100517 { 0, 2 }, /* ALC_PIN_DIR_IN */
518 { 3, 4 }, /* ALC_PIN_DIR_OUT */
519 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
521 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522};
523#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
524#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
525#define alc_pin_mode_n_items(_dir) \
526 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
527
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 unsigned int item_num = uinfo->value.enumerated.item;
532 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
533
534 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200535 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
537
538 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
539 item_num = alc_pin_mode_min(dir);
540 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200541 return 0;
542}
543
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200551 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
553 AC_VERB_GET_PIN_WIDGET_CONTROL,
554 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556 /* Find enumerated value for current pinctl setting */
557 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 return 0;
562}
563
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566{
567 signed int change;
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 hda_nid_t nid = kcontrol->private_value & 0xffff;
570 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
571 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
573 AC_VERB_GET_PIN_WIDGET_CONTROL,
574 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200576 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 val = alc_pin_mode_min(dir);
578
579 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100580 if (change) {
581 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200582 snd_hda_codec_write_cache(codec, nid, 0,
583 AC_VERB_SET_PIN_WIDGET_CONTROL,
584 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100585
Kailang Yangea1fb292008-08-26 12:58:38 +0200586 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 * for the requested pin mode. Enum values of 2 or less are
588 * input modes.
589 *
590 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 * reduces noise slightly (particularly on input) so we'll
592 * do it. However, having both input and output buffers
593 * enabled simultaneously doesn't seem to be problematic if
594 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100595 */
596 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200597 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
598 HDA_AMP_MUTE, HDA_AMP_MUTE);
599 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
600 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200602 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
603 HDA_AMP_MUTE, HDA_AMP_MUTE);
604 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
605 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100606 }
607 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200608 return change;
609}
610
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100613 .info = alc_pin_mode_info, \
614 .get = alc_pin_mode_get, \
615 .put = alc_pin_mode_put, \
616 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100617
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100618/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
619 * together using a mask with more than one bit set. This control is
620 * currently used only by the ALC260 test model. At this stage they are not
621 * needed for any "production" models.
622 */
623#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200624#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200625
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200626static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633 unsigned int val = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100635
636 *valp = (val & mask) != 0;
637 return 0;
638}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641{
642 signed int change;
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
645 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
646 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_GPIO_DATA,
649 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650
651 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
653 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654 gpio_data &= ~mask;
655 else
656 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200657 snd_hda_codec_write_cache(codec, nid, 0,
658 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100659
660 return change;
661}
662#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
663 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
664 .info = alc_gpio_data_info, \
665 .get = alc_gpio_data_get, \
666 .put = alc_gpio_data_put, \
667 .private_value = nid | (mask<<16) }
668#endif /* CONFIG_SND_DEBUG */
669
Jonathan Woithe92621f12006-02-28 11:47:47 +0100670/* A switch control to allow the enabling of the digital IO pins on the
671 * ALC260. This is incredibly simplistic; the intention of this control is
672 * to provide something in the test model allowing digital outputs to be
673 * identified if present. If models are found which can utilise these
674 * outputs a more complete mixer control can be devised for those models if
675 * necessary.
676 */
677#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200678#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200679
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200680static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100682{
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100688 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100689
690 *valp = (val & mask) != 0;
691 return 0;
692}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695{
696 signed int change;
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 hda_nid_t nid = kcontrol->private_value & 0xffff;
699 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
700 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100702 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100704
705 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100707 if (val==0)
708 ctrl_data &= ~mask;
709 else
710 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200711 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
712 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100713
714 return change;
715}
716#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
717 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
718 .info = alc_spdif_ctrl_info, \
719 .get = alc_spdif_ctrl_get, \
720 .put = alc_spdif_ctrl_put, \
721 .private_value = nid | (mask<<16) }
722#endif /* CONFIG_SND_DEBUG */
723
Jonathan Woithef8225f62008-01-08 12:16:54 +0100724/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
725 * Again, this is only used in the ALC26x test models to help identify when
726 * the EAPD line must be asserted for features to work.
727 */
728#ifdef CONFIG_SND_DEBUG
729#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
730
731static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
735 hda_nid_t nid = kcontrol->private_value & 0xffff;
736 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
737 long *valp = ucontrol->value.integer.value;
738 unsigned int val = snd_hda_codec_read(codec, nid, 0,
739 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
740
741 *valp = (val & mask) != 0;
742 return 0;
743}
744
745static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
746 struct snd_ctl_elem_value *ucontrol)
747{
748 int change;
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 hda_nid_t nid = kcontrol->private_value & 0xffff;
751 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
752 long val = *ucontrol->value.integer.value;
753 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
754 AC_VERB_GET_EAPD_BTLENABLE,
755 0x00);
756
757 /* Set/unset the masked control bit(s) as needed */
758 change = (!val ? 0 : mask) != (ctrl_data & mask);
759 if (!val)
760 ctrl_data &= ~mask;
761 else
762 ctrl_data |= mask;
763 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
764 ctrl_data);
765
766 return change;
767}
768
769#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
770 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
771 .info = alc_eapd_ctrl_info, \
772 .get = alc_eapd_ctrl_get, \
773 .put = alc_eapd_ctrl_put, \
774 .private_value = nid | (mask<<16) }
775#endif /* CONFIG_SND_DEBUG */
776
Kailang Yangdf694da2005-12-05 19:42:22 +0100777/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100778 * set up the input pin config (depending on the given auto-pin type)
779 */
780static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
781 int auto_pin_type)
782{
783 unsigned int val = PIN_IN;
784
785 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
786 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100787 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100788 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
789 if (pincap & AC_PINCAP_VREF_80)
790 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200791 else if (pincap & AC_PINCAP_VREF_50)
792 val = PIN_VREF50;
793 else if (pincap & AC_PINCAP_VREF_100)
794 val = PIN_VREF100;
795 else if (pincap & AC_PINCAP_VREF_GRD)
796 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100797 }
798 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
799}
800
801/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100802 */
803static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
804{
805 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
806 return;
807 spec->mixers[spec->num_mixers++] = mix;
808}
809
810static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
811{
812 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
813 return;
814 spec->init_verbs[spec->num_init_verbs++] = verb;
815}
816
Takashi Iwaidaead532008-11-28 12:55:36 +0100817#ifdef CONFIG_PROC_FS
818/*
819 * hook for proc
820 */
821static void print_realtek_coef(struct snd_info_buffer *buffer,
822 struct hda_codec *codec, hda_nid_t nid)
823{
824 int coeff;
825
826 if (nid != 0x20)
827 return;
828 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
829 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
830 coeff = snd_hda_codec_read(codec, nid, 0,
831 AC_VERB_GET_COEF_INDEX, 0);
832 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
833}
834#else
835#define print_realtek_coef NULL
836#endif
837
Takashi Iwaid88897e2008-10-31 15:01:37 +0100838/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100839 * set up from the preset table
840 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200841static void setup_preset(struct alc_spec *spec,
842 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100843{
844 int i;
845
846 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100847 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100848 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200849 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
850 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200852
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 spec->channel_mode = preset->channel_mode;
854 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200855 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200856 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100857
Hector Martin3b315d72009-06-02 10:54:19 +0200858 if (preset->const_channel_count)
859 spec->multiout.max_channels = preset->const_channel_count;
860 else
861 spec->multiout.max_channels = spec->channel_mode[0].channels;
862 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100863
864 spec->multiout.num_dacs = preset->num_dacs;
865 spec->multiout.dac_nids = preset->dac_nids;
866 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800867 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200869
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200870 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200871 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200872 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873 spec->input_mux = preset->input_mux;
874
875 spec->num_adc_nids = preset->num_adc_nids;
876 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100877 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100879
880 spec->unsol_event = preset->unsol_event;
881 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200882#ifdef CONFIG_SND_HDA_POWER_SAVE
883 spec->loopback.amplist = preset->loopbacks;
884#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100885}
886
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200887/* Enable GPIO mask and set output */
888static struct hda_verb alc_gpio1_init_verbs[] = {
889 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
890 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
891 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
892 { }
893};
894
895static struct hda_verb alc_gpio2_init_verbs[] = {
896 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
897 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
898 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
899 { }
900};
901
Kailang Yangbdd148a2007-05-08 15:19:08 +0200902static struct hda_verb alc_gpio3_init_verbs[] = {
903 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
904 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
905 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
906 { }
907};
908
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200909/*
910 * Fix hardware PLL issue
911 * On some codecs, the analog PLL gating control must be off while
912 * the default value is 1.
913 */
914static void alc_fix_pll(struct hda_codec *codec)
915{
916 struct alc_spec *spec = codec->spec;
917 unsigned int val;
918
919 if (!spec->pll_nid)
920 return;
921 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
922 spec->pll_coef_idx);
923 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
924 AC_VERB_GET_PROC_COEF, 0);
925 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
926 spec->pll_coef_idx);
927 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
928 val & ~(1 << spec->pll_coef_bit));
929}
930
931static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
932 unsigned int coef_idx, unsigned int coef_bit)
933{
934 struct alc_spec *spec = codec->spec;
935 spec->pll_nid = nid;
936 spec->pll_coef_idx = coef_idx;
937 spec->pll_coef_bit = coef_bit;
938 alc_fix_pll(codec);
939}
940
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200941static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200942{
943 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200944 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200945 unsigned int nid = spec->autocfg.hp_pins[0];
946 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200947
Takashi Iwai261c2402009-06-25 08:13:40 +0200948 pincap = snd_hda_query_pin_caps(codec, nid);
949 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
950 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200951 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200952 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200953 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
954 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
955 nid = spec->autocfg.speaker_pins[i];
956 if (!nid)
957 break;
958 snd_hda_codec_write(codec, nid, 0,
959 AC_VERB_SET_PIN_WIDGET_CONTROL,
960 spec->jack_present ? 0 : PIN_OUT);
961 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200962}
963
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400964#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200965static void alc_mic_automute(struct hda_codec *codec)
966{
967 struct alc_spec *spec = codec->spec;
968 unsigned int present;
969 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
970 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
971 unsigned int mix_nid = spec->capsrc_nids[0];
972 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
973
974 capsrc_idx_mic = mic_nid - 0x18;
975 capsrc_idx_fmic = fmic_nid - 0x18;
976 present = snd_hda_codec_read(codec, mic_nid, 0,
977 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
978 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
979 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
980 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
981 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
982 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
983 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
984}
Takashi Iwai4605b712008-10-31 14:18:24 +0100985#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100986#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100987#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200988
Kailang Yangc9b58002007-10-16 14:30:01 +0200989/* unsolicited event for HP jack sensing */
990static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
991{
992 if (codec->vendor_id == 0x10ec0880)
993 res >>= 28;
994 else
995 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200996 switch (res) {
997 case ALC880_HP_EVENT:
998 alc_automute_pin(codec);
999 break;
1000 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001002 break;
1003 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001004}
1005
1006static void alc_inithook(struct hda_codec *codec)
1007{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001008 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001009 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001010}
1011
Kailang Yangf9423e72008-05-27 12:32:25 +02001012/* additional initialization for ALC888 variants */
1013static void alc888_coef_init(struct hda_codec *codec)
1014{
1015 unsigned int tmp;
1016
1017 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1018 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1019 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001020 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001021 /* alc888S-VC */
1022 snd_hda_codec_read(codec, 0x20, 0,
1023 AC_VERB_SET_PROC_COEF, 0x830);
1024 else
1025 /* alc888-VB */
1026 snd_hda_codec_read(codec, 0x20, 0,
1027 AC_VERB_SET_PROC_COEF, 0x3030);
1028}
1029
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001030static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001031{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001032 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001033
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001034 switch (type) {
1035 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001036 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1037 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001038 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001039 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1040 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001041 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001042 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1043 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001044 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001045 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001046 case 0x10ec0260:
1047 snd_hda_codec_write(codec, 0x0f, 0,
1048 AC_VERB_SET_EAPD_BTLENABLE, 2);
1049 snd_hda_codec_write(codec, 0x10, 0,
1050 AC_VERB_SET_EAPD_BTLENABLE, 2);
1051 break;
1052 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001053 case 0x10ec0267:
1054 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001056 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001057 case 0x10ec0660:
1058 case 0x10ec0662:
1059 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001060 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001061 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001062 snd_hda_codec_write(codec, 0x14, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 snd_hda_codec_write(codec, 0x15, 0,
1065 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001067 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001068 switch (codec->vendor_id) {
1069 case 0x10ec0260:
1070 snd_hda_codec_write(codec, 0x1a, 0,
1071 AC_VERB_SET_COEF_INDEX, 7);
1072 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1073 AC_VERB_GET_PROC_COEF, 0);
1074 snd_hda_codec_write(codec, 0x1a, 0,
1075 AC_VERB_SET_COEF_INDEX, 7);
1076 snd_hda_codec_write(codec, 0x1a, 0,
1077 AC_VERB_SET_PROC_COEF,
1078 tmp | 0x2010);
1079 break;
1080 case 0x10ec0262:
1081 case 0x10ec0880:
1082 case 0x10ec0882:
1083 case 0x10ec0883:
1084 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001085 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001086 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001087 snd_hda_codec_write(codec, 0x20, 0,
1088 AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0,
1090 AC_VERB_GET_PROC_COEF, 0);
1091 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001092 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001093 snd_hda_codec_write(codec, 0x20, 0,
1094 AC_VERB_SET_PROC_COEF,
1095 tmp | 0x2010);
1096 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001097 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001099 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 case 0x10ec0267:
1101 case 0x10ec0268:
1102 snd_hda_codec_write(codec, 0x20, 0,
1103 AC_VERB_SET_COEF_INDEX, 7);
1104 tmp = snd_hda_codec_read(codec, 0x20, 0,
1105 AC_VERB_GET_PROC_COEF, 0);
1106 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001107 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 snd_hda_codec_write(codec, 0x20, 0,
1109 AC_VERB_SET_PROC_COEF,
1110 tmp | 0x3000);
1111 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001112 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001113 break;
1114 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001115}
Kailang Yangea1fb292008-08-26 12:58:38 +02001116
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001117static void alc_init_auto_hp(struct hda_codec *codec)
1118{
1119 struct alc_spec *spec = codec->spec;
1120
1121 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001123
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001125 if (spec->autocfg.line_out_pins[0] &&
1126 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001128 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 else
1130 return;
1131 }
1132
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001133 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1134 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001135 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1136 AC_VERB_SET_UNSOLICITED_ENABLE,
1137 AC_USRSP_EN | ALC880_HP_EVENT);
1138 spec->unsol_event = alc_sku_unsol_event;
1139}
1140
1141/* check subsystem ID and set up device-specific initialization;
1142 * return 1 if initialized, 0 if invalid SSID
1143 */
1144/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1145 * 31 ~ 16 : Manufacture ID
1146 * 15 ~ 8 : SKU ID
1147 * 7 ~ 0 : Assembly ID
1148 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1149 */
1150static int alc_subsystem_id(struct hda_codec *codec,
1151 hda_nid_t porta, hda_nid_t porte,
1152 hda_nid_t portd)
1153{
1154 unsigned int ass, tmp, i;
1155 unsigned nid;
1156 struct alc_spec *spec = codec->spec;
1157
1158 ass = codec->subsystem_id & 0xffff;
1159 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1160 goto do_sku;
1161
1162 /* invalid SSID, check the special NID pin defcfg instead */
1163 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001164 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001165 * 29~21 : reserve
1166 * 20 : PCBEEP input
1167 * 19~16 : Check sum (15:1)
1168 * 15~1 : Custom
1169 * 0 : override
1170 */
1171 nid = 0x1d;
1172 if (codec->vendor_id == 0x10ec0260)
1173 nid = 0x17;
1174 ass = snd_hda_codec_get_pincfg(codec, nid);
1175 snd_printd("realtek: No valid SSID, "
1176 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001177 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001178 if (!(ass & 1) && !(ass & 0x100000))
1179 return 0;
1180 if ((ass >> 30) != 1) /* no physical connection */
1181 return 0;
1182
1183 /* check sum */
1184 tmp = 0;
1185 for (i = 1; i < 16; i++) {
1186 if ((ass >> i) & 1)
1187 tmp++;
1188 }
1189 if (((ass >> 16) & 0xf) != tmp)
1190 return 0;
1191do_sku:
1192 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1193 ass & 0xffff, codec->vendor_id);
1194 /*
1195 * 0 : override
1196 * 1 : Swap Jack
1197 * 2 : 0 --> Desktop, 1 --> Laptop
1198 * 3~5 : External Amplifier control
1199 * 7~6 : Reserved
1200 */
1201 tmp = (ass & 0x38) >> 3; /* external Amp control */
1202 switch (tmp) {
1203 case 1:
1204 spec->init_amp = ALC_INIT_GPIO1;
1205 break;
1206 case 3:
1207 spec->init_amp = ALC_INIT_GPIO2;
1208 break;
1209 case 7:
1210 spec->init_amp = ALC_INIT_GPIO3;
1211 break;
1212 case 5:
1213 spec->init_amp = ALC_INIT_DEFAULT;
1214 break;
1215 }
1216
1217 /* is laptop or Desktop and enable the function "Mute internal speaker
1218 * when the external headphone out jack is plugged"
1219 */
1220 if (!(ass & 0x8000))
1221 return 1;
1222 /*
1223 * 10~8 : Jack location
1224 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1225 * 14~13: Resvered
1226 * 15 : 1 --> enable the function "Mute internal speaker
1227 * when the external headphone out jack is plugged"
1228 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001229 if (!spec->autocfg.hp_pins[0]) {
1230 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1231 if (tmp == 0)
1232 spec->autocfg.hp_pins[0] = porta;
1233 else if (tmp == 1)
1234 spec->autocfg.hp_pins[0] = porte;
1235 else if (tmp == 2)
1236 spec->autocfg.hp_pins[0] = portd;
1237 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001238 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001239 }
1240
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241 alc_init_auto_hp(codec);
1242 return 1;
1243}
Kailang Yangea1fb292008-08-26 12:58:38 +02001244
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245static void alc_ssid_check(struct hda_codec *codec,
1246 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1247{
1248 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1249 struct alc_spec *spec = codec->spec;
1250 snd_printd("realtek: "
1251 "Enable default setup for auto mode as fallback\n");
1252 spec->init_amp = ALC_INIT_DEFAULT;
1253 alc_init_auto_hp(codec);
1254 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001255}
1256
Takashi Iwai41e41f12005-06-08 14:48:49 +02001257/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001258 * Fix-up pin default configurations
1259 */
1260
1261struct alc_pincfg {
1262 hda_nid_t nid;
1263 u32 val;
1264};
1265
1266static void alc_fix_pincfg(struct hda_codec *codec,
1267 const struct snd_pci_quirk *quirk,
1268 const struct alc_pincfg **pinfix)
1269{
1270 const struct alc_pincfg *cfg;
1271
1272 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1273 if (!quirk)
1274 return;
1275
1276 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001277 for (; cfg->nid; cfg++)
1278 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001279}
1280
1281/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001282 * ALC888
1283 */
1284
1285/*
1286 * 2ch mode
1287 */
1288static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1289/* Mic-in jack as mic in */
1290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1292/* Line-in jack as Line in */
1293 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1294 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1295/* Line-Out as Front */
1296 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1297 { } /* end */
1298};
1299
1300/*
1301 * 4ch mode
1302 */
1303static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1304/* Mic-in jack as mic in */
1305 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1306 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1307/* Line-in jack as Surround */
1308 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1309 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1310/* Line-Out as Front */
1311 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1312 { } /* end */
1313};
1314
1315/*
1316 * 6ch mode
1317 */
1318static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1319/* Mic-in jack as CLFE */
1320 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1321 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1322/* Line-in jack as Surround */
1323 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1324 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1325/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1326 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1327 { } /* end */
1328};
1329
1330/*
1331 * 8ch mode
1332 */
1333static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1334/* Mic-in jack as CLFE */
1335 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1336 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1337/* Line-in jack as Surround */
1338 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1339 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1340/* Line-Out as Side */
1341 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1342 { } /* end */
1343};
1344
1345static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1346 { 2, alc888_4ST_ch2_intel_init },
1347 { 4, alc888_4ST_ch4_intel_init },
1348 { 6, alc888_4ST_ch6_intel_init },
1349 { 8, alc888_4ST_ch8_intel_init },
1350};
1351
1352/*
1353 * ALC888 Fujitsu Siemens Amillo xa3530
1354 */
1355
1356static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1357/* Front Mic: set to PIN_IN (empty by default) */
1358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1359/* Connect Internal HP to Front */
1360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1363/* Connect Bass HP to Front */
1364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1367/* Connect Line-Out side jack (SPDIF) to Side */
1368 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1370 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1371/* Connect Mic jack to CLFE */
1372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1374 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1375/* Connect Line-in jack to Surround */
1376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1378 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1379/* Connect HP out jack to Front */
1380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1383/* Enable unsolicited event for HP jack and Line-out jack */
1384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1385 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1386 {}
1387};
1388
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001389static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001390{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001391 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001392 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001393 hda_nid_t nid;
1394 int i;
1395
1396 spec->jack_present = 0;
1397 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1398 nid = spec->autocfg.hp_pins[i];
1399 if (!nid)
1400 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001401 pincap = snd_hda_query_pin_caps(codec, nid);
1402 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1403 snd_hda_codec_read(codec, nid, 0,
1404 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001405 val = snd_hda_codec_read(codec, nid, 0,
1406 AC_VERB_GET_PIN_SENSE, 0);
1407 if (val & AC_PINSENSE_PRESENCE) {
1408 spec->jack_present = 1;
1409 break;
1410 }
1411 }
1412
1413 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001414 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001415 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1416 nid = spec->autocfg.speaker_pins[i];
1417 if (!nid)
1418 break;
1419 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1420 HDA_AMP_MUTE, mute);
1421 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001422}
1423
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001424static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1425 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001426{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001427 if (codec->vendor_id == 0x10ec0880)
1428 res >>= 28;
1429 else
1430 res >>= 26;
1431 if (res == ALC880_HP_EVENT)
1432 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001433}
1434
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001435static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1436{
1437 struct alc_spec *spec = codec->spec;
1438
1439 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1440 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1441 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1442 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1443 alc_automute_amp(codec);
1444}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001445
1446/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001447 * ALC888 Acer Aspire 4930G model
1448 */
1449
1450static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1451/* Front Mic: set to PIN_IN (empty by default) */
1452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1453/* Unselect Front Mic by default in input mixer 3 */
1454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001455/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001456 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1457/* Connect Internal HP to front */
1458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1461/* Connect HP out to front */
1462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1465 { }
1466};
1467
Hector Martin3b315d72009-06-02 10:54:19 +02001468/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001469 * ALC888 Acer Aspire 6530G model
1470 */
1471
1472static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1473/* Bias voltage on for external mic port */
1474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001475/* Front Mic: set to PIN_IN (empty by default) */
1476 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1477/* Unselect Front Mic by default in input mixer 3 */
1478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001479/* Enable unsolicited event for HP jack */
1480 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1481/* Enable speaker output */
1482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484/* Enable headphone output */
1485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1488 { }
1489};
1490
1491/*
Hector Martin018df412009-06-04 00:13:40 +02001492 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001493 */
1494
Hector Martin018df412009-06-04 00:13:40 +02001495static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001496/* Front Mic: set to PIN_IN (empty by default) */
1497 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1498/* Unselect Front Mic by default in input mixer 3 */
1499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1500/* Enable unsolicited event for HP jack */
1501 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1502/* Connect Internal Front to Front */
1503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1505 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1506/* Connect Internal Rear to Rear */
1507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1510/* Connect Internal CLFE to CLFE */
1511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1514/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1518/* Enable all DACs */
1519/* DAC DISABLE/MUTE 1? */
1520/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1521 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1522 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1523/* DAC DISABLE/MUTE 2? */
1524/* some bit here disables the other DACs. Init=0x4900 */
1525 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1526 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1527/* Enable amplifiers */
1528 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1529 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001530/* DMIC fix
1531 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1532 * which makes the stereo useless. However, either the mic or the ALC889
1533 * makes the signal become a difference/sum signal instead of standard
1534 * stereo, which is annoying. So instead we flip this bit which makes the
1535 * codec replicate the sum signal to both channels, turning it into a
1536 * normal mono mic.
1537 */
1538/* DMIC_CONTROL? Init value = 0x0001 */
1539 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1540 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001541 { }
1542};
1543
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001544static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001545 /* Front mic only available on one ADC */
1546 {
1547 .num_items = 4,
1548 .items = {
1549 { "Mic", 0x0 },
1550 { "Line", 0x2 },
1551 { "CD", 0x4 },
1552 { "Front Mic", 0xb },
1553 },
1554 },
1555 {
1556 .num_items = 3,
1557 .items = {
1558 { "Mic", 0x0 },
1559 { "Line", 0x2 },
1560 { "CD", 0x4 },
1561 },
1562 }
1563};
1564
Tony Vroond2fd4b02009-06-21 00:40:10 +01001565static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1566 /* Interal mic only available on one ADC */
1567 {
Tony Vroon684a8842009-06-26 09:27:50 +01001568 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001569 .items = {
1570 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001571 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001572 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001573 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001574 { "Int Mic", 0xb },
1575 },
1576 },
1577 {
Tony Vroon684a8842009-06-26 09:27:50 +01001578 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001579 .items = {
1580 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001581 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001582 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001583 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001584 },
1585 }
1586};
1587
Hector Martin018df412009-06-04 00:13:40 +02001588static struct hda_input_mux alc889_capture_sources[3] = {
1589 /* Digital mic only available on first "ADC" */
1590 {
1591 .num_items = 5,
1592 .items = {
1593 { "Mic", 0x0 },
1594 { "Line", 0x2 },
1595 { "CD", 0x4 },
1596 { "Front Mic", 0xb },
1597 { "Input Mix", 0xa },
1598 },
1599 },
1600 {
1601 .num_items = 4,
1602 .items = {
1603 { "Mic", 0x0 },
1604 { "Line", 0x2 },
1605 { "CD", 0x4 },
1606 { "Input Mix", 0xa },
1607 },
1608 },
1609 {
1610 .num_items = 4,
1611 .items = {
1612 { "Mic", 0x0 },
1613 { "Line", 0x2 },
1614 { "CD", 0x4 },
1615 { "Input Mix", 0xa },
1616 },
1617 }
1618};
1619
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001620static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1624 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1626 HDA_OUTPUT),
1627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1630 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1631 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001639 { } /* end */
1640};
1641
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001642static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001644 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001645
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001646 spec->autocfg.hp_pins[0] = 0x15;
1647 spec->autocfg.speaker_pins[0] = 0x14;
1648 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001649}
1650
Emilio López320d5922009-06-25 08:18:44 +02001651static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1652{
1653 struct alc_spec *spec = codec->spec;
1654
1655 spec->autocfg.hp_pins[0] = 0x15;
1656 spec->autocfg.speaker_pins[0] = 0x14;
1657 spec->autocfg.speaker_pins[1] = 0x16;
1658 spec->autocfg.speaker_pins[2] = 0x17;
1659 alc_automute_amp(codec);
1660}
1661
Hector Martin018df412009-06-04 00:13:40 +02001662static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001663{
1664 struct alc_spec *spec = codec->spec;
1665
1666 spec->autocfg.hp_pins[0] = 0x15;
1667 spec->autocfg.speaker_pins[0] = 0x14;
1668 spec->autocfg.speaker_pins[1] = 0x16;
1669 spec->autocfg.speaker_pins[2] = 0x1b;
1670 alc_automute_amp(codec);
1671}
1672
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001673/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001674 * ALC880 3-stack model
1675 *
1676 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001677 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1678 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679 */
1680
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001681static hda_nid_t alc880_dac_nids[4] = {
1682 /* front, rear, clfe, rear_surr */
1683 0x02, 0x05, 0x04, 0x03
1684};
1685
1686static hda_nid_t alc880_adc_nids[3] = {
1687 /* ADC0-2 */
1688 0x07, 0x08, 0x09,
1689};
1690
1691/* The datasheet says the node 0x07 is connected from inputs,
1692 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001693 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001695static hda_nid_t alc880_adc_nids_alt[2] = {
1696 /* ADC1-2 */
1697 0x08, 0x09,
1698};
1699
1700#define ALC880_DIGOUT_NID 0x06
1701#define ALC880_DIGIN_NID 0x0a
1702
1703static struct hda_input_mux alc880_capture_source = {
1704 .num_items = 4,
1705 .items = {
1706 { "Mic", 0x0 },
1707 { "Front Mic", 0x3 },
1708 { "Line", 0x2 },
1709 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001711};
1712
1713/* channel source setting (2/6 channel selection for 3-stack) */
1714/* 2ch mode */
1715static struct hda_verb alc880_threestack_ch2_init[] = {
1716 /* set line-in to input, mute it */
1717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1719 /* set mic-in to input vref 80%, mute it */
1720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 { } /* end */
1723};
1724
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001725/* 6ch mode */
1726static struct hda_verb alc880_threestack_ch6_init[] = {
1727 /* set line-in to output, unmute it */
1728 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1729 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1730 /* set mic-in to output, unmute it */
1731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1733 { } /* end */
1734};
1735
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001736static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001737 { 2, alc880_threestack_ch2_init },
1738 { 6, alc880_threestack_ch6_init },
1739};
1740
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001741static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001742 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001743 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001745 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001746 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1747 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001748 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1749 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1751 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1753 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1755 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001759 {
1760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1761 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001762 .info = alc_ch_mode_info,
1763 .get = alc_ch_mode_get,
1764 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765 },
1766 { } /* end */
1767};
1768
1769/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001770static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1771 struct snd_ctl_elem_info *uinfo)
1772{
1773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1774 struct alc_spec *spec = codec->spec;
1775 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001777 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001778 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1779 HDA_INPUT);
1780 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001781 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001782 return err;
1783}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001785static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1786 unsigned int size, unsigned int __user *tlv)
1787{
1788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1789 struct alc_spec *spec = codec->spec;
1790 int err;
1791
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001792 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001793 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1794 HDA_INPUT);
1795 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001796 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001797 return err;
1798}
1799
1800typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol);
1802
1803static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1804 struct snd_ctl_elem_value *ucontrol,
1805 getput_call_t func)
1806{
1807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1808 struct alc_spec *spec = codec->spec;
1809 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1810 int err;
1811
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001812 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001813 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1814 3, 0, HDA_INPUT);
1815 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001816 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001817 return err;
1818}
1819
1820static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1821 struct snd_ctl_elem_value *ucontrol)
1822{
1823 return alc_cap_getput_caller(kcontrol, ucontrol,
1824 snd_hda_mixer_amp_volume_get);
1825}
1826
1827static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1828 struct snd_ctl_elem_value *ucontrol)
1829{
1830 return alc_cap_getput_caller(kcontrol, ucontrol,
1831 snd_hda_mixer_amp_volume_put);
1832}
1833
1834/* capture mixer elements */
1835#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1836
1837static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1838 struct snd_ctl_elem_value *ucontrol)
1839{
1840 return alc_cap_getput_caller(kcontrol, ucontrol,
1841 snd_hda_mixer_amp_switch_get);
1842}
1843
1844static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1845 struct snd_ctl_elem_value *ucontrol)
1846{
1847 return alc_cap_getput_caller(kcontrol, ucontrol,
1848 snd_hda_mixer_amp_switch_put);
1849}
1850
Takashi Iwaia23b6882009-03-23 15:21:36 +01001851#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001852 { \
1853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1854 .name = "Capture Switch", \
1855 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1856 .count = num, \
1857 .info = alc_cap_sw_info, \
1858 .get = alc_cap_sw_get, \
1859 .put = alc_cap_sw_put, \
1860 }, \
1861 { \
1862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1863 .name = "Capture Volume", \
1864 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1865 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1866 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1867 .count = num, \
1868 .info = alc_cap_vol_info, \
1869 .get = alc_cap_vol_get, \
1870 .put = alc_cap_vol_put, \
1871 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001872 }
1873
1874#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001875 { \
1876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1877 /* .name = "Capture Source", */ \
1878 .name = "Input Source", \
1879 .count = num, \
1880 .info = alc_mux_enum_info, \
1881 .get = alc_mux_enum_get, \
1882 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001883 }
1884
1885#define DEFINE_CAPMIX(num) \
1886static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1887 _DEFINE_CAPMIX(num), \
1888 _DEFINE_CAPSRC(num), \
1889 { } /* end */ \
1890}
1891
1892#define DEFINE_CAPMIX_NOSRC(num) \
1893static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1894 _DEFINE_CAPMIX(num), \
1895 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001896}
1897
1898/* up to three ADCs */
1899DEFINE_CAPMIX(1);
1900DEFINE_CAPMIX(2);
1901DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001902DEFINE_CAPMIX_NOSRC(1);
1903DEFINE_CAPMIX_NOSRC(2);
1904DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001905
1906/*
1907 * ALC880 5-stack model
1908 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001909 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1910 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1912 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1913 */
1914
1915/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001916static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001917 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001918 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 { } /* end */
1920};
1921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001922/* channel source setting (6/8 channel selection for 5-stack) */
1923/* 6ch mode */
1924static struct hda_verb alc880_fivestack_ch6_init[] = {
1925 /* set line-in to input, mute it */
1926 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1927 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001928 { } /* end */
1929};
1930
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931/* 8ch mode */
1932static struct hda_verb alc880_fivestack_ch8_init[] = {
1933 /* set line-in to output, unmute it */
1934 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1935 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1936 { } /* end */
1937};
1938
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001939static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001940 { 6, alc880_fivestack_ch6_init },
1941 { 8, alc880_fivestack_ch8_init },
1942};
1943
1944
1945/*
1946 * ALC880 6-stack model
1947 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001948 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1949 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001950 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1951 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1952 */
1953
1954static hda_nid_t alc880_6st_dac_nids[4] = {
1955 /* front, rear, clfe, rear_surr */
1956 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001957};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001958
1959static struct hda_input_mux alc880_6stack_capture_source = {
1960 .num_items = 4,
1961 .items = {
1962 { "Mic", 0x0 },
1963 { "Front Mic", 0x1 },
1964 { "Line", 0x2 },
1965 { "CD", 0x4 },
1966 },
1967};
1968
1969/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001970static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001971 { 8, NULL },
1972};
1973
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001974static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001977 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001978 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001979 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001993 {
1994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1995 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001996 .info = alc_ch_mode_info,
1997 .get = alc_ch_mode_get,
1998 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001999 },
2000 { } /* end */
2001};
2002
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002003
2004/*
2005 * ALC880 W810 model
2006 *
2007 * W810 has rear IO for:
2008 * Front (DAC 02)
2009 * Surround (DAC 03)
2010 * Center/LFE (DAC 04)
2011 * Digital out (06)
2012 *
2013 * The system also has a pair of internal speakers, and a headphone jack.
2014 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002015 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 * There is a variable resistor to control the speaker or headphone
2017 * volume. This is a hardware-only device without a software API.
2018 *
2019 * Plugging headphones in will disable the internal speakers. This is
2020 * implemented in hardware, not via the driver using jack sense. In
2021 * a similar fashion, plugging into the rear socket marked "front" will
2022 * disable both the speakers and headphones.
2023 *
2024 * For input, there's a microphone jack, and an "audio in" jack.
2025 * These may not do anything useful with this driver yet, because I
2026 * haven't setup any initialization verbs for these yet...
2027 */
2028
2029static hda_nid_t alc880_w810_dac_nids[3] = {
2030 /* front, rear/surround, clfe */
2031 0x02, 0x03, 0x04
2032};
2033
2034/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002035static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002036 { 6, NULL }
2037};
2038
2039/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002040static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2050 { } /* end */
2051};
2052
2053
2054/*
2055 * Z710V model
2056 *
2057 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002058 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2059 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060 */
2061
2062static hda_nid_t alc880_z71v_dac_nids[1] = {
2063 0x02
2064};
2065#define ALC880_Z71V_HP_DAC 0x03
2066
2067/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002068static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 { 2, NULL }
2070};
2071
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002072static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 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 { } /* end */
2082};
2083
2084
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002085/*
2086 * ALC880 F1734 model
2087 *
2088 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2089 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2090 */
2091
2092static hda_nid_t alc880_f1734_dac_nids[1] = {
2093 0x03
2094};
2095#define ALC880_F1734_HP_DAC 0x02
2096
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002097static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002099 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002106 { } /* end */
2107};
2108
Takashi Iwai937b4162008-02-11 14:52:36 +01002109static struct hda_input_mux alc880_f1734_capture_source = {
2110 .num_items = 2,
2111 .items = {
2112 { "Mic", 0x1 },
2113 { "CD", 0x4 },
2114 },
2115};
2116
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002118/*
2119 * ALC880 ASUS model
2120 *
2121 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2122 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2123 * Mic = 0x18, Line = 0x1a
2124 */
2125
2126#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2127#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2128
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002129static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002144 {
2145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2146 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002147 .info = alc_ch_mode_info,
2148 .get = alc_ch_mode_get,
2149 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002150 },
2151 { } /* end */
2152};
2153
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002154/*
2155 * ALC880 ASUS W1V model
2156 *
2157 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2158 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2159 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2160 */
2161
2162/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002163static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002164 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2165 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002166 { } /* end */
2167};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168
Kailang Yangdf694da2005-12-05 19:42:22 +01002169/* TCL S700 */
2170static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2172 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2175 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2178 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2179 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002180 { } /* end */
2181};
2182
Kailang Yangccc656c2006-10-17 12:32:26 +02002183/* Uniwill */
2184static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002185 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2186 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2188 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002201 {
2202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2203 .name = "Channel Mode",
2204 .info = alc_ch_mode_info,
2205 .get = alc_ch_mode_get,
2206 .put = alc_ch_mode_put,
2207 },
2208 { } /* end */
2209};
2210
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002211static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2213 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2215 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2216 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2218 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2219 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2220 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2221 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2222 { } /* end */
2223};
2224
Kailang Yangccc656c2006-10-17 12:32:26 +02002225static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2232 { } /* end */
2233};
2234
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002236 * virtual master controls
2237 */
2238
2239/*
2240 * slave controls for virtual master
2241 */
2242static const char *alc_slave_vols[] = {
2243 "Front Playback Volume",
2244 "Surround Playback Volume",
2245 "Center Playback Volume",
2246 "LFE Playback Volume",
2247 "Side Playback Volume",
2248 "Headphone Playback Volume",
2249 "Speaker Playback Volume",
2250 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002251 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002252 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002253 NULL,
2254};
2255
2256static const char *alc_slave_sws[] = {
2257 "Front Playback Switch",
2258 "Surround Playback Switch",
2259 "Center Playback Switch",
2260 "LFE Playback Switch",
2261 "Side Playback Switch",
2262 "Headphone Playback Switch",
2263 "Speaker Playback Switch",
2264 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002265 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002266 NULL,
2267};
2268
2269/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002272
2273static void alc_free_kctls(struct hda_codec *codec);
2274
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002275/* additional beep mixers; the actual parameters are overwritten at build */
2276static struct snd_kcontrol_new alc_beep_mixer[] = {
2277 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2278 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2279 { } /* end */
2280};
2281
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282static int alc_build_controls(struct hda_codec *codec)
2283{
2284 struct alc_spec *spec = codec->spec;
2285 int err;
2286 int i;
2287
2288 for (i = 0; i < spec->num_mixers; i++) {
2289 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2290 if (err < 0)
2291 return err;
2292 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002293 if (spec->cap_mixer) {
2294 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2295 if (err < 0)
2296 return err;
2297 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002299 err = snd_hda_create_spdif_out_ctls(codec,
2300 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 if (err < 0)
2302 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002303 if (!spec->no_analog) {
2304 err = snd_hda_create_spdif_share_sw(codec,
2305 &spec->multiout);
2306 if (err < 0)
2307 return err;
2308 spec->multiout.share_spdif = 1;
2309 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 }
2311 if (spec->dig_in_nid) {
2312 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2313 if (err < 0)
2314 return err;
2315 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002316
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002317 /* create beep controls if needed */
2318 if (spec->beep_amp) {
2319 struct snd_kcontrol_new *knew;
2320 for (knew = alc_beep_mixer; knew->name; knew++) {
2321 struct snd_kcontrol *kctl;
2322 kctl = snd_ctl_new1(knew, codec);
2323 if (!kctl)
2324 return -ENOMEM;
2325 kctl->private_value = spec->beep_amp;
2326 err = snd_hda_ctl_add(codec, kctl);
2327 if (err < 0)
2328 return err;
2329 }
2330 }
2331
Takashi Iwai2134ea42008-01-10 16:53:55 +01002332 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002333 if (!spec->no_analog &&
2334 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002335 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002336 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002337 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002338 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002339 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002340 if (err < 0)
2341 return err;
2342 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002343 if (!spec->no_analog &&
2344 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002345 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2346 NULL, alc_slave_sws);
2347 if (err < 0)
2348 return err;
2349 }
2350
Takashi Iwai603c4012008-07-30 15:01:44 +02002351 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002352 return 0;
2353}
2354
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002355
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356/*
2357 * initialize the codec volumes, etc
2358 */
2359
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002360/*
2361 * generic initialization of ADC, input mixers and output mixers
2362 */
2363static struct hda_verb alc880_volume_init_verbs[] = {
2364 /*
2365 * Unmute ADC0-2 and set the default input to mic-in
2366 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002367 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002371 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2375 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002376 * Note: PASD motherboards uses the Line In 2 as the input for front
2377 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002379 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002388 /*
2389 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002391 /* set vol=0 to output mixers */
2392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2396 /* set up input amps for analog loopback */
2397 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406
2407 { }
2408};
2409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002410/*
2411 * 3-stack pin configuration:
2412 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2413 */
2414static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2415 /*
2416 * preset connection lists of input pins
2417 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2418 */
2419 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2420 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2421 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2422
2423 /*
2424 * Set pin mode and muting
2425 */
2426 /* set front pin widgets 0x14 for output */
2427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2429 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2432 /* Mic2 (as headphone out) for HP output */
2433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2435 /* Line In pin widget for input */
2436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2438 /* Line2 (as front mic) pin widget for input and vref at 80% */
2439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2440 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2441 /* CD pin widget for input */
2442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2443
2444 { }
2445};
2446
2447/*
2448 * 5-stack pin configuration:
2449 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2450 * line-in/side = 0x1a, f-mic = 0x1b
2451 */
2452static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2453 /*
2454 * preset connection lists of input pins
2455 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2456 */
2457 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2458 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2459
2460 /*
2461 * Set pin mode and muting
2462 */
2463 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002468 /* unmute pins for output (no gain on this amp) */
2469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2477 /* Mic2 (as headphone out) for HP output */
2478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 /* Line In pin widget for input */
2481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 /* Line2 (as front mic) pin widget for input and vref at 80% */
2484 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2486 /* CD pin widget for input */
2487 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488
2489 { }
2490};
2491
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492/*
2493 * W810 pin configuration:
2494 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2495 */
2496static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 /* hphone/speaker input selector: front DAC */
2498 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2499
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506
2507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 { }
2511};
2512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513/*
2514 * Z71V pin configuration:
2515 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2516 */
2517static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002522
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002527
2528 { }
2529};
2530
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531/*
2532 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002533 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2534 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 */
2536static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2537 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2538
Takashi Iwai16ded522005-06-10 19:58:24 +02002539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2547
Takashi Iwai16ded522005-06-10 19:58:24 +02002548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002550 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002555 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558 { }
2559};
Takashi Iwai16ded522005-06-10 19:58:24 +02002560
Kailang Yangccc656c2006-10-17 12:32:26 +02002561/*
2562 * Uniwill pin configuration:
2563 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2564 * line = 0x1a
2565 */
2566static struct hda_verb alc880_uniwill_init_verbs[] = {
2567 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2568
2569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2574 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2583
2584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2586 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2587 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2588 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2590 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2591 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2592 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2593
2594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2596
2597 { }
2598};
2599
2600/*
2601* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002602* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002603 */
2604static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2605 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2606
2607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2611 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2619
2620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626
2627 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2628 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2629
2630 { }
2631};
2632
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002633static struct hda_verb alc880_beep_init_verbs[] = {
2634 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2635 { }
2636};
2637
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002638/* auto-toggle front mic */
2639static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2640{
2641 unsigned int present;
2642 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002643
2644 present = snd_hda_codec_read(codec, 0x18, 0,
2645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002646 bits = present ? HDA_AMP_MUTE : 0;
2647 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002648}
2649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002650static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002651{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002652 struct alc_spec *spec = codec->spec;
2653
2654 spec->autocfg.hp_pins[0] = 0x14;
2655 spec->autocfg.speaker_pins[0] = 0x15;
2656 spec->autocfg.speaker_pins[0] = 0x16;
2657 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002658 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002659}
2660
2661static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2662 unsigned int res)
2663{
2664 /* Looks like the unsol event is incompatible with the standard
2665 * definition. 4bit tag is placed at 28 bit!
2666 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002667 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002668 case ALC880_MIC_EVENT:
2669 alc880_uniwill_mic_automute(codec);
2670 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002671 default:
2672 alc_automute_amp_unsol_event(codec, res);
2673 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002674 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002675}
2676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002677static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002678{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002679 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002680
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002681 spec->autocfg.hp_pins[0] = 0x14;
2682 spec->autocfg.speaker_pins[0] = 0x15;
2683 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002684}
2685
2686static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2687{
2688 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002689
Kailang Yangccc656c2006-10-17 12:32:26 +02002690 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002691 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2692 present &= HDA_AMP_VOLMASK;
2693 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2694 HDA_AMP_VOLMASK, present);
2695 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2696 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002697}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002698
Kailang Yangccc656c2006-10-17 12:32:26 +02002699static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2700 unsigned int res)
2701{
2702 /* Looks like the unsol event is incompatible with the standard
2703 * definition. 4bit tag is placed at 28 bit!
2704 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002705 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002706 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002707 else
2708 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002709}
2710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711/*
2712 * F1734 pin configuration:
2713 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2714 */
2715static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002716 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2718 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2719 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2720 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2721
2722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2726
2727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2734 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002736
Takashi Iwai937b4162008-02-11 14:52:36 +01002737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2738 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2739
Takashi Iwai16ded522005-06-10 19:58:24 +02002740 { }
2741};
2742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743/*
2744 * ASUS pin configuration:
2745 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2746 */
2747static struct hda_verb alc880_pin_asus_init_verbs[] = {
2748 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2749 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2750 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2752
2753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2761
2762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002771
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 { }
2773};
2774
2775/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002776#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2777#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002778#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779
Kailang Yangdf694da2005-12-05 19:42:22 +01002780/* Clevo m520g init */
2781static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2782 /* headphone output */
2783 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2784 /* line-out */
2785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2787 /* Line-in */
2788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2789 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2790 /* CD */
2791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2792 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2793 /* Mic1 (rear panel) */
2794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2796 /* Mic2 (front panel) */
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2799 /* headphone */
2800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2802 /* change to EAPD mode */
2803 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2804 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2805
2806 { }
2807};
2808
2809static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002810 /* change to EAPD mode */
2811 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2812 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2813
Kailang Yangdf694da2005-12-05 19:42:22 +01002814 /* Headphone output */
2815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2816 /* Front output*/
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2818 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2819
2820 /* Line In pin widget for input */
2821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2822 /* CD pin widget for input */
2823 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2825 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2826
2827 /* change to EAPD mode */
2828 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2829 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2830
2831 { }
2832};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833
2834/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002835 * LG m1 express dual
2836 *
2837 * Pin assignment:
2838 * Rear Line-In/Out (blue): 0x14
2839 * Build-in Mic-In: 0x15
2840 * Speaker-out: 0x17
2841 * HP-Out (green): 0x1b
2842 * Mic-In/Out (red): 0x19
2843 * SPDIF-Out: 0x1e
2844 */
2845
2846/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2847static hda_nid_t alc880_lg_dac_nids[3] = {
2848 0x05, 0x02, 0x03
2849};
2850
2851/* seems analog CD is not working */
2852static struct hda_input_mux alc880_lg_capture_source = {
2853 .num_items = 3,
2854 .items = {
2855 { "Mic", 0x1 },
2856 { "Line", 0x5 },
2857 { "Internal Mic", 0x6 },
2858 },
2859};
2860
2861/* 2,4,6 channel modes */
2862static struct hda_verb alc880_lg_ch2_init[] = {
2863 /* set line-in and mic-in to input */
2864 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2866 { }
2867};
2868
2869static struct hda_verb alc880_lg_ch4_init[] = {
2870 /* set line-in to out and mic-in to input */
2871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2872 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2873 { }
2874};
2875
2876static struct hda_verb alc880_lg_ch6_init[] = {
2877 /* set line-in and mic-in to output */
2878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2879 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2880 { }
2881};
2882
2883static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2884 { 2, alc880_lg_ch2_init },
2885 { 4, alc880_lg_ch4_init },
2886 { 6, alc880_lg_ch6_init },
2887};
2888
2889static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002890 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2891 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002892 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2893 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2896 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2897 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2902 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2903 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2904 {
2905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2906 .name = "Channel Mode",
2907 .info = alc_ch_mode_info,
2908 .get = alc_ch_mode_get,
2909 .put = alc_ch_mode_put,
2910 },
2911 { } /* end */
2912};
2913
2914static struct hda_verb alc880_lg_init_verbs[] = {
2915 /* set capture source to mic-in */
2916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2919 /* mute all amp mixer inputs */
2920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002923 /* line-in to input */
2924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* built-in mic */
2927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 /* speaker-out */
2930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* mic-in to input */
2933 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* HP-out */
2937 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002942 { }
2943};
2944
2945/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002946static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002947{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002948 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002949
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002950 spec->autocfg.hp_pins[0] = 0x1b;
2951 spec->autocfg.speaker_pins[0] = 0x17;
2952 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002953}
2954
2955/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002956 * LG LW20
2957 *
2958 * Pin assignment:
2959 * Speaker-out: 0x14
2960 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002961 * Built-in Mic-In: 0x19
2962 * Line-In: 0x1b
2963 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002964 * SPDIF-Out: 0x1e
2965 */
2966
Takashi Iwaid6815182006-03-23 16:06:23 +01002967static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002968 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002969 .items = {
2970 { "Mic", 0x0 },
2971 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002972 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002973 },
2974};
2975
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002976#define alc880_lg_lw_modes alc880_threestack_modes
2977
Takashi Iwaid6815182006-03-23 16:06:23 +01002978static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2982 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2992 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002993 {
2994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2995 .name = "Channel Mode",
2996 .info = alc_ch_mode_info,
2997 .get = alc_ch_mode_get,
2998 .put = alc_ch_mode_put,
2999 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003000 { } /* end */
3001};
3002
3003static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003004 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3007
Takashi Iwaid6815182006-03-23 16:06:23 +01003008 /* set capture source to mic-in */
3009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003013 /* speaker-out */
3014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3016 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 /* mic-in to input */
3020 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3021 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3022 /* built-in mic */
3023 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003026 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003027 { }
3028};
3029
3030/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003031static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003032{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003033 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003034
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003035 spec->autocfg.hp_pins[0] = 0x1b;
3036 spec->autocfg.speaker_pins[0] = 0x14;
3037 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003038}
3039
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003040static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3041 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3042 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3045 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3046 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3047 { } /* end */
3048};
3049
3050static struct hda_input_mux alc880_medion_rim_capture_source = {
3051 .num_items = 2,
3052 .items = {
3053 { "Mic", 0x0 },
3054 { "Internal Mic", 0x1 },
3055 },
3056};
3057
3058static struct hda_verb alc880_medion_rim_init_verbs[] = {
3059 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3060
3061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063
3064 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3067 /* Mic2 (as headphone out) for HP output */
3068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 /* Internal Speaker */
3071 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3072 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073
3074 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3075 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3076
3077 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3078 { }
3079};
3080
3081/* toggle speaker-output according to the hp-jack state */
3082static void alc880_medion_rim_automute(struct hda_codec *codec)
3083{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003084 struct alc_spec *spec = codec->spec;
3085 alc_automute_amp(codec);
3086 /* toggle EAPD */
3087 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003088 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3089 else
3090 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3091}
3092
3093static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3094 unsigned int res)
3095{
3096 /* Looks like the unsol event is incompatible with the standard
3097 * definition. 4bit tag is placed at 28 bit!
3098 */
3099 if ((res >> 28) == ALC880_HP_EVENT)
3100 alc880_medion_rim_automute(codec);
3101}
3102
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003103static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3104{
3105 struct alc_spec *spec = codec->spec;
3106
3107 spec->autocfg.hp_pins[0] = 0x14;
3108 spec->autocfg.speaker_pins[0] = 0x1b;
3109 alc880_medion_rim_automute(codec);
3110}
3111
Takashi Iwaicb53c622007-08-10 17:21:45 +02003112#ifdef CONFIG_SND_HDA_POWER_SAVE
3113static struct hda_amp_list alc880_loopbacks[] = {
3114 { 0x0b, HDA_INPUT, 0 },
3115 { 0x0b, HDA_INPUT, 1 },
3116 { 0x0b, HDA_INPUT, 2 },
3117 { 0x0b, HDA_INPUT, 3 },
3118 { 0x0b, HDA_INPUT, 4 },
3119 { } /* end */
3120};
3121
3122static struct hda_amp_list alc880_lg_loopbacks[] = {
3123 { 0x0b, HDA_INPUT, 1 },
3124 { 0x0b, HDA_INPUT, 6 },
3125 { 0x0b, HDA_INPUT, 7 },
3126 { } /* end */
3127};
3128#endif
3129
Takashi Iwaid6815182006-03-23 16:06:23 +01003130/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003131 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003133
Linus Torvalds1da177e2005-04-16 15:20:36 -07003134static int alc_init(struct hda_codec *codec)
3135{
3136 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 unsigned int i;
3138
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003139 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003140 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142 for (i = 0; i < spec->num_init_verbs; i++)
3143 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003144
3145 if (spec->init_hook)
3146 spec->init_hook(codec);
3147
Linus Torvalds1da177e2005-04-16 15:20:36 -07003148 return 0;
3149}
3150
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003151static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3152{
3153 struct alc_spec *spec = codec->spec;
3154
3155 if (spec->unsol_event)
3156 spec->unsol_event(codec, res);
3157}
3158
Takashi Iwaicb53c622007-08-10 17:21:45 +02003159#ifdef CONFIG_SND_HDA_POWER_SAVE
3160static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3161{
3162 struct alc_spec *spec = codec->spec;
3163 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3164}
3165#endif
3166
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167/*
3168 * Analog playback callbacks
3169 */
3170static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3171 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003172 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173{
3174 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003175 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3176 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177}
3178
3179static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3180 struct hda_codec *codec,
3181 unsigned int stream_tag,
3182 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003183 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003184{
3185 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003186 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3187 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188}
3189
3190static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3191 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003192 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003193{
3194 struct alc_spec *spec = codec->spec;
3195 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3196}
3197
3198/*
3199 * Digital out
3200 */
3201static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3202 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003203 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204{
3205 struct alc_spec *spec = codec->spec;
3206 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3207}
3208
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003209static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3210 struct hda_codec *codec,
3211 unsigned int stream_tag,
3212 unsigned int format,
3213 struct snd_pcm_substream *substream)
3214{
3215 struct alc_spec *spec = codec->spec;
3216 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3217 stream_tag, format, substream);
3218}
3219
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003220static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3221 struct hda_codec *codec,
3222 struct snd_pcm_substream *substream)
3223{
3224 struct alc_spec *spec = codec->spec;
3225 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3226}
3227
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3229 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003230 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003231{
3232 struct alc_spec *spec = codec->spec;
3233 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3234}
3235
3236/*
3237 * Analog capture
3238 */
Takashi Iwai63300792008-01-24 15:31:36 +01003239static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240 struct hda_codec *codec,
3241 unsigned int stream_tag,
3242 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003243 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244{
3245 struct alc_spec *spec = codec->spec;
3246
Takashi Iwai63300792008-01-24 15:31:36 +01003247 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248 stream_tag, 0, format);
3249 return 0;
3250}
3251
Takashi Iwai63300792008-01-24 15:31:36 +01003252static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003253 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003254 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255{
3256 struct alc_spec *spec = codec->spec;
3257
Takashi Iwai888afa12008-03-18 09:57:50 +01003258 snd_hda_codec_cleanup_stream(codec,
3259 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003260 return 0;
3261}
3262
3263
3264/*
3265 */
3266static struct hda_pcm_stream alc880_pcm_analog_playback = {
3267 .substreams = 1,
3268 .channels_min = 2,
3269 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003271 .ops = {
3272 .open = alc880_playback_pcm_open,
3273 .prepare = alc880_playback_pcm_prepare,
3274 .cleanup = alc880_playback_pcm_cleanup
3275 },
3276};
3277
3278static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003279 .substreams = 1,
3280 .channels_min = 2,
3281 .channels_max = 2,
3282 /* NID is set in alc_build_pcms */
3283};
3284
3285static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3286 .substreams = 1,
3287 .channels_min = 2,
3288 .channels_max = 2,
3289 /* NID is set in alc_build_pcms */
3290};
3291
3292static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3293 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003294 .channels_min = 2,
3295 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003296 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003297 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003298 .prepare = alc880_alt_capture_pcm_prepare,
3299 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003300 },
3301};
3302
3303static struct hda_pcm_stream alc880_pcm_digital_playback = {
3304 .substreams = 1,
3305 .channels_min = 2,
3306 .channels_max = 2,
3307 /* NID is set in alc_build_pcms */
3308 .ops = {
3309 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003310 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003311 .prepare = alc880_dig_playback_pcm_prepare,
3312 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313 },
3314};
3315
3316static struct hda_pcm_stream alc880_pcm_digital_capture = {
3317 .substreams = 1,
3318 .channels_min = 2,
3319 .channels_max = 2,
3320 /* NID is set in alc_build_pcms */
3321};
3322
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003323/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003324static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003325 .substreams = 0,
3326 .channels_min = 0,
3327 .channels_max = 0,
3328};
3329
Linus Torvalds1da177e2005-04-16 15:20:36 -07003330static int alc_build_pcms(struct hda_codec *codec)
3331{
3332 struct alc_spec *spec = codec->spec;
3333 struct hda_pcm *info = spec->pcm_rec;
3334 int i;
3335
3336 codec->num_pcms = 1;
3337 codec->pcm_info = info;
3338
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003339 if (spec->no_analog)
3340 goto skip_analog;
3341
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003342 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3343 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003344 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003345
Takashi Iwai4a471b72005-12-07 13:56:29 +01003346 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003347 if (snd_BUG_ON(!spec->multiout.dac_nids))
3348 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003349 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3350 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3351 }
3352 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003353 if (snd_BUG_ON(!spec->adc_nids))
3354 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003355 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3356 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3357 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003358
Takashi Iwai4a471b72005-12-07 13:56:29 +01003359 if (spec->channel_mode) {
3360 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3361 for (i = 0; i < spec->num_channel_mode; i++) {
3362 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3363 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3364 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365 }
3366 }
3367
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003368 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003369 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003370 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003371 snprintf(spec->stream_name_digital,
3372 sizeof(spec->stream_name_digital),
3373 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003374 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003375 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003376 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003378 if (spec->dig_out_type)
3379 info->pcm_type = spec->dig_out_type;
3380 else
3381 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003382 if (spec->multiout.dig_out_nid &&
3383 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003384 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3385 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3386 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003387 if (spec->dig_in_nid &&
3388 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3390 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3391 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003392 /* FIXME: do we need this for all Realtek codec models? */
3393 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394 }
3395
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003396 if (spec->no_analog)
3397 return 0;
3398
Takashi Iwaie08a0072006-09-07 17:52:14 +02003399 /* If the use of more than one ADC is requested for the current
3400 * model, configure a second analog capture-only PCM.
3401 */
3402 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003403 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3404 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003405 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003406 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003407 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003408 if (spec->alt_dac_nid) {
3409 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3410 *spec->stream_analog_alt_playback;
3411 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3412 spec->alt_dac_nid;
3413 } else {
3414 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3415 alc_pcm_null_stream;
3416 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3417 }
3418 if (spec->num_adc_nids > 1) {
3419 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3420 *spec->stream_analog_alt_capture;
3421 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3422 spec->adc_nids[1];
3423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3424 spec->num_adc_nids - 1;
3425 } else {
3426 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3427 alc_pcm_null_stream;
3428 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003429 }
3430 }
3431
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 return 0;
3433}
3434
Takashi Iwai603c4012008-07-30 15:01:44 +02003435static void alc_free_kctls(struct hda_codec *codec)
3436{
3437 struct alc_spec *spec = codec->spec;
3438
3439 if (spec->kctls.list) {
3440 struct snd_kcontrol_new *kctl = spec->kctls.list;
3441 int i;
3442 for (i = 0; i < spec->kctls.used; i++)
3443 kfree(kctl[i].name);
3444 }
3445 snd_array_free(&spec->kctls);
3446}
3447
Linus Torvalds1da177e2005-04-16 15:20:36 -07003448static void alc_free(struct hda_codec *codec)
3449{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003450 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003452 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003453 return;
3454
Takashi Iwai603c4012008-07-30 15:01:44 +02003455 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003456 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003457 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003458}
3459
Takashi Iwaie044c392008-10-27 16:56:24 +01003460#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003461static int alc_resume(struct hda_codec *codec)
3462{
Takashi Iwaie044c392008-10-27 16:56:24 +01003463 codec->patch_ops.init(codec);
3464 snd_hda_codec_resume_amp(codec);
3465 snd_hda_codec_resume_cache(codec);
3466 return 0;
3467}
Takashi Iwaie044c392008-10-27 16:56:24 +01003468#endif
3469
Linus Torvalds1da177e2005-04-16 15:20:36 -07003470/*
3471 */
3472static struct hda_codec_ops alc_patch_ops = {
3473 .build_controls = alc_build_controls,
3474 .build_pcms = alc_build_pcms,
3475 .init = alc_init,
3476 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003477 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003478#ifdef SND_HDA_NEEDS_RESUME
3479 .resume = alc_resume,
3480#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003481#ifdef CONFIG_SND_HDA_POWER_SAVE
3482 .check_power_status = alc_check_power_status,
3483#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484};
3485
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003486
3487/*
3488 * Test configuration for debugging
3489 *
3490 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3491 * enum controls.
3492 */
3493#ifdef CONFIG_SND_DEBUG
3494static hda_nid_t alc880_test_dac_nids[4] = {
3495 0x02, 0x03, 0x04, 0x05
3496};
3497
3498static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003499 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003500 .items = {
3501 { "In-1", 0x0 },
3502 { "In-2", 0x1 },
3503 { "In-3", 0x2 },
3504 { "In-4", 0x3 },
3505 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003506 { "Front", 0x5 },
3507 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003508 },
3509};
3510
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003511static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003513 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003514 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003515 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516};
3517
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003518static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3519 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003520{
3521 static char *texts[] = {
3522 "N/A", "Line Out", "HP Out",
3523 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3524 };
3525 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3526 uinfo->count = 1;
3527 uinfo->value.enumerated.items = 8;
3528 if (uinfo->value.enumerated.item >= 8)
3529 uinfo->value.enumerated.item = 7;
3530 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3531 return 0;
3532}
3533
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003534static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3535 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003536{
3537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3538 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3539 unsigned int pin_ctl, item = 0;
3540
3541 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3542 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3543 if (pin_ctl & AC_PINCTL_OUT_EN) {
3544 if (pin_ctl & AC_PINCTL_HP_EN)
3545 item = 2;
3546 else
3547 item = 1;
3548 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3549 switch (pin_ctl & AC_PINCTL_VREFEN) {
3550 case AC_PINCTL_VREF_HIZ: item = 3; break;
3551 case AC_PINCTL_VREF_50: item = 4; break;
3552 case AC_PINCTL_VREF_GRD: item = 5; break;
3553 case AC_PINCTL_VREF_80: item = 6; break;
3554 case AC_PINCTL_VREF_100: item = 7; break;
3555 }
3556 }
3557 ucontrol->value.enumerated.item[0] = item;
3558 return 0;
3559}
3560
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003561static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3562 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003563{
3564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3565 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3566 static unsigned int ctls[] = {
3567 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3568 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3569 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3570 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3571 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3572 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3573 };
3574 unsigned int old_ctl, new_ctl;
3575
3576 old_ctl = snd_hda_codec_read(codec, nid, 0,
3577 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3578 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3579 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003580 int val;
3581 snd_hda_codec_write_cache(codec, nid, 0,
3582 AC_VERB_SET_PIN_WIDGET_CONTROL,
3583 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003584 val = ucontrol->value.enumerated.item[0] >= 3 ?
3585 HDA_AMP_MUTE : 0;
3586 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3587 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003588 return 1;
3589 }
3590 return 0;
3591}
3592
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003593static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3594 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003595{
3596 static char *texts[] = {
3597 "Front", "Surround", "CLFE", "Side"
3598 };
3599 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3600 uinfo->count = 1;
3601 uinfo->value.enumerated.items = 4;
3602 if (uinfo->value.enumerated.item >= 4)
3603 uinfo->value.enumerated.item = 3;
3604 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3605 return 0;
3606}
3607
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003608static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3609 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003610{
3611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3612 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3613 unsigned int sel;
3614
3615 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3616 ucontrol->value.enumerated.item[0] = sel & 3;
3617 return 0;
3618}
3619
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003620static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3621 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003622{
3623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3624 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3625 unsigned int sel;
3626
3627 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3628 if (ucontrol->value.enumerated.item[0] != sel) {
3629 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003630 snd_hda_codec_write_cache(codec, nid, 0,
3631 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003632 return 1;
3633 }
3634 return 0;
3635}
3636
3637#define PIN_CTL_TEST(xname,nid) { \
3638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3639 .name = xname, \
3640 .info = alc_test_pin_ctl_info, \
3641 .get = alc_test_pin_ctl_get, \
3642 .put = alc_test_pin_ctl_put, \
3643 .private_value = nid \
3644 }
3645
3646#define PIN_SRC_TEST(xname,nid) { \
3647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3648 .name = xname, \
3649 .info = alc_test_pin_src_info, \
3650 .get = alc_test_pin_src_get, \
3651 .put = alc_test_pin_src_put, \
3652 .private_value = nid \
3653 }
3654
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003655static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003656 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3658 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3659 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003660 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3661 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3662 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3663 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003664 PIN_CTL_TEST("Front Pin Mode", 0x14),
3665 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3666 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3667 PIN_CTL_TEST("Side Pin Mode", 0x17),
3668 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3669 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3670 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3671 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3672 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3673 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3674 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3675 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3676 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3677 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3678 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3679 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3680 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3681 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3682 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3683 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003686 {
3687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3688 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003689 .info = alc_ch_mode_info,
3690 .get = alc_ch_mode_get,
3691 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003692 },
3693 { } /* end */
3694};
3695
3696static struct hda_verb alc880_test_init_verbs[] = {
3697 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003706 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003711 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3714 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3715 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003716 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003721 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003727 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3730 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003732 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003734 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003735 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003736 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003738 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003739 /* Analog input/passthru */
3740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003745 { }
3746};
3747#endif
3748
Linus Torvalds1da177e2005-04-16 15:20:36 -07003749/*
3750 */
3751
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003752static const char *alc880_models[ALC880_MODEL_LAST] = {
3753 [ALC880_3ST] = "3stack",
3754 [ALC880_TCL_S700] = "tcl",
3755 [ALC880_3ST_DIG] = "3stack-digout",
3756 [ALC880_CLEVO] = "clevo",
3757 [ALC880_5ST] = "5stack",
3758 [ALC880_5ST_DIG] = "5stack-digout",
3759 [ALC880_W810] = "w810",
3760 [ALC880_Z71V] = "z71v",
3761 [ALC880_6ST] = "6stack",
3762 [ALC880_6ST_DIG] = "6stack-digout",
3763 [ALC880_ASUS] = "asus",
3764 [ALC880_ASUS_W1V] = "asus-w1v",
3765 [ALC880_ASUS_DIG] = "asus-dig",
3766 [ALC880_ASUS_DIG2] = "asus-dig2",
3767 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003768 [ALC880_UNIWILL_P53] = "uniwill-p53",
3769 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003770 [ALC880_F1734] = "F1734",
3771 [ALC880_LG] = "lg",
3772 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003773 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003774#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003775 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003776#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003777 [ALC880_AUTO] = "auto",
3778};
3779
3780static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003781 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003782 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3783 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3784 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3785 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3786 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3787 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3788 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3789 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003790 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3791 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003792 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3793 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3794 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3795 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3796 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3797 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3798 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3799 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3800 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3801 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003802 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003803 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3804 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3805 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003806 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003808 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3809 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003810 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3811 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003812 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3813 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3814 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3815 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003816 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3817 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003818 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003819 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003820 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003821 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003822 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3823 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003824 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003825 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003826 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003827 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003828 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003829 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003830 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003831 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003832 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003833 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3834 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003835 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003836 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3837 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3838 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3839 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003840 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3841 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003842 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003843 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003844 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3845 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003846 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3847 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3848 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003849 /* default Intel */
3850 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003851 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3852 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003853 {}
3854};
3855
Takashi Iwai16ded522005-06-10 19:58:24 +02003856/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003857 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003858 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003859static struct alc_config_preset alc880_presets[] = {
3860 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003862 .init_verbs = { alc880_volume_init_verbs,
3863 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003864 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003865 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003866 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3867 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003868 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003869 .input_mux = &alc880_capture_source,
3870 },
3871 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003872 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003873 .init_verbs = { alc880_volume_init_verbs,
3874 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003875 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003876 .dac_nids = alc880_dac_nids,
3877 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003878 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3879 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003880 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003881 .input_mux = &alc880_capture_source,
3882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003883 [ALC880_TCL_S700] = {
3884 .mixers = { alc880_tcl_s700_mixer },
3885 .init_verbs = { alc880_volume_init_verbs,
3886 alc880_pin_tcl_S700_init_verbs,
3887 alc880_gpio2_init_verbs },
3888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3889 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003890 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3891 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003892 .hp_nid = 0x03,
3893 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3894 .channel_mode = alc880_2_jack_modes,
3895 .input_mux = &alc880_capture_source,
3896 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003897 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003898 .mixers = { alc880_three_stack_mixer,
3899 alc880_five_stack_mixer},
3900 .init_verbs = { alc880_volume_init_verbs,
3901 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003902 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3903 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003904 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3905 .channel_mode = alc880_fivestack_modes,
3906 .input_mux = &alc880_capture_source,
3907 },
3908 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003909 .mixers = { alc880_three_stack_mixer,
3910 alc880_five_stack_mixer },
3911 .init_verbs = { alc880_volume_init_verbs,
3912 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003913 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3914 .dac_nids = alc880_dac_nids,
3915 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003916 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3917 .channel_mode = alc880_fivestack_modes,
3918 .input_mux = &alc880_capture_source,
3919 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003920 [ALC880_6ST] = {
3921 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003922 .init_verbs = { alc880_volume_init_verbs,
3923 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003924 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3925 .dac_nids = alc880_6st_dac_nids,
3926 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3927 .channel_mode = alc880_sixstack_modes,
3928 .input_mux = &alc880_6stack_capture_source,
3929 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003930 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003931 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003932 .init_verbs = { alc880_volume_init_verbs,
3933 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003934 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3935 .dac_nids = alc880_6st_dac_nids,
3936 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003937 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3938 .channel_mode = alc880_sixstack_modes,
3939 .input_mux = &alc880_6stack_capture_source,
3940 },
3941 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003942 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003943 .init_verbs = { alc880_volume_init_verbs,
3944 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003945 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003946 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3947 .dac_nids = alc880_w810_dac_nids,
3948 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003949 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3950 .channel_mode = alc880_w810_modes,
3951 .input_mux = &alc880_capture_source,
3952 },
3953 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003954 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003955 .init_verbs = { alc880_volume_init_verbs,
3956 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003957 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3958 .dac_nids = alc880_z71v_dac_nids,
3959 .dig_out_nid = ALC880_DIGOUT_NID,
3960 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3962 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003963 .input_mux = &alc880_capture_source,
3964 },
3965 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003967 .init_verbs = { alc880_volume_init_verbs,
3968 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3970 .dac_nids = alc880_f1734_dac_nids,
3971 .hp_nid = 0x02,
3972 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3973 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003974 .input_mux = &alc880_f1734_capture_source,
3975 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003976 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 },
3978 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003979 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003980 .init_verbs = { alc880_volume_init_verbs,
3981 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003982 alc880_gpio1_init_verbs },
3983 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3984 .dac_nids = alc880_asus_dac_nids,
3985 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3986 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003987 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .input_mux = &alc880_capture_source,
3989 },
3990 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994 alc880_gpio1_init_verbs },
3995 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3996 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003997 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3999 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004000 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 .input_mux = &alc880_capture_source,
4002 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004003 [ALC880_ASUS_DIG2] = {
4004 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 alc880_gpio2_init_verbs }, /* use GPIO2 */
4008 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4009 .dac_nids = alc880_asus_dac_nids,
4010 .dig_out_nid = ALC880_DIGOUT_NID,
4011 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4012 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004013 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004014 .input_mux = &alc880_capture_source,
4015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004017 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004018 .init_verbs = { alc880_volume_init_verbs,
4019 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004020 alc880_gpio1_init_verbs },
4021 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4022 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4025 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004026 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004027 .input_mux = &alc880_capture_source,
4028 },
4029 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004030 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004031 .init_verbs = { alc880_volume_init_verbs,
4032 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004033 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4034 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004036 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4037 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004038 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004039 .input_mux = &alc880_capture_source,
4040 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004041 [ALC880_UNIWILL] = {
4042 .mixers = { alc880_uniwill_mixer },
4043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_uniwill_init_verbs },
4045 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4046 .dac_nids = alc880_asus_dac_nids,
4047 .dig_out_nid = ALC880_DIGOUT_NID,
4048 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4049 .channel_mode = alc880_threestack_modes,
4050 .need_dac_fix = 1,
4051 .input_mux = &alc880_capture_source,
4052 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004053 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004054 },
4055 [ALC880_UNIWILL_P53] = {
4056 .mixers = { alc880_uniwill_p53_mixer },
4057 .init_verbs = { alc880_volume_init_verbs,
4058 alc880_uniwill_p53_init_verbs },
4059 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4060 .dac_nids = alc880_asus_dac_nids,
4061 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004062 .channel_mode = alc880_threestack_modes,
4063 .input_mux = &alc880_capture_source,
4064 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004065 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004066 },
4067 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004068 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004069 .init_verbs = { alc880_volume_init_verbs,
4070 alc880_uniwill_p53_init_verbs,
4071 alc880_beep_init_verbs },
4072 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4073 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004074 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004075 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4076 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004077 .input_mux = &alc880_capture_source,
4078 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004079 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004080 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004081 [ALC880_CLEVO] = {
4082 .mixers = { alc880_three_stack_mixer },
4083 .init_verbs = { alc880_volume_init_verbs,
4084 alc880_pin_clevo_init_verbs },
4085 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4086 .dac_nids = alc880_dac_nids,
4087 .hp_nid = 0x03,
4088 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4089 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004090 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004091 .input_mux = &alc880_capture_source,
4092 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004093 [ALC880_LG] = {
4094 .mixers = { alc880_lg_mixer },
4095 .init_verbs = { alc880_volume_init_verbs,
4096 alc880_lg_init_verbs },
4097 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4098 .dac_nids = alc880_lg_dac_nids,
4099 .dig_out_nid = ALC880_DIGOUT_NID,
4100 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4101 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004102 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004103 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004104 .unsol_event = alc_automute_amp_unsol_event,
4105 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004106#ifdef CONFIG_SND_HDA_POWER_SAVE
4107 .loopbacks = alc880_lg_loopbacks,
4108#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004109 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004110 [ALC880_LG_LW] = {
4111 .mixers = { alc880_lg_lw_mixer },
4112 .init_verbs = { alc880_volume_init_verbs,
4113 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004114 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004115 .dac_nids = alc880_dac_nids,
4116 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004117 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4118 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004119 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004120 .unsol_event = alc_automute_amp_unsol_event,
4121 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004122 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004123 [ALC880_MEDION_RIM] = {
4124 .mixers = { alc880_medion_rim_mixer },
4125 .init_verbs = { alc880_volume_init_verbs,
4126 alc880_medion_rim_init_verbs,
4127 alc_gpio2_init_verbs },
4128 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4129 .dac_nids = alc880_dac_nids,
4130 .dig_out_nid = ALC880_DIGOUT_NID,
4131 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4132 .channel_mode = alc880_2_jack_modes,
4133 .input_mux = &alc880_medion_rim_capture_source,
4134 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004135 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004136 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004137#ifdef CONFIG_SND_DEBUG
4138 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 .mixers = { alc880_test_mixer },
4140 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004141 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4142 .dac_nids = alc880_test_dac_nids,
4143 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004144 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4145 .channel_mode = alc880_test_modes,
4146 .input_mux = &alc880_test_capture_source,
4147 },
4148#endif
4149};
4150
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151/*
4152 * Automatic parse of I/O pins from the BIOS configuration
4153 */
4154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155enum {
4156 ALC_CTL_WIDGET_VOL,
4157 ALC_CTL_WIDGET_MUTE,
4158 ALC_CTL_BIND_MUTE,
4159};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004160static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4162 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004163 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164};
4165
4166/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004167static int add_control(struct alc_spec *spec, int type, const char *name,
4168 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004170 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171
Takashi Iwai603c4012008-07-30 15:01:44 +02004172 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4173 knew = snd_array_new(&spec->kctls);
4174 if (!knew)
4175 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004176 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004177 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004178 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179 return -ENOMEM;
4180 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004181 return 0;
4182}
4183
4184#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4185#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4186#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4187#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4188#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4189#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4190#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4191#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4192#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4193#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4194#define ALC880_PIN_CD_NID 0x1c
4195
4196/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004197static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4198 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199{
4200 hda_nid_t nid;
4201 int assigned[4];
4202 int i, j;
4203
4204 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004205 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206
4207 /* check the pins hardwired to audio widget */
4208 for (i = 0; i < cfg->line_outs; i++) {
4209 nid = cfg->line_out_pins[i];
4210 if (alc880_is_fixed_pin(nid)) {
4211 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004212 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 assigned[idx] = 1;
4214 }
4215 }
4216 /* left pins can be connect to any audio widget */
4217 for (i = 0; i < cfg->line_outs; i++) {
4218 nid = cfg->line_out_pins[i];
4219 if (alc880_is_fixed_pin(nid))
4220 continue;
4221 /* search for an empty channel */
4222 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004223 if (!assigned[j]) {
4224 spec->multiout.dac_nids[i] =
4225 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004226 assigned[j] = 1;
4227 break;
4228 }
4229 }
4230 }
4231 spec->multiout.num_dacs = cfg->line_outs;
4232 return 0;
4233}
4234
4235/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004236static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4237 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004238{
4239 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004240 static const char *chname[4] = {
4241 "Front", "Surround", NULL /*CLFE*/, "Side"
4242 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004243 hda_nid_t nid;
4244 int i, err;
4245
4246 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004247 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 continue;
4249 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4250 if (i == 2) {
4251 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004252 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4253 "Center Playback Volume",
4254 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4255 HDA_OUTPUT));
4256 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004257 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004258 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4259 "LFE Playback Volume",
4260 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4261 HDA_OUTPUT));
4262 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004263 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004264 err = add_control(spec, ALC_CTL_BIND_MUTE,
4265 "Center Playback Switch",
4266 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4267 HDA_INPUT));
4268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004270 err = add_control(spec, ALC_CTL_BIND_MUTE,
4271 "LFE Playback Switch",
4272 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4273 HDA_INPUT));
4274 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004275 return err;
4276 } else {
4277 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004278 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4279 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4280 HDA_OUTPUT));
4281 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 return err;
4283 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004284 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4285 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4286 HDA_INPUT));
4287 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288 return err;
4289 }
4290 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291 return 0;
4292}
4293
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004294/* add playback controls for speaker and HP outputs */
4295static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4296 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297{
4298 hda_nid_t nid;
4299 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004300 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return 0;
4304
4305 if (alc880_is_fixed_pin(pin)) {
4306 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004307 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004308 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004310 else
4311 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312 /* control HP volume/switch on the output mixer amp */
4313 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004314 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4316 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4317 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004319 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004320 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4321 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4322 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323 return err;
4324 } else if (alc880_is_multi_pin(pin)) {
4325 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004327 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4329 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4330 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331 return err;
4332 }
4333 return 0;
4334}
4335
4336/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004337static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4338 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004339 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340{
4341 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343
4344 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004345 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4346 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4347 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 return err;
4349 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004350 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4351 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4352 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353 return err;
4354 return 0;
4355}
4356
4357/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004358static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4359 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004361 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004362 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363
4364 for (i = 0; i < AUTO_PIN_LAST; i++) {
4365 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004366 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004367 err = new_analog_input(spec, cfg->input_pins[i],
4368 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004369 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 if (err < 0)
4371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004372 imux->items[imux->num_items].label =
4373 auto_pin_cfg_labels[i];
4374 imux->items[imux->num_items].index =
4375 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004376 imux->num_items++;
4377 }
4378 }
4379 return 0;
4380}
4381
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004382static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4383 unsigned int pin_type)
4384{
4385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4386 pin_type);
4387 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4389 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004390}
4391
Kailang Yangdf694da2005-12-05 19:42:22 +01004392static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4393 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 int dac_idx)
4395{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004396 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004397 /* need the manual connection? */
4398 if (alc880_is_multi_pin(nid)) {
4399 struct alc_spec *spec = codec->spec;
4400 int idx = alc880_multi_pin_idx(nid);
4401 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4402 AC_VERB_SET_CONNECT_SEL,
4403 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4404 }
4405}
4406
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004407static int get_pin_type(int line_out_type)
4408{
4409 if (line_out_type == AUTO_PIN_HP_OUT)
4410 return PIN_HP;
4411 else
4412 return PIN_OUT;
4413}
4414
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415static void alc880_auto_init_multi_out(struct hda_codec *codec)
4416{
4417 struct alc_spec *spec = codec->spec;
4418 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004419
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420 for (i = 0; i < spec->autocfg.line_outs; i++) {
4421 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004422 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4423 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 }
4425}
4426
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004427static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428{
4429 struct alc_spec *spec = codec->spec;
4430 hda_nid_t pin;
4431
Takashi Iwai82bc9552006-03-21 11:24:42 +01004432 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004433 if (pin) /* connect to front */
4434 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004435 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004436 if (pin) /* connect to front */
4437 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4438}
4439
4440static void alc880_auto_init_analog_input(struct hda_codec *codec)
4441{
4442 struct alc_spec *spec = codec->spec;
4443 int i;
4444
4445 for (i = 0; i < AUTO_PIN_LAST; i++) {
4446 hda_nid_t nid = spec->autocfg.input_pins[i];
4447 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004448 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004449 if (nid != ALC880_PIN_CD_NID &&
4450 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 snd_hda_codec_write(codec, nid, 0,
4452 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 AMP_OUT_MUTE);
4454 }
4455 }
4456}
4457
4458/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004459/* return 1 if successful, 0 if the proper config is not found,
4460 * or a negative error code
4461 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462static int alc880_parse_auto_config(struct hda_codec *codec)
4463{
4464 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004465 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004466 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004468 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4469 alc880_ignore);
4470 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004471 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004474
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4476 if (err < 0)
4477 return err;
4478 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4479 if (err < 0)
4480 return err;
4481 err = alc880_auto_create_extra_out(spec,
4482 spec->autocfg.speaker_pins[0],
4483 "Speaker");
4484 if (err < 0)
4485 return err;
4486 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4487 "Headphone");
4488 if (err < 0)
4489 return err;
4490 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4491 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492 return err;
4493
4494 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4495
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004496 /* check multiple SPDIF-out (for recent codecs) */
4497 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4498 hda_nid_t dig_nid;
4499 err = snd_hda_get_connections(codec,
4500 spec->autocfg.dig_out_pins[i],
4501 &dig_nid, 1);
4502 if (err < 0)
4503 continue;
4504 if (!i)
4505 spec->multiout.dig_out_nid = dig_nid;
4506 else {
4507 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4508 spec->slave_dig_outs[i - 1] = dig_nid;
4509 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4510 break;
4511 }
4512 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 if (spec->autocfg.dig_in_pin)
4514 spec->dig_in_nid = ALC880_DIGIN_NID;
4515
Takashi Iwai603c4012008-07-30 15:01:44 +02004516 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004517 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518
Takashi Iwaid88897e2008-10-31 15:01:37 +01004519 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004520
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004521 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004522 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004524 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4525
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004526 return 1;
4527}
4528
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004529/* additional initialization for auto-configuration model */
4530static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004532 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004534 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004535 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004536 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004537 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004538}
4539
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004540static void set_capture_mixer(struct alc_spec *spec)
4541{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004542 static struct snd_kcontrol_new *caps[2][3] = {
4543 { alc_capture_mixer_nosrc1,
4544 alc_capture_mixer_nosrc2,
4545 alc_capture_mixer_nosrc3 },
4546 { alc_capture_mixer1,
4547 alc_capture_mixer2,
4548 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004549 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004550 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4551 int mux;
4552 if (spec->input_mux && spec->input_mux->num_items > 1)
4553 mux = 1;
4554 else
4555 mux = 0;
4556 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4557 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004558}
4559
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004560#define set_beep_amp(spec, nid, idx, dir) \
4561 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4562
4563/*
4564 * OK, here we have finally the patch for ALC880
4565 */
4566
Linus Torvalds1da177e2005-04-16 15:20:36 -07004567static int patch_alc880(struct hda_codec *codec)
4568{
4569 struct alc_spec *spec;
4570 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004571 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004572
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004574 if (spec == NULL)
4575 return -ENOMEM;
4576
4577 codec->spec = spec;
4578
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4580 alc880_models,
4581 alc880_cfg_tbl);
4582 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004583 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4584 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004586 }
4587
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004588 if (board_config == ALC880_AUTO) {
4589 /* automatic parse from the BIOS config */
4590 err = alc880_parse_auto_config(codec);
4591 if (err < 0) {
4592 alc_free(codec);
4593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004594 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004595 printk(KERN_INFO
4596 "hda_codec: Cannot set up configuration "
4597 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598 board_config = ALC880_3ST;
4599 }
4600 }
4601
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004602 err = snd_hda_attach_beep_device(codec, 0x1);
4603 if (err < 0) {
4604 alc_free(codec);
4605 return err;
4606 }
4607
Kailang Yangdf694da2005-12-05 19:42:22 +01004608 if (board_config != ALC880_AUTO)
4609 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004610
Linus Torvalds1da177e2005-04-16 15:20:36 -07004611 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4612 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004613 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004614
Linus Torvalds1da177e2005-04-16 15:20:36 -07004615 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4616 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4617
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004618 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004620 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004621 /* get type */
4622 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623 if (wcap != AC_WID_AUD_IN) {
4624 spec->adc_nids = alc880_adc_nids_alt;
4625 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 } else {
4627 spec->adc_nids = alc880_adc_nids;
4628 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004629 }
4630 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004631 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004632 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004633
Takashi Iwai2134ea42008-01-10 16:53:55 +01004634 spec->vmaster_nid = 0x0c;
4635
Linus Torvalds1da177e2005-04-16 15:20:36 -07004636 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004638 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004639#ifdef CONFIG_SND_HDA_POWER_SAVE
4640 if (!spec->loopback.amplist)
4641 spec->loopback.amplist = alc880_loopbacks;
4642#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004643 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004644
4645 return 0;
4646}
4647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004648
Linus Torvalds1da177e2005-04-16 15:20:36 -07004649/*
4650 * ALC260 support
4651 */
4652
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653static hda_nid_t alc260_dac_nids[1] = {
4654 /* front */
4655 0x02,
4656};
4657
4658static hda_nid_t alc260_adc_nids[1] = {
4659 /* ADC0 */
4660 0x04,
4661};
4662
Kailang Yangdf694da2005-12-05 19:42:22 +01004663static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 /* ADC1 */
4665 0x05,
4666};
4667
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004668/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4669 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4670 */
4671static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004672 /* ADC0, ADC1 */
4673 0x04, 0x05
4674};
4675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676#define ALC260_DIGOUT_NID 0x03
4677#define ALC260_DIGIN_NID 0x06
4678
4679static struct hda_input_mux alc260_capture_source = {
4680 .num_items = 4,
4681 .items = {
4682 { "Mic", 0x0 },
4683 { "Front Mic", 0x1 },
4684 { "Line", 0x2 },
4685 { "CD", 0x4 },
4686 },
4687};
4688
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004689/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004690 * headphone jack and the internal CD lines since these are the only pins at
4691 * which audio can appear. For flexibility, also allow the option of
4692 * recording the mixer output on the second ADC (ADC0 doesn't have a
4693 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004694 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004695static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4696 {
4697 .num_items = 3,
4698 .items = {
4699 { "Mic/Line", 0x0 },
4700 { "CD", 0x4 },
4701 { "Headphone", 0x2 },
4702 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004703 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004704 {
4705 .num_items = 4,
4706 .items = {
4707 { "Mic/Line", 0x0 },
4708 { "CD", 0x4 },
4709 { "Headphone", 0x2 },
4710 { "Mixer", 0x5 },
4711 },
4712 },
4713
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004714};
4715
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004716/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4717 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004718 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004719static struct hda_input_mux alc260_acer_capture_sources[2] = {
4720 {
4721 .num_items = 4,
4722 .items = {
4723 { "Mic", 0x0 },
4724 { "Line", 0x2 },
4725 { "CD", 0x4 },
4726 { "Headphone", 0x5 },
4727 },
4728 },
4729 {
4730 .num_items = 5,
4731 .items = {
4732 { "Mic", 0x0 },
4733 { "Line", 0x2 },
4734 { "CD", 0x4 },
4735 { "Headphone", 0x6 },
4736 { "Mixer", 0x5 },
4737 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004738 },
4739};
Michael Schwingencc959482009-02-22 18:58:45 +01004740
4741/* Maxdata Favorit 100XS */
4742static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4743 {
4744 .num_items = 2,
4745 .items = {
4746 { "Line/Mic", 0x0 },
4747 { "CD", 0x4 },
4748 },
4749 },
4750 {
4751 .num_items = 3,
4752 .items = {
4753 { "Line/Mic", 0x0 },
4754 { "CD", 0x4 },
4755 { "Mixer", 0x5 },
4756 },
4757 },
4758};
4759
Linus Torvalds1da177e2005-04-16 15:20:36 -07004760/*
4761 * This is just place-holder, so there's something for alc_build_pcms to look
4762 * at when it calculates the maximum number of channels. ALC260 has no mixer
4763 * element which allows changing the channel mode, so the verb list is
4764 * never used.
4765 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004766static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004767 { 2, NULL },
4768};
4769
Kailang Yangdf694da2005-12-05 19:42:22 +01004770
4771/* Mixer combinations
4772 *
4773 * basic: base_output + input + pc_beep + capture
4774 * HP: base_output + input + capture_alt
4775 * HP_3013: hp_3013 + input + capture
4776 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004777 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004778 */
4779
4780static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004781 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004782 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004783 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4784 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4785 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4786 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4787 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004788};
Kailang Yangdf694da2005-12-05 19:42:22 +01004789
4790static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004791 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4792 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4793 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4794 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4796 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4798 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004799 { } /* end */
4800};
4801
Takashi Iwaibec15c32008-01-28 18:16:30 +01004802/* update HP, line and mono out pins according to the master switch */
4803static void alc260_hp_master_update(struct hda_codec *codec,
4804 hda_nid_t hp, hda_nid_t line,
4805 hda_nid_t mono)
4806{
4807 struct alc_spec *spec = codec->spec;
4808 unsigned int val = spec->master_sw ? PIN_HP : 0;
4809 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004810 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004811 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004812 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004813 val);
4814 /* mono (speaker) depending on the HP jack sense */
4815 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004816 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004817 val);
4818}
4819
4820static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4821 struct snd_ctl_elem_value *ucontrol)
4822{
4823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4824 struct alc_spec *spec = codec->spec;
4825 *ucontrol->value.integer.value = spec->master_sw;
4826 return 0;
4827}
4828
4829static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4830 struct snd_ctl_elem_value *ucontrol)
4831{
4832 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4833 struct alc_spec *spec = codec->spec;
4834 int val = !!*ucontrol->value.integer.value;
4835 hda_nid_t hp, line, mono;
4836
4837 if (val == spec->master_sw)
4838 return 0;
4839 spec->master_sw = val;
4840 hp = (kcontrol->private_value >> 16) & 0xff;
4841 line = (kcontrol->private_value >> 8) & 0xff;
4842 mono = kcontrol->private_value & 0xff;
4843 alc260_hp_master_update(codec, hp, line, mono);
4844 return 1;
4845}
4846
4847static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4848 {
4849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4850 .name = "Master Playback Switch",
4851 .info = snd_ctl_boolean_mono_info,
4852 .get = alc260_hp_master_sw_get,
4853 .put = alc260_hp_master_sw_put,
4854 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4855 },
4856 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4857 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4859 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4860 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4861 HDA_OUTPUT),
4862 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4863 { } /* end */
4864};
4865
4866static struct hda_verb alc260_hp_unsol_verbs[] = {
4867 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4868 {},
4869};
4870
4871static void alc260_hp_automute(struct hda_codec *codec)
4872{
4873 struct alc_spec *spec = codec->spec;
4874 unsigned int present;
4875
4876 present = snd_hda_codec_read(codec, 0x10, 0,
4877 AC_VERB_GET_PIN_SENSE, 0);
4878 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4879 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4880}
4881
4882static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4883{
4884 if ((res >> 26) == ALC880_HP_EVENT)
4885 alc260_hp_automute(codec);
4886}
4887
Kailang Yangdf694da2005-12-05 19:42:22 +01004888static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004889 {
4890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4891 .name = "Master Playback Switch",
4892 .info = snd_ctl_boolean_mono_info,
4893 .get = alc260_hp_master_sw_get,
4894 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004895 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004896 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004897 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4898 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4899 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4900 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004903 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4904 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004905 { } /* end */
4906};
4907
Kailang Yang3f878302008-08-26 13:02:23 +02004908static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4909 .ops = &snd_hda_bind_vol,
4910 .values = {
4911 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4912 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4913 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4914 0
4915 },
4916};
4917
4918static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4919 .ops = &snd_hda_bind_sw,
4920 .values = {
4921 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4922 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4923 0
4924 },
4925};
4926
4927static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4928 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4929 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4930 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4932 { } /* end */
4933};
4934
Takashi Iwaibec15c32008-01-28 18:16:30 +01004935static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4936 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4937 {},
4938};
4939
4940static void alc260_hp_3013_automute(struct hda_codec *codec)
4941{
4942 struct alc_spec *spec = codec->spec;
4943 unsigned int present;
4944
4945 present = snd_hda_codec_read(codec, 0x15, 0,
4946 AC_VERB_GET_PIN_SENSE, 0);
4947 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004948 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004949}
4950
4951static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4952 unsigned int res)
4953{
4954 if ((res >> 26) == ALC880_HP_EVENT)
4955 alc260_hp_3013_automute(codec);
4956}
4957
Kailang Yang3f878302008-08-26 13:02:23 +02004958static void alc260_hp_3012_automute(struct hda_codec *codec)
4959{
4960 unsigned int present, bits;
4961
4962 present = snd_hda_codec_read(codec, 0x10, 0,
4963 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4964
4965 bits = present ? 0 : PIN_OUT;
4966 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4967 bits);
4968 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4969 bits);
4970 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4971 bits);
4972}
4973
4974static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4975 unsigned int res)
4976{
4977 if ((res >> 26) == ALC880_HP_EVENT)
4978 alc260_hp_3012_automute(codec);
4979}
4980
4981/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004982 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4983 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004984static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004986 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004987 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004988 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4989 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4990 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4991 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004992 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4994 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004995 { } /* end */
4996};
4997
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004998/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4999 * versions of the ALC260 don't act on requests to enable mic bias from NID
5000 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5001 * datasheet doesn't mention this restriction. At this stage it's not clear
5002 * whether this behaviour is intentional or is a hardware bug in chip
5003 * revisions available in early 2006. Therefore for now allow the
5004 * "Headphone Jack Mode" control to span all choices, but if it turns out
5005 * that the lack of mic bias for this NID is intentional we could change the
5006 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5007 *
5008 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5009 * don't appear to make the mic bias available from the "line" jack, even
5010 * though the NID used for this jack (0x14) can supply it. The theory is
5011 * that perhaps Acer have included blocking capacitors between the ALC260
5012 * and the output jack. If this turns out to be the case for all such
5013 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5014 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005015 *
5016 * The C20x Tablet series have a mono internal speaker which is controlled
5017 * via the chip's Mono sum widget and pin complex, so include the necessary
5018 * controls for such models. On models without a "mono speaker" the control
5019 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005020 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005021static struct snd_kcontrol_new alc260_acer_mixer[] = {
5022 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5023 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005024 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005025 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005026 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005027 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005028 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005029 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5030 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5032 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5033 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5034 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5035 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5036 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005037 { } /* end */
5038};
5039
Michael Schwingencc959482009-02-22 18:58:45 +01005040/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5041 */
5042static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5043 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5044 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5045 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5046 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5047 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5048 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5049 { } /* end */
5050};
5051
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005052/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5053 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5054 */
5055static struct snd_kcontrol_new alc260_will_mixer[] = {
5056 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5057 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5059 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5060 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5061 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5062 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5063 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5064 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5065 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005066 { } /* end */
5067};
5068
5069/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5070 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5071 */
5072static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5073 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5074 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5076 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5077 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5078 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5079 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5080 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5081 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5082 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5083 { } /* end */
5084};
5085
Kailang Yangdf694da2005-12-05 19:42:22 +01005086/*
5087 * initialization verbs
5088 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005089static struct hda_verb alc260_init_verbs[] = {
5090 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005092 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005094 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005095 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005097 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005098 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005100 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005101 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005102 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005103 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005105 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005107 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5108 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005109 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005110 /* set connection select to line in (default select for this ADC) */
5111 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005112 /* mute capture amp left and right */
5113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5114 /* set connection select to line in (default select for this ADC) */
5115 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005116 /* set vol=0 Line-Out mixer amp left and right */
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5118 /* unmute pin widget amp left and right (no gain on this amp) */
5119 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5120 /* set vol=0 HP mixer amp left and right */
5121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 /* unmute pin widget amp left and right (no gain on this amp) */
5123 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5124 /* set vol=0 Mono mixer amp left and right */
5125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5126 /* unmute pin widget amp left and right (no gain on this amp) */
5127 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* unmute LINE-2 out pin */
5129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005130 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5131 * Line In 2 = 0x03
5132 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005133 /* mute analog inputs */
5134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005139 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005140 /* mute Front out path */
5141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5143 /* mute Headphone out path */
5144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5146 /* mute Mono out path */
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005149 { }
5150};
5151
Takashi Iwai474167d2006-05-17 17:17:43 +02005152#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005153static struct hda_verb alc260_hp_init_verbs[] = {
5154 /* Headphone and output */
5155 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5156 /* mono output */
5157 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5158 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5159 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5160 /* Mic2 (front panel) pin widget for input and vref at 80% */
5161 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5162 /* Line In pin widget for input */
5163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5164 /* Line-2 pin widget for output */
5165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5166 /* CD pin widget for input */
5167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5168 /* unmute amp left and right */
5169 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5170 /* set connection select to line in (default select for this ADC) */
5171 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5172 /* unmute Line-Out mixer amp left and right (volume = 0) */
5173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5174 /* mute pin widget amp left and right (no gain on this amp) */
5175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5176 /* unmute HP mixer amp left and right (volume = 0) */
5177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5178 /* mute pin widget amp left and right (no gain on this amp) */
5179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5181 * Line In 2 = 0x03
5182 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005183 /* mute analog inputs */
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005189 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5190 /* Unmute Front out path */
5191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5192 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5193 /* Unmute Headphone out path */
5194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5196 /* Unmute Mono out path */
5197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5198 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5199 { }
5200};
Takashi Iwai474167d2006-05-17 17:17:43 +02005201#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005202
5203static struct hda_verb alc260_hp_3013_init_verbs[] = {
5204 /* Line out and output */
5205 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5206 /* mono output */
5207 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5208 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5209 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5210 /* Mic2 (front panel) pin widget for input and vref at 80% */
5211 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5212 /* Line In pin widget for input */
5213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5214 /* Headphone pin widget for output */
5215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5216 /* CD pin widget for input */
5217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5218 /* unmute amp left and right */
5219 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5220 /* set connection select to line in (default select for this ADC) */
5221 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5222 /* unmute Line-Out mixer amp left and right (volume = 0) */
5223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5224 /* mute pin widget amp left and right (no gain on this amp) */
5225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5226 /* unmute HP mixer amp left and right (volume = 0) */
5227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5228 /* mute pin widget amp left and right (no gain on this amp) */
5229 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005230 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5231 * Line In 2 = 0x03
5232 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005233 /* mute analog inputs */
5234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005239 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5240 /* Unmute Front out path */
5241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5243 /* Unmute Headphone out path */
5244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5246 /* Unmute Mono out path */
5247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5248 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5249 { }
5250};
5251
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005252/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005253 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5254 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005255 */
5256static struct hda_verb alc260_fujitsu_init_verbs[] = {
5257 /* Disable all GPIOs */
5258 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5259 /* Internal speaker is connected to headphone pin */
5260 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5261 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005263 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5265 /* Ensure all other unused pins are disabled and muted. */
5266 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005268 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005269 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005270 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005271 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005274
Jonathan Woithef7ace402006-02-28 11:46:14 +01005275 /* Disable digital (SPDIF) pins */
5276 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5277 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005278
Kailang Yangea1fb292008-08-26 12:58:38 +02005279 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005280 * when acting as an output.
5281 */
5282 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5283
5284 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5293 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005294
Jonathan Woithef7ace402006-02-28 11:46:14 +01005295 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5296 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5297 /* Unmute Line1 pin widget output buffer since it starts as an output.
5298 * If the pin mode is changed by the user the pin mode control will
5299 * take care of enabling the pin's input/output buffers as needed.
5300 * Therefore there's no need to enable the input buffer at this
5301 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005302 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005304 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005305 * mixer ctrl)
5306 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005307 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005308
Jonathan Woithef7ace402006-02-28 11:46:14 +01005309 /* Mute capture amp left and right */
5310 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005311 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005312 * in (on mic1 pin)
5313 */
5314 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005315
Jonathan Woithef7ace402006-02-28 11:46:14 +01005316 /* Do the same for the second ADC: mute capture input amp and
5317 * set ADC connection to line in (on mic1 pin)
5318 */
5319 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005321
Jonathan Woithef7ace402006-02-28 11:46:14 +01005322 /* Mute all inputs to mixer widget (even unconnected ones) */
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005331
5332 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005333};
5334
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005335/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5336 * similar laptops (adapted from Fujitsu init verbs).
5337 */
5338static struct hda_verb alc260_acer_init_verbs[] = {
5339 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5340 * the headphone jack. Turn this on and rely on the standard mute
5341 * methods whenever the user wants to turn these outputs off.
5342 */
5343 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5344 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5345 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5346 /* Internal speaker/Headphone jack is connected to Line-out pin */
5347 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5348 /* Internal microphone/Mic jack is connected to Mic1 pin */
5349 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5350 /* Line In jack is connected to Line1 pin */
5351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005352 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5353 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005354 /* Ensure all other unused pins are disabled and muted. */
5355 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5356 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005357 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5358 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 /* Disable digital (SPDIF) pins */
5362 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5363 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5364
Kailang Yangea1fb292008-08-26 12:58:38 +02005365 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005366 * bus when acting as outputs.
5367 */
5368 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5369 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5370
5371 /* Start with output sum widgets muted and their output gains at min */
5372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5379 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5380 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5381
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005382 /* Unmute Line-out pin widget amp left and right
5383 * (no equiv mixer ctrl)
5384 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005386 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5387 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005388 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5389 * inputs. If the pin mode is changed by the user the pin mode control
5390 * will take care of enabling the pin's input/output buffers as needed.
5391 * Therefore there's no need to enable the input buffer at this
5392 * stage.
5393 */
5394 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5396
5397 /* Mute capture amp left and right */
5398 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5399 /* Set ADC connection select to match default mixer setting - mic
5400 * (on mic1 pin)
5401 */
5402 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5403
5404 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005405 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005406 */
5407 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005408 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005409
5410 /* Mute all inputs to mixer widget (even unconnected ones) */
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5419
5420 { }
5421};
5422
Michael Schwingencc959482009-02-22 18:58:45 +01005423/* Initialisation sequence for Maxdata Favorit 100XS
5424 * (adapted from Acer init verbs).
5425 */
5426static struct hda_verb alc260_favorit100_init_verbs[] = {
5427 /* GPIO 0 enables the output jack.
5428 * Turn this on and rely on the standard mute
5429 * methods whenever the user wants to turn these outputs off.
5430 */
5431 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5433 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5434 /* Line/Mic input jack is connected to Mic1 pin */
5435 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5436 /* Ensure all other unused pins are disabled and muted. */
5437 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5438 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5440 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5441 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5442 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 /* Disable digital (SPDIF) pins */
5448 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5449 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5450
5451 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5452 * bus when acting as outputs.
5453 */
5454 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5455 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5456
5457 /* Start with output sum widgets muted and their output gains at min */
5458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5460 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5465 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5466 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467
5468 /* Unmute Line-out pin widget amp left and right
5469 * (no equiv mixer ctrl)
5470 */
5471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5472 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5473 * inputs. If the pin mode is changed by the user the pin mode control
5474 * will take care of enabling the pin's input/output buffers as needed.
5475 * Therefore there's no need to enable the input buffer at this
5476 * stage.
5477 */
5478 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5479
5480 /* Mute capture amp left and right */
5481 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5482 /* Set ADC connection select to match default mixer setting - mic
5483 * (on mic1 pin)
5484 */
5485 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5486
5487 /* Do similar with the second ADC: mute capture input amp and
5488 * set ADC connection to mic to match ALSA's default state.
5489 */
5490 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5492
5493 /* Mute all inputs to mixer widget (even unconnected ones) */
5494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5502
5503 { }
5504};
5505
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005506static struct hda_verb alc260_will_verbs[] = {
5507 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5508 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5509 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5510 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5511 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5512 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5513 {}
5514};
5515
5516static struct hda_verb alc260_replacer_672v_verbs[] = {
5517 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5518 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5519 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5520
5521 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5522 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5523 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5524
5525 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5526 {}
5527};
5528
5529/* toggle speaker-output according to the hp-jack state */
5530static void alc260_replacer_672v_automute(struct hda_codec *codec)
5531{
5532 unsigned int present;
5533
5534 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5535 present = snd_hda_codec_read(codec, 0x0f, 0,
5536 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5537 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005538 snd_hda_codec_write_cache(codec, 0x01, 0,
5539 AC_VERB_SET_GPIO_DATA, 1);
5540 snd_hda_codec_write_cache(codec, 0x0f, 0,
5541 AC_VERB_SET_PIN_WIDGET_CONTROL,
5542 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005543 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005544 snd_hda_codec_write_cache(codec, 0x01, 0,
5545 AC_VERB_SET_GPIO_DATA, 0);
5546 snd_hda_codec_write_cache(codec, 0x0f, 0,
5547 AC_VERB_SET_PIN_WIDGET_CONTROL,
5548 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005549 }
5550}
5551
5552static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5553 unsigned int res)
5554{
5555 if ((res >> 26) == ALC880_HP_EVENT)
5556 alc260_replacer_672v_automute(codec);
5557}
5558
Kailang Yang3f878302008-08-26 13:02:23 +02005559static struct hda_verb alc260_hp_dc7600_verbs[] = {
5560 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5561 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5562 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5563 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5564 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5566 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5567 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5568 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5569 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5570 {}
5571};
5572
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005573/* Test configuration for debugging, modelled after the ALC880 test
5574 * configuration.
5575 */
5576#ifdef CONFIG_SND_DEBUG
5577static hda_nid_t alc260_test_dac_nids[1] = {
5578 0x02,
5579};
5580static hda_nid_t alc260_test_adc_nids[2] = {
5581 0x04, 0x05,
5582};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005583/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005584 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005585 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005586 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005587static struct hda_input_mux alc260_test_capture_sources[2] = {
5588 {
5589 .num_items = 7,
5590 .items = {
5591 { "MIC1 pin", 0x0 },
5592 { "MIC2 pin", 0x1 },
5593 { "LINE1 pin", 0x2 },
5594 { "LINE2 pin", 0x3 },
5595 { "CD pin", 0x4 },
5596 { "LINE-OUT pin", 0x5 },
5597 { "HP-OUT pin", 0x6 },
5598 },
5599 },
5600 {
5601 .num_items = 8,
5602 .items = {
5603 { "MIC1 pin", 0x0 },
5604 { "MIC2 pin", 0x1 },
5605 { "LINE1 pin", 0x2 },
5606 { "LINE2 pin", 0x3 },
5607 { "CD pin", 0x4 },
5608 { "Mixer", 0x5 },
5609 { "LINE-OUT pin", 0x6 },
5610 { "HP-OUT pin", 0x7 },
5611 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005612 },
5613};
5614static struct snd_kcontrol_new alc260_test_mixer[] = {
5615 /* Output driver widgets */
5616 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5617 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5618 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5619 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5620 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5621 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5622
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005623 /* Modes for retasking pin widgets
5624 * Note: the ALC260 doesn't seem to act on requests to enable mic
5625 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5626 * mention this restriction. At this stage it's not clear whether
5627 * this behaviour is intentional or is a hardware bug in chip
5628 * revisions available at least up until early 2006. Therefore for
5629 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5630 * choices, but if it turns out that the lack of mic bias for these
5631 * NIDs is intentional we could change their modes from
5632 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5633 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005634 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5635 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5636 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5637 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5638 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5639 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5640
5641 /* Loopback mixer controls */
5642 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5643 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5644 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5645 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5646 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5647 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5648 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5649 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5650 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5651 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005652 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5653 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5654 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5655 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005656
5657 /* Controls for GPIO pins, assuming they are configured as outputs */
5658 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5659 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5660 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5661 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5662
Jonathan Woithe92621f12006-02-28 11:47:47 +01005663 /* Switches to allow the digital IO pins to be enabled. The datasheet
5664 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005665 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005666 */
5667 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5668 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5669
Jonathan Woithef8225f62008-01-08 12:16:54 +01005670 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5671 * this output to turn on an external amplifier.
5672 */
5673 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5674 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5675
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005676 { } /* end */
5677};
5678static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005679 /* Enable all GPIOs as outputs with an initial value of 0 */
5680 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5681 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5682 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5683
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005684 /* Enable retasking pins as output, initially without power amp */
5685 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5686 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5689 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5691
Jonathan Woithe92621f12006-02-28 11:47:47 +01005692 /* Disable digital (SPDIF) pins initially, but users can enable
5693 * them via a mixer switch. In the case of SPDIF-out, this initverb
5694 * payload also sets the generation to 0, output to be in "consumer"
5695 * PCM format, copyright asserted, no pre-emphasis and no validity
5696 * control.
5697 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005698 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5699 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5700
Kailang Yangea1fb292008-08-26 12:58:38 +02005701 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005702 * OUT1 sum bus when acting as an output.
5703 */
5704 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5705 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5706 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5707 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5708
5709 /* Start with output sum widgets muted and their output gains at min */
5710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5711 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5715 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5716 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5717 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5718 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5719
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005720 /* Unmute retasking pin widget output buffers since the default
5721 * state appears to be output. As the pin mode is changed by the
5722 * user the pin mode control will take care of enabling the pin's
5723 * input/output buffers as needed.
5724 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5729 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5730 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5731 /* Also unmute the mono-out pin widget */
5732 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5733
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005734 /* Mute capture amp left and right */
5735 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005736 /* Set ADC connection select to match default mixer setting (mic1
5737 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005738 */
5739 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5740
5741 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005742 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005743 */
5744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5745 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5746
5747 /* Mute all inputs to mixer widget (even unconnected ones) */
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5756
5757 { }
5758};
5759#endif
5760
Takashi Iwai63300792008-01-24 15:31:36 +01005761#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5762#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005763
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005764#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5765#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5766
Kailang Yangdf694da2005-12-05 19:42:22 +01005767/*
5768 * for BIOS auto-configuration
5769 */
5770
5771static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005772 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005773{
5774 hda_nid_t nid_vol;
5775 unsigned long vol_val, sw_val;
5776 char name[32];
5777 int err;
5778
5779 if (nid >= 0x0f && nid < 0x11) {
5780 nid_vol = nid - 0x7;
5781 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5782 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5783 } else if (nid == 0x11) {
5784 nid_vol = nid - 0x7;
5785 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5786 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5787 } else if (nid >= 0x12 && nid <= 0x15) {
5788 nid_vol = 0x08;
5789 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5790 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5791 } else
5792 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005793
Takashi Iwai863b4512008-10-21 17:01:47 +02005794 if (!(*vol_bits & (1 << nid_vol))) {
5795 /* first control for the volume widget */
5796 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5797 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5798 if (err < 0)
5799 return err;
5800 *vol_bits |= (1 << nid_vol);
5801 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005802 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005803 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5804 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005805 return err;
5806 return 1;
5807}
5808
5809/* add playback controls from the parsed DAC table */
5810static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5811 const struct auto_pin_cfg *cfg)
5812{
5813 hda_nid_t nid;
5814 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005815 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005816
5817 spec->multiout.num_dacs = 1;
5818 spec->multiout.dac_nids = spec->private_dac_nids;
5819 spec->multiout.dac_nids[0] = 0x02;
5820
5821 nid = cfg->line_out_pins[0];
5822 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005823 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005824 if (err < 0)
5825 return err;
5826 }
5827
Takashi Iwai82bc9552006-03-21 11:24:42 +01005828 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005829 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005830 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005831 if (err < 0)
5832 return err;
5833 }
5834
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005835 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005836 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005837 err = alc260_add_playback_controls(spec, nid, "Headphone",
5838 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005839 if (err < 0)
5840 return err;
5841 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005842 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005843}
5844
5845/* create playback/capture controls for input pins */
5846static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5847 const struct auto_pin_cfg *cfg)
5848{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005849 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005850 int i, err, idx;
5851
5852 for (i = 0; i < AUTO_PIN_LAST; i++) {
5853 if (cfg->input_pins[i] >= 0x12) {
5854 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005855 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005856 auto_pin_cfg_labels[i], idx,
5857 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005858 if (err < 0)
5859 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005860 imux->items[imux->num_items].label =
5861 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 imux->items[imux->num_items].index = idx;
5863 imux->num_items++;
5864 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005865 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005867 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005868 auto_pin_cfg_labels[i], idx,
5869 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 if (err < 0)
5871 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005872 imux->items[imux->num_items].label =
5873 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005874 imux->items[imux->num_items].index = idx;
5875 imux->num_items++;
5876 }
5877 }
5878 return 0;
5879}
5880
5881static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5882 hda_nid_t nid, int pin_type,
5883 int sel_idx)
5884{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005885 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005886 /* need the manual connection? */
5887 if (nid >= 0x12) {
5888 int idx = nid - 0x12;
5889 snd_hda_codec_write(codec, idx + 0x0b, 0,
5890 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005891 }
5892}
5893
5894static void alc260_auto_init_multi_out(struct hda_codec *codec)
5895{
5896 struct alc_spec *spec = codec->spec;
5897 hda_nid_t nid;
5898
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005899 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005900 if (nid) {
5901 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5902 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5903 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005904
Takashi Iwai82bc9552006-03-21 11:24:42 +01005905 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005906 if (nid)
5907 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5908
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005909 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005911 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005912}
Kailang Yangdf694da2005-12-05 19:42:22 +01005913
5914#define ALC260_PIN_CD_NID 0x16
5915static void alc260_auto_init_analog_input(struct hda_codec *codec)
5916{
5917 struct alc_spec *spec = codec->spec;
5918 int i;
5919
5920 for (i = 0; i < AUTO_PIN_LAST; i++) {
5921 hda_nid_t nid = spec->autocfg.input_pins[i];
5922 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005923 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005924 if (nid != ALC260_PIN_CD_NID &&
5925 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005926 snd_hda_codec_write(codec, nid, 0,
5927 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005928 AMP_OUT_MUTE);
5929 }
5930 }
5931}
5932
5933/*
5934 * generic initialization of ADC, input mixers and output mixers
5935 */
5936static struct hda_verb alc260_volume_init_verbs[] = {
5937 /*
5938 * Unmute ADC0-1 and set the default input to mic-in
5939 */
5940 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5941 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5942 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005944
Kailang Yangdf694da2005-12-05 19:42:22 +01005945 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5946 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005947 * Note: PASD motherboards uses the Line In 2 as the input for
5948 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005949 */
5950 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005951 /* mute analog inputs */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005957
5958 /*
5959 * Set up output mixers (0x08 - 0x0a)
5960 */
5961 /* set vol=0 to output mixers */
5962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5964 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5965 /* set up input amps for analog loopback */
5966 /* Amp Indices: DAC = 0, mixer = 1 */
5967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5971 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5972 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005973
Kailang Yangdf694da2005-12-05 19:42:22 +01005974 { }
5975};
5976
5977static int alc260_parse_auto_config(struct hda_codec *codec)
5978{
5979 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005980 int err;
5981 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5982
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005983 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5984 alc260_ignore);
5985 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005986 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005987 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5988 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005989 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005990 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005991 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005992 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5993 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 return err;
5995
5996 spec->multiout.max_channels = 2;
5997
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005998 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005999 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006000 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006001 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006002
Takashi Iwaid88897e2008-10-31 15:01:37 +01006003 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006004
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006005 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006006 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006007
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006008 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6009
Kailang Yangdf694da2005-12-05 19:42:22 +01006010 return 1;
6011}
6012
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006013/* additional initialization for auto-configuration model */
6014static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006015{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006016 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006017 alc260_auto_init_multi_out(codec);
6018 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006019 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006020 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006021}
6022
Takashi Iwaicb53c622007-08-10 17:21:45 +02006023#ifdef CONFIG_SND_HDA_POWER_SAVE
6024static struct hda_amp_list alc260_loopbacks[] = {
6025 { 0x07, HDA_INPUT, 0 },
6026 { 0x07, HDA_INPUT, 1 },
6027 { 0x07, HDA_INPUT, 2 },
6028 { 0x07, HDA_INPUT, 3 },
6029 { 0x07, HDA_INPUT, 4 },
6030 { } /* end */
6031};
6032#endif
6033
Kailang Yangdf694da2005-12-05 19:42:22 +01006034/*
6035 * ALC260 configurations
6036 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006037static const char *alc260_models[ALC260_MODEL_LAST] = {
6038 [ALC260_BASIC] = "basic",
6039 [ALC260_HP] = "hp",
6040 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006041 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006042 [ALC260_FUJITSU_S702X] = "fujitsu",
6043 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006044 [ALC260_WILL] = "will",
6045 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006046 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006047#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006048 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006049#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006050 [ALC260_AUTO] = "auto",
6051};
6052
6053static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006054 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006055 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006056 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006057 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006058 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006059 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006060 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006061 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006062 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6063 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6064 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6065 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6066 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6067 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6068 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6069 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6070 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006071 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006072 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006073 {}
6074};
6075
Kailang Yangdf694da2005-12-05 19:42:22 +01006076static struct alc_config_preset alc260_presets[] = {
6077 [ALC260_BASIC] = {
6078 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006079 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 .init_verbs = { alc260_init_verbs },
6081 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6082 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006083 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 .adc_nids = alc260_adc_nids,
6085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6086 .channel_mode = alc260_modes,
6087 .input_mux = &alc260_capture_source,
6088 },
6089 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006090 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006091 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006092 .init_verbs = { alc260_init_verbs,
6093 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006094 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6095 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006096 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6097 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6099 .channel_mode = alc260_modes,
6100 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006101 .unsol_event = alc260_hp_unsol_event,
6102 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006103 },
Kailang Yang3f878302008-08-26 13:02:23 +02006104 [ALC260_HP_DC7600] = {
6105 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006107 .init_verbs = { alc260_init_verbs,
6108 alc260_hp_dc7600_verbs },
6109 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6110 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006111 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6112 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6114 .channel_mode = alc260_modes,
6115 .input_mux = &alc260_capture_source,
6116 .unsol_event = alc260_hp_3012_unsol_event,
6117 .init_hook = alc260_hp_3012_automute,
6118 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006119 [ALC260_HP_3013] = {
6120 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006121 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006122 .init_verbs = { alc260_hp_3013_init_verbs,
6123 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006124 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6125 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006126 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6127 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6129 .channel_mode = alc260_modes,
6130 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006131 .unsol_event = alc260_hp_3013_unsol_event,
6132 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006133 },
6134 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006135 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006136 .init_verbs = { alc260_fujitsu_init_verbs },
6137 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6138 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006139 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6140 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006141 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6142 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006143 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6144 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006146 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006147 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006148 .init_verbs = { alc260_acer_init_verbs },
6149 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6150 .dac_nids = alc260_dac_nids,
6151 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6152 .adc_nids = alc260_dual_adc_nids,
6153 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6154 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006155 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6156 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006157 },
Michael Schwingencc959482009-02-22 18:58:45 +01006158 [ALC260_FAVORIT100] = {
6159 .mixers = { alc260_favorit100_mixer },
6160 .init_verbs = { alc260_favorit100_init_verbs },
6161 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6162 .dac_nids = alc260_dac_nids,
6163 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6164 .adc_nids = alc260_dual_adc_nids,
6165 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6166 .channel_mode = alc260_modes,
6167 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6168 .input_mux = alc260_favorit100_capture_sources,
6169 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006170 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006171 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006172 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6173 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6174 .dac_nids = alc260_dac_nids,
6175 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6176 .adc_nids = alc260_adc_nids,
6177 .dig_out_nid = ALC260_DIGOUT_NID,
6178 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6179 .channel_mode = alc260_modes,
6180 .input_mux = &alc260_capture_source,
6181 },
6182 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006183 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006184 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6185 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6186 .dac_nids = alc260_dac_nids,
6187 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6188 .adc_nids = alc260_adc_nids,
6189 .dig_out_nid = ALC260_DIGOUT_NID,
6190 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6191 .channel_mode = alc260_modes,
6192 .input_mux = &alc260_capture_source,
6193 .unsol_event = alc260_replacer_672v_unsol_event,
6194 .init_hook = alc260_replacer_672v_automute,
6195 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006196#ifdef CONFIG_SND_DEBUG
6197 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006198 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006199 .init_verbs = { alc260_test_init_verbs },
6200 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6201 .dac_nids = alc260_test_dac_nids,
6202 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6203 .adc_nids = alc260_test_adc_nids,
6204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6205 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006206 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6207 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006208 },
6209#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006210};
6211
Linus Torvalds1da177e2005-04-16 15:20:36 -07006212static int patch_alc260(struct hda_codec *codec)
6213{
6214 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006216
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006217 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006218 if (spec == NULL)
6219 return -ENOMEM;
6220
6221 codec->spec = spec;
6222
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006223 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6224 alc260_models,
6225 alc260_cfg_tbl);
6226 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006227 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6228 "trying auto-probe from BIOS...\n",
6229 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006230 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006231 }
6232
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 if (board_config == ALC260_AUTO) {
6234 /* automatic parse from the BIOS config */
6235 err = alc260_parse_auto_config(codec);
6236 if (err < 0) {
6237 alc_free(codec);
6238 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006240 printk(KERN_INFO
6241 "hda_codec: Cannot set up configuration "
6242 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 board_config = ALC260_BASIC;
6244 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006245 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006246
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006247 err = snd_hda_attach_beep_device(codec, 0x1);
6248 if (err < 0) {
6249 alc_free(codec);
6250 return err;
6251 }
6252
Kailang Yangdf694da2005-12-05 19:42:22 +01006253 if (board_config != ALC260_AUTO)
6254 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006255
Linus Torvalds1da177e2005-04-16 15:20:36 -07006256 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6257 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6258
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006259 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6260 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6261
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006262 if (!spec->adc_nids && spec->input_mux) {
6263 /* check whether NID 0x04 is valid */
6264 unsigned int wcap = get_wcaps(codec, 0x04);
6265 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6266 /* get type */
6267 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6268 spec->adc_nids = alc260_adc_nids_alt;
6269 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6270 } else {
6271 spec->adc_nids = alc260_adc_nids;
6272 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6273 }
6274 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006275 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006276 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006277
Takashi Iwai2134ea42008-01-10 16:53:55 +01006278 spec->vmaster_nid = 0x08;
6279
Linus Torvalds1da177e2005-04-16 15:20:36 -07006280 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006281 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006282 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006283#ifdef CONFIG_SND_HDA_POWER_SAVE
6284 if (!spec->loopback.amplist)
6285 spec->loopback.amplist = alc260_loopbacks;
6286#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006287 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006288
6289 return 0;
6290}
6291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006292
Linus Torvalds1da177e2005-04-16 15:20:36 -07006293/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006294 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006295 *
6296 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6297 * configuration. Each pin widget can choose any input DACs and a mixer.
6298 * Each ADC is connected from a mixer of all inputs. This makes possible
6299 * 6-channel independent captures.
6300 *
6301 * In addition, an independent DAC for the multi-playback (not used in this
6302 * driver yet).
6303 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006304#define ALC882_DIGOUT_NID 0x06
6305#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006306#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6307#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6308#define ALC1200_DIGOUT_NID 0x10
6309
Linus Torvalds1da177e2005-04-16 15:20:36 -07006310
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006311static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006312 { 8, NULL }
6313};
6314
Takashi Iwai4953550a2009-06-30 15:28:30 +02006315/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006316static hda_nid_t alc882_dac_nids[4] = {
6317 /* front, rear, clfe, rear_surr */
6318 0x02, 0x03, 0x04, 0x05
6319};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006320#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006321
Takashi Iwai4953550a2009-06-30 15:28:30 +02006322/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006323#define alc882_adc_nids alc880_adc_nids
6324#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006325#define alc883_adc_nids alc882_adc_nids_alt
6326static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6327static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6328#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006329
Takashi Iwaie1406342008-02-11 18:32:32 +01006330static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6331static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006332#define alc883_capsrc_nids alc882_capsrc_nids_alt
6333static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6334#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006335
Linus Torvalds1da177e2005-04-16 15:20:36 -07006336/* input MUX */
6337/* FIXME: should be a matrix-type input source selection */
6338
6339static struct hda_input_mux alc882_capture_source = {
6340 .num_items = 4,
6341 .items = {
6342 { "Mic", 0x0 },
6343 { "Front Mic", 0x1 },
6344 { "Line", 0x2 },
6345 { "CD", 0x4 },
6346 },
6347};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006348
Takashi Iwai4953550a2009-06-30 15:28:30 +02006349#define alc883_capture_source alc882_capture_source
6350
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006351static struct hda_input_mux mb5_capture_source = {
6352 .num_items = 3,
6353 .items = {
6354 { "Mic", 0x1 },
6355 { "Line", 0x2 },
6356 { "CD", 0x4 },
6357 },
6358};
6359
Takashi Iwai4953550a2009-06-30 15:28:30 +02006360static struct hda_input_mux alc883_3stack_6ch_intel = {
6361 .num_items = 4,
6362 .items = {
6363 { "Mic", 0x1 },
6364 { "Front Mic", 0x0 },
6365 { "Line", 0x2 },
6366 { "CD", 0x4 },
6367 },
6368};
6369
6370static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6371 .num_items = 2,
6372 .items = {
6373 { "Mic", 0x1 },
6374 { "Line", 0x2 },
6375 },
6376};
6377
6378static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6379 .num_items = 4,
6380 .items = {
6381 { "Mic", 0x0 },
6382 { "iMic", 0x1 },
6383 { "Line", 0x2 },
6384 { "CD", 0x4 },
6385 },
6386};
6387
6388static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6389 .num_items = 2,
6390 .items = {
6391 { "Mic", 0x0 },
6392 { "Int Mic", 0x1 },
6393 },
6394};
6395
6396static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6397 .num_items = 3,
6398 .items = {
6399 { "Mic", 0x0 },
6400 { "Front Mic", 0x1 },
6401 { "Line", 0x4 },
6402 },
6403};
6404
6405static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6406 .num_items = 2,
6407 .items = {
6408 { "Mic", 0x0 },
6409 { "Line", 0x2 },
6410 },
6411};
6412
6413static struct hda_input_mux alc889A_mb31_capture_source = {
6414 .num_items = 2,
6415 .items = {
6416 { "Mic", 0x0 },
6417 /* Front Mic (0x01) unused */
6418 { "Line", 0x2 },
6419 /* Line 2 (0x03) unused */
6420 /* CD (0x04) unsused? */
6421 },
6422};
6423
6424/*
6425 * 2ch mode
6426 */
6427static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6428 { 2, NULL }
6429};
6430
Kailang Yangdf694da2005-12-05 19:42:22 +01006431/*
Kailang Yang272a5272007-05-14 11:00:38 +02006432 * 2ch mode
6433 */
6434static struct hda_verb alc882_3ST_ch2_init[] = {
6435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6439 { } /* end */
6440};
6441
6442/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006443 * 4ch mode
6444 */
6445static struct hda_verb alc882_3ST_ch4_init[] = {
6446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6450 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6451 { } /* end */
6452};
6453
6454/*
Kailang Yang272a5272007-05-14 11:00:38 +02006455 * 6ch mode
6456 */
6457static struct hda_verb alc882_3ST_ch6_init[] = {
6458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6464 { } /* end */
6465};
6466
Takashi Iwai4953550a2009-06-30 15:28:30 +02006467static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006468 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006469 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006470 { 6, alc882_3ST_ch6_init },
6471};
6472
Takashi Iwai4953550a2009-06-30 15:28:30 +02006473#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6474
Kailang Yang272a5272007-05-14 11:00:38 +02006475/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 * 6ch mode
6477 */
6478static struct hda_verb alc882_sixstack_ch6_init[] = {
6479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6483 { } /* end */
6484};
6485
6486/*
6487 * 8ch mode
6488 */
6489static struct hda_verb alc882_sixstack_ch8_init[] = {
6490 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6492 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6493 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6494 { } /* end */
6495};
6496
6497static struct hda_channel_mode alc882_sixstack_modes[2] = {
6498 { 6, alc882_sixstack_ch6_init },
6499 { 8, alc882_sixstack_ch8_init },
6500};
6501
Takashi Iwai87350ad2007-08-16 18:19:38 +02006502/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006503 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006504 */
6505
6506/*
6507 * 2ch mode
6508 */
6509static struct hda_verb alc885_mbp_ch2_init[] = {
6510 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6511 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6513 { } /* end */
6514};
6515
6516/*
6517 * 6ch mode
6518 */
6519static struct hda_verb alc885_mbp_ch6_init[] = {
6520 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6521 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6522 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6523 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6524 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6525 { } /* end */
6526};
6527
6528static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6529 { 2, alc885_mbp_ch2_init },
6530 { 6, alc885_mbp_ch6_init },
6531};
6532
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006533/*
6534 * 2ch
6535 * Speakers/Woofer/HP = Front
6536 * LineIn = Input
6537 */
6538static struct hda_verb alc885_mb5_ch2_init[] = {
6539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6541 { } /* end */
6542};
6543
6544/*
6545 * 6ch mode
6546 * Speakers/HP = Front
6547 * Woofer = LFE
6548 * LineIn = Surround
6549 */
6550static struct hda_verb alc885_mb5_ch6_init[] = {
6551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6553 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6554 { } /* end */
6555};
6556
6557static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6558 { 2, alc885_mb5_ch2_init },
6559 { 6, alc885_mb5_ch6_init },
6560};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006561
Takashi Iwai4953550a2009-06-30 15:28:30 +02006562
6563/*
6564 * 2ch mode
6565 */
6566static struct hda_verb alc883_4ST_ch2_init[] = {
6567 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6568 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6569 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6570 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6573 { } /* end */
6574};
6575
6576/*
6577 * 4ch mode
6578 */
6579static struct hda_verb alc883_4ST_ch4_init[] = {
6580 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6581 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6582 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6583 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6584 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6585 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6586 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6587 { } /* end */
6588};
6589
6590/*
6591 * 6ch mode
6592 */
6593static struct hda_verb alc883_4ST_ch6_init[] = {
6594 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6595 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6596 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6597 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6598 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6599 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6600 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6601 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6602 { } /* end */
6603};
6604
6605/*
6606 * 8ch mode
6607 */
6608static struct hda_verb alc883_4ST_ch8_init[] = {
6609 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6610 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6611 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6612 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6614 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6618 { } /* end */
6619};
6620
6621static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6622 { 2, alc883_4ST_ch2_init },
6623 { 4, alc883_4ST_ch4_init },
6624 { 6, alc883_4ST_ch6_init },
6625 { 8, alc883_4ST_ch8_init },
6626};
6627
6628
6629/*
6630 * 2ch mode
6631 */
6632static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6633 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6634 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6637 { } /* end */
6638};
6639
6640/*
6641 * 4ch mode
6642 */
6643static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6644 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6645 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6649 { } /* end */
6650};
6651
6652/*
6653 * 6ch mode
6654 */
6655static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6656 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6657 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6658 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6659 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6660 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6661 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6662 { } /* end */
6663};
6664
6665static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6666 { 2, alc883_3ST_ch2_intel_init },
6667 { 4, alc883_3ST_ch4_intel_init },
6668 { 6, alc883_3ST_ch6_intel_init },
6669};
6670
6671/*
6672 * 6ch mode
6673 */
6674static struct hda_verb alc883_sixstack_ch6_init[] = {
6675 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6676 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6679 { } /* end */
6680};
6681
6682/*
6683 * 8ch mode
6684 */
6685static struct hda_verb alc883_sixstack_ch8_init[] = {
6686 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6687 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6688 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6689 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { } /* end */
6691};
6692
6693static struct hda_channel_mode alc883_sixstack_modes[2] = {
6694 { 6, alc883_sixstack_ch6_init },
6695 { 8, alc883_sixstack_ch8_init },
6696};
6697
6698
Linus Torvalds1da177e2005-04-16 15:20:36 -07006699/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6700 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6701 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006702static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006705 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006706 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006707 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6708 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006709 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6710 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006711 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006712 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6721 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006722 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724 { } /* end */
6725};
6726
Takashi Iwai87350ad2007-08-16 18:19:38 +02006727static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6729 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6730 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6731 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6733 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6735 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006736 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006737 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6738 { } /* end */
6739};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006740
6741static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006742 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6743 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6745 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6746 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6747 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6748 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6749 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6751 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6753 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6754 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6755 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6756 { } /* end */
6757};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006758
Kailang Yangbdd148a2007-05-08 15:19:08 +02006759static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006769 { } /* end */
6770};
6771
Kailang Yang272a5272007-05-14 11:00:38 +02006772static struct snd_kcontrol_new alc882_targa_mixer[] = {
6773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6778 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6779 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006786 { } /* end */
6787};
6788
6789/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6790 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6791 */
6792static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6794 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6796 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6802 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006806 { } /* end */
6807};
6808
Takashi Iwai914759b2007-09-06 14:52:04 +02006809static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006820 { } /* end */
6821};
6822
Kailang Yangdf694da2005-12-05 19:42:22 +01006823static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6824 {
6825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6826 .name = "Channel Mode",
6827 .info = alc_ch_mode_info,
6828 .get = alc_ch_mode_get,
6829 .put = alc_ch_mode_put,
6830 },
6831 { } /* end */
6832};
6833
Takashi Iwai4953550a2009-06-30 15:28:30 +02006834static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006835 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006839 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006843 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006847 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006851
Takashi Iwaicb638122009-07-03 10:56:10 +02006852 /* mute analog input loopbacks */
6853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6858
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006859 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006862 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006863 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006867 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006870 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006871 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006874 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006875 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6878 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6881 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6884 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6887 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006888 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006890
6891 /* FIXME: use matrix-type input source selection */
6892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006893 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006898 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02006903 /* ADC2: mute amp left and right */
6904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006906 /* ADC3: mute amp left and right */
6907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006908 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006909
6910 { }
6911};
6912
Takashi Iwai4953550a2009-06-30 15:28:30 +02006913static struct hda_verb alc882_adc1_init_verbs[] = {
6914 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6919 /* ADC1: mute amp left and right */
6920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6921 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6922 { }
6923};
6924
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006925static struct hda_verb alc882_eapd_verbs[] = {
6926 /* change to EAPD mode */
6927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006929 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006930};
6931
Takashi Iwai4953550a2009-06-30 15:28:30 +02006932#define alc883_init_verbs alc882_base_init_verbs
6933
Tobin Davis9102cd12006-12-15 10:02:12 +01006934/* Mac Pro test */
6935static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006941 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006942 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6943 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006944 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006945 { } /* end */
6946};
6947
6948static struct hda_verb alc882_macpro_init_verbs[] = {
6949 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6953 /* Front Pin: output 0 (0x0c) */
6954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6957 /* Front Mic pin: input vref at 80% */
6958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6960 /* Speaker: output */
6961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6963 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6964 /* Headphone output (output 0 - 0x0c) */
6965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6967 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6968
6969 /* FIXME: use matrix-type input source selection */
6970 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6971 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6976 /* Input mixer2 */
6977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6981 /* Input mixer3 */
6982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6986 /* ADC1: mute amp left and right */
6987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6988 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6989 /* ADC2: mute amp left and right */
6990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6992 /* ADC3: mute amp left and right */
6993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6994 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6995
6996 { }
6997};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006998
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006999/* Macbook 5,1 */
7000static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007001 /* DACs */
7002 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7003 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7004 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7005 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007006 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007010 /* Surround mixer */
7011 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7012 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7013 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7014 /* LFE mixer */
7015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7018 /* HP mixer */
7019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7022 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007025 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7026 /* LFE Pin (0x0e) */
7027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7029 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7030 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007033 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007034 /* Front Mic pin: input vref at 80% */
7035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7037 /* Line In pin */
7038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7040
7041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7045 { }
7046};
7047
Takashi Iwai87350ad2007-08-16 18:19:38 +02007048/* Macbook Pro rev3 */
7049static struct hda_verb alc885_mbp3_init_verbs[] = {
7050 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7054 /* Rear mixer */
7055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7058 /* Front Pin: output 0 (0x0c) */
7059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7062 /* HP Pin: output 0 (0x0d) */
7063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7065 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7067 /* Mic (rear) pin: input vref at 80% */
7068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7070 /* Front Mic pin: input vref at 80% */
7071 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7072 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7073 /* Line In pin: use output 1 when in LineOut mode */
7074 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7075 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7076 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7077
7078 /* FIXME: use matrix-type input source selection */
7079 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7080 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7085 /* Input mixer2 */
7086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7090 /* Input mixer3 */
7091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7095 /* ADC1: mute amp left and right */
7096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7097 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7098 /* ADC2: mute amp left and right */
7099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7101 /* ADC3: mute amp left and right */
7102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7104
7105 { }
7106};
7107
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007108/* iMac 24 mixer. */
7109static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7110 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7111 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7112 { } /* end */
7113};
7114
7115/* iMac 24 init verbs. */
7116static struct hda_verb alc885_imac24_init_verbs[] = {
7117 /* Internal speakers: output 0 (0x0c) */
7118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7120 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7121 /* Internal speakers: output 0 (0x0c) */
7122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7124 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7125 /* Headphone: output 0 (0x0c) */
7126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7128 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7129 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7130 /* Front Mic: input vref at 80% */
7131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7133 { }
7134};
7135
7136/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007137static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007138{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007139 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007140
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007141 spec->autocfg.hp_pins[0] = 0x14;
7142 spec->autocfg.speaker_pins[0] = 0x18;
7143 spec->autocfg.speaker_pins[1] = 0x1a;
7144 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007145}
7146
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007147static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007148{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007149 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007150
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007151 spec->autocfg.hp_pins[0] = 0x15;
7152 spec->autocfg.speaker_pins[0] = 0x14;
7153 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007154}
7155
7156
Kailang Yang272a5272007-05-14 11:00:38 +02007157static struct hda_verb alc882_targa_verbs[] = {
7158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7160
7161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007163
Kailang Yang272a5272007-05-14 11:00:38 +02007164 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7165 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7166 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7167
7168 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007169 { } /* end */
7170};
7171
7172/* toggle speaker-output according to the hp-jack state */
7173static void alc882_targa_automute(struct hda_codec *codec)
7174{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007175 struct alc_spec *spec = codec->spec;
7176 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007177 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007178 spec->jack_present ? 1 : 3);
7179}
7180
7181static void alc882_targa_init_hook(struct hda_codec *codec)
7182{
7183 struct alc_spec *spec = codec->spec;
7184
7185 spec->autocfg.hp_pins[0] = 0x14;
7186 spec->autocfg.speaker_pins[0] = 0x1b;
7187 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007188}
7189
7190static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7191{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007192 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007193 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007194}
7195
7196static struct hda_verb alc882_asus_a7j_verbs[] = {
7197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7199
7200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007203
Kailang Yang272a5272007-05-14 11:00:38 +02007204 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7206 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7207
7208 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7209 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7210 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7211 { } /* end */
7212};
7213
Takashi Iwai914759b2007-09-06 14:52:04 +02007214static struct hda_verb alc882_asus_a7m_verbs[] = {
7215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7217
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7220 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007221
Takashi Iwai914759b2007-09-06 14:52:04 +02007222 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7223 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7224 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7225
7226 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7227 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7228 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7229 { } /* end */
7230};
7231
Tobin Davis9102cd12006-12-15 10:02:12 +01007232static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7233{
7234 unsigned int gpiostate, gpiomask, gpiodir;
7235
7236 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7237 AC_VERB_GET_GPIO_DATA, 0);
7238
7239 if (!muted)
7240 gpiostate |= (1 << pin);
7241 else
7242 gpiostate &= ~(1 << pin);
7243
7244 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7245 AC_VERB_GET_GPIO_MASK, 0);
7246 gpiomask |= (1 << pin);
7247
7248 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7249 AC_VERB_GET_GPIO_DIRECTION, 0);
7250 gpiodir |= (1 << pin);
7251
7252
7253 snd_hda_codec_write(codec, codec->afg, 0,
7254 AC_VERB_SET_GPIO_MASK, gpiomask);
7255 snd_hda_codec_write(codec, codec->afg, 0,
7256 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7257
7258 msleep(1);
7259
7260 snd_hda_codec_write(codec, codec->afg, 0,
7261 AC_VERB_SET_GPIO_DATA, gpiostate);
7262}
7263
Takashi Iwai7debbe52007-08-16 15:01:03 +02007264/* set up GPIO at initialization */
7265static void alc885_macpro_init_hook(struct hda_codec *codec)
7266{
7267 alc882_gpio_mute(codec, 0, 0);
7268 alc882_gpio_mute(codec, 1, 0);
7269}
7270
7271/* set up GPIO and update auto-muting at initialization */
7272static void alc885_imac24_init_hook(struct hda_codec *codec)
7273{
7274 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007275 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007276}
7277
Kailang Yangdf694da2005-12-05 19:42:22 +01007278/*
7279 * generic initialization of ADC, input mixers and output mixers
7280 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007281static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007282 /*
7283 * Unmute ADC0-2 and set the default input to mic-in
7284 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7287 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7289
Takashi Iwaicb53c622007-08-10 17:21:45 +02007290 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007292 * Note: PASD motherboards uses the Line In 2 as the input for
7293 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007294 */
7295 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007301
7302 /*
7303 * Set up output mixers (0x0c - 0x0f)
7304 */
7305 /* set vol=0 to output mixers */
7306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7310 /* set up input amps for analog loopback */
7311 /* Amp Indices: DAC = 0, mixer = 1 */
7312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7320 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7321 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7322
7323 /* FIXME: use matrix-type input source selection */
7324 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007325 /* Input mixer2 */
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7330 /* Input mixer3 */
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7335
7336 { }
7337};
7338
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007339/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7340static struct hda_verb alc889A_mb31_ch2_init[] = {
7341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7342 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7345 { } /* end */
7346};
7347
7348/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7349static struct hda_verb alc889A_mb31_ch4_init[] = {
7350 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7354 { } /* end */
7355};
7356
7357/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7358static struct hda_verb alc889A_mb31_ch5_init[] = {
7359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7363 { } /* end */
7364};
7365
7366/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7367static struct hda_verb alc889A_mb31_ch6_init[] = {
7368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7372 { } /* end */
7373};
7374
7375static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7376 { 2, alc889A_mb31_ch2_init },
7377 { 4, alc889A_mb31_ch4_init },
7378 { 5, alc889A_mb31_ch5_init },
7379 { 6, alc889A_mb31_ch6_init },
7380};
7381
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007382static struct hda_verb alc883_medion_eapd_verbs[] = {
7383 /* eanable EAPD on medion laptop */
7384 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7385 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7386 { }
7387};
7388
Takashi Iwai4953550a2009-06-30 15:28:30 +02007389#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007390
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007391static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7393 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7396 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7397 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7400 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007405 { } /* end */
7406};
7407
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007408static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7410 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7412 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7416 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7417 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7418 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007419 { } /* end */
7420};
7421
Jiang zhefb97dc62008-03-06 11:07:11 +01007422static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7423 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7424 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7425 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7426 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7431 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7432 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007433 { } /* end */
7434};
7435
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007436static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450 { } /* end */
7451};
7452
7453static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7454 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7457 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7458 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7459 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7460 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7461 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007471 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007473 { } /* end */
7474};
7475
Jiang zhe17bba1b2008-06-04 12:11:07 +02007476static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7478 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7480 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7481 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7482 HDA_OUTPUT),
7483 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7484 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7485 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7487 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7488 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7489 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7490 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7496 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007497 { } /* end */
7498};
7499
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007500static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007503 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007504 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007505 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7506 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007507 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7508 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007520 { } /* end */
7521};
7522
Sasha Alexandrc2592492009-06-16 14:52:54 -04007523static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7526 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7528 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7529 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7530 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7531 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7532 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7533 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7534 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7536 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007540 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007541};
Kailang Yangccc656c2006-10-17 12:32:26 +02007542
Sasha Alexandrc2592492009-06-16 14:52:54 -04007543static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007544 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7546 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7547 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7548 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007552 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7553 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7554 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007555 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007556};
Kailang Yangccc656c2006-10-17 12:32:26 +02007557
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007558static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7560 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007561 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7562 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007567 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007568};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007569
Kailang Yang272a5272007-05-14 11:00:38 +02007570static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7571 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7572 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7578 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7579 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007580 { } /* end */
7581};
7582
7583static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7586 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007593 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007594};
Kailang Yang272a5272007-05-14 11:00:38 +02007595
Tobin Davis2880a862007-08-07 11:50:26 +02007596static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7598 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007600 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007605 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007606};
Tobin Davis2880a862007-08-07 11:50:26 +02007607
Tony Vroond2fd4b02009-06-21 00:40:10 +01007608static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7610 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7611 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007613 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7614 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007615 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7616 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7620 { } /* end */
7621};
7622
Kailang Yange2757d52008-08-26 13:17:46 +02007623static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7628 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7629 0x0d, 1, 0x0, HDA_OUTPUT),
7630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7633 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7634 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007635 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7636 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007645 { } /* end */
7646};
7647
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007648static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7649 /* Output mixers */
7650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7651 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7653 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7655 HDA_OUTPUT),
7656 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7657 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7658 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7659 /* Output switches */
7660 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7661 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7662 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7663 /* Boost mixers */
7664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7666 /* Input mixers */
7667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7671 { } /* end */
7672};
7673
Guido Günther3e1647c2009-06-05 00:47:26 +02007674static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
7675 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7676 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7679 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7681 { } /* end */
7682};
7683
Kailang Yange2757d52008-08-26 13:17:46 +02007684static struct hda_bind_ctls alc883_bind_cap_vol = {
7685 .ops = &snd_hda_bind_vol,
7686 .values = {
7687 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7688 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7689 0
7690 },
7691};
7692
7693static struct hda_bind_ctls alc883_bind_cap_switch = {
7694 .ops = &snd_hda_bind_sw,
7695 .values = {
7696 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7697 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7698 0
7699 },
7700};
7701
7702static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007711 { } /* end */
7712};
7713
7714static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007715 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7716 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7717 {
7718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7719 /* .name = "Capture Source", */
7720 .name = "Input Source",
7721 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007722 .info = alc_mux_enum_info,
7723 .get = alc_mux_enum_get,
7724 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007725 },
7726 { } /* end */
7727};
7728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007729static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7730 {
7731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7732 .name = "Channel Mode",
7733 .info = alc_ch_mode_info,
7734 .get = alc_ch_mode_get,
7735 .put = alc_ch_mode_put,
7736 },
7737 { } /* end */
7738};
7739
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007740/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007741static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007742{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007743 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007744
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007745 spec->autocfg.hp_pins[0] = 0x15;
7746 spec->autocfg.speaker_pins[0] = 0x14;
7747 spec->autocfg.speaker_pins[1] = 0x17;
7748 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007749}
7750
7751/* auto-toggle front mic */
7752/*
7753static void alc883_mitac_mic_automute(struct hda_codec *codec)
7754{
7755 unsigned int present;
7756 unsigned char bits;
7757
7758 present = snd_hda_codec_read(codec, 0x18, 0,
7759 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7760 bits = present ? HDA_AMP_MUTE : 0;
7761 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7762}
7763*/
7764
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007765static struct hda_verb alc883_mitac_verbs[] = {
7766 /* HP */
7767 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7769 /* Subwoofer */
7770 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7771 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7772
7773 /* enable unsolicited event */
7774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7775 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7776
7777 { } /* end */
7778};
7779
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007780static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007781 /* HP */
7782 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7784 /* Int speaker */
7785 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7787
7788 /* enable unsolicited event */
7789 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007790 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007791
7792 { } /* end */
7793};
7794
Jiang zhefb97dc62008-03-06 11:07:11 +01007795static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7796 /* HP */
7797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7799 /* Subwoofer */
7800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7802
7803 /* enable unsolicited event */
7804 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7805
7806 { } /* end */
7807};
7808
Sasha Alexandrc2592492009-06-16 14:52:54 -04007809static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7812
7813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7814 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007815
David Heidelberger64a8be72009-06-08 16:15:18 +02007816/* Connect Line-Out side jack (SPDIF) to Side */
7817 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7819 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7820/* Connect Mic jack to CLFE */
7821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7823 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
7824/* Connect Line-in jack to Surround */
7825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7827 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7828/* Connect HP out jack to Front */
7829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7831 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02007832
7833 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02007834
7835 { } /* end */
7836};
7837
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007838static struct hda_verb alc883_lenovo_101e_verbs[] = {
7839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7840 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7841 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7842 { } /* end */
7843};
7844
Kailang Yang272a5272007-05-14 11:00:38 +02007845static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7850 { } /* end */
7851};
7852
7853static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7858 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7859 { } /* end */
7860};
7861
Kailang Yang189609a2007-08-20 11:31:23 +02007862static struct hda_verb alc883_haier_w66_verbs[] = {
7863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7865
7866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7867
7868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7872 { } /* end */
7873};
7874
Kailang Yange2757d52008-08-26 13:17:46 +02007875static struct hda_verb alc888_lenovo_sky_verbs[] = {
7876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7881 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7882 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7884 { } /* end */
7885};
7886
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03007887static struct hda_verb alc888_6st_dell_verbs[] = {
7888 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7889 { }
7890};
7891
Guido Günther3e1647c2009-06-05 00:47:26 +02007892static struct hda_verb alc883_vaiott_verbs[] = {
7893 /* HP */
7894 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7896
7897 /* enable unsolicited event */
7898 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7899
7900 { } /* end */
7901};
7902
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007903static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03007904{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007905 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03007906
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007907 spec->autocfg.hp_pins[0] = 0x1b;
7908 spec->autocfg.speaker_pins[0] = 0x14;
7909 spec->autocfg.speaker_pins[1] = 0x16;
7910 spec->autocfg.speaker_pins[2] = 0x18;
7911 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03007912}
7913
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007914static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007915 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007916 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7917 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03007919 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007920};
7921
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007922/*
7923 * 2ch mode
7924 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007925static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007926 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7927 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7928 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7929 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007930 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007931};
7932
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007933/*
7934 * 4ch mode
7935 */
7936static struct hda_verb alc888_3st_hp_4ch_init[] = {
7937 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7938 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7939 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7940 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7941 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
7942 { } /* end */
7943};
7944
7945/*
7946 * 6ch mode
7947 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007948static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007951 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007952 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7953 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007954 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
7955 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007956};
7957
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007958static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007959 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03007960 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007961 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007962};
7963
Kailang Yang272a5272007-05-14 11:00:38 +02007964/* toggle front-jack and RCA according to the hp-jack state */
7965static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7966{
7967 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007968
Kailang Yang272a5272007-05-14 11:00:38 +02007969 present = snd_hda_codec_read(codec, 0x1b, 0,
7970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007971 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7972 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7973 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7974 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007975}
7976
7977/* toggle RCA according to the front-jack state */
7978static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7979{
7980 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007981
Kailang Yang272a5272007-05-14 11:00:38 +02007982 present = snd_hda_codec_read(codec, 0x14, 0,
7983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007984 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7985 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007986}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007987
Kailang Yang272a5272007-05-14 11:00:38 +02007988static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7989 unsigned int res)
7990{
7991 if ((res >> 26) == ALC880_HP_EVENT)
7992 alc888_lenovo_ms7195_front_automute(codec);
7993 if ((res >> 26) == ALC880_FRONT_EVENT)
7994 alc888_lenovo_ms7195_rca_automute(codec);
7995}
7996
7997static struct hda_verb alc883_medion_md2_verbs[] = {
7998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8000
8001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8002
8003 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8004 { } /* end */
8005};
8006
8007/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008008static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008009{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008010 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008011
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008012 spec->autocfg.hp_pins[0] = 0x14;
8013 spec->autocfg.speaker_pins[0] = 0x15;
8014 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008015}
8016
Kailang Yangccc656c2006-10-17 12:32:26 +02008017/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008018#define alc883_targa_init_hook alc882_targa_init_hook
8019#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008020
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008021static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8022{
8023 unsigned int present;
8024
8025 present = snd_hda_codec_read(codec, 0x18, 0,
8026 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8027 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8028 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8029}
8030
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008031static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008032{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008033 struct alc_spec *spec = codec->spec;
8034
8035 spec->autocfg.hp_pins[0] = 0x15;
8036 spec->autocfg.speaker_pins[0] = 0x14;
8037 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008038 alc883_clevo_m720_mic_automute(codec);
8039}
8040
8041static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008042 unsigned int res)
8043{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008044 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008045 case ALC880_MIC_EVENT:
8046 alc883_clevo_m720_mic_automute(codec);
8047 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008048 default:
8049 alc_automute_amp_unsol_event(codec, res);
8050 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008051 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008052}
8053
Jiang zhefb97dc62008-03-06 11:07:11 +01008054/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008055static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008056{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008057 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008058
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008059 spec->autocfg.hp_pins[0] = 0x14;
8060 spec->autocfg.speaker_pins[0] = 0x15;
8061 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008062}
8063
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008064static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008065{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008066 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008067
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008068 spec->autocfg.hp_pins[0] = 0x1b;
8069 spec->autocfg.speaker_pins[0] = 0x14;
8070 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008071}
8072
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008073static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8074{
8075 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008076 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008077
David Heidelberger64a8be72009-06-08 16:15:18 +02008078 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8079 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008080 bits = present ? HDA_AMP_MUTE : 0;
8081 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8082 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008083}
8084
8085static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8086{
8087 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008088 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008089
8090 present = snd_hda_codec_read(codec, 0x1b, 0,
8091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008092 bits = present ? HDA_AMP_MUTE : 0;
8093 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8094 HDA_AMP_MUTE, bits);
8095 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8096 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008097}
8098
8099static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8100 unsigned int res)
8101{
8102 if ((res >> 26) == ALC880_HP_EVENT)
8103 alc883_lenovo_101e_all_automute(codec);
8104 if ((res >> 26) == ALC880_FRONT_EVENT)
8105 alc883_lenovo_101e_ispeaker_automute(codec);
8106}
8107
Takashi Iwai676a9b52007-08-16 15:23:35 +02008108/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008109static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008110{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008111 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008112
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008113 spec->autocfg.hp_pins[0] = 0x14;
8114 spec->autocfg.speaker_pins[0] = 0x15;
8115 spec->autocfg.speaker_pins[1] = 0x16;
8116 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008117}
8118
Kailang Yangd1a991a2007-08-15 16:21:59 +02008119static struct hda_verb alc883_acer_eapd_verbs[] = {
8120 /* HP Pin: output 0 (0x0c) */
8121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8124 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8126 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008128 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8129 /* eanable EAPD on medion laptop */
8130 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8131 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008132 /* enable unsolicited event */
8133 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008134 { }
8135};
8136
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008137static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008138{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008139 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008140
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008141 spec->autocfg.hp_pins[0] = 0x1b;
8142 spec->autocfg.speaker_pins[0] = 0x14;
8143 spec->autocfg.speaker_pins[1] = 0x15;
8144 spec->autocfg.speaker_pins[2] = 0x16;
8145 spec->autocfg.speaker_pins[3] = 0x17;
8146 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008147}
8148
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008149static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008150{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008151 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008152
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008153 spec->autocfg.hp_pins[0] = 0x1b;
8154 spec->autocfg.speaker_pins[0] = 0x14;
8155 spec->autocfg.speaker_pins[1] = 0x15;
8156 spec->autocfg.speaker_pins[2] = 0x16;
8157 spec->autocfg.speaker_pins[3] = 0x17;
8158 spec->autocfg.speaker_pins[4] = 0x1a;
8159 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008160}
8161
Guido Günther3e1647c2009-06-05 00:47:26 +02008162static void alc883_vaiott_init_hook(struct hda_codec *codec)
8163{
8164 struct alc_spec *spec = codec->spec;
8165
8166 spec->autocfg.hp_pins[0] = 0x15;
8167 spec->autocfg.speaker_pins[0] = 0x14;
8168 spec->autocfg.speaker_pins[1] = 0x17;
8169 alc_automute_amp(codec);
8170}
8171
Kailang Yange2757d52008-08-26 13:17:46 +02008172static struct hda_verb alc888_asus_m90v_verbs[] = {
8173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8176 /* enable unsolicited event */
8177 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8179 { } /* end */
8180};
8181
8182static void alc883_nb_mic_automute(struct hda_codec *codec)
8183{
8184 unsigned int present;
8185
8186 present = snd_hda_codec_read(codec, 0x18, 0,
8187 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8188 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8189 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8190 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8191 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8192}
8193
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008194static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008196 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008197
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008198 spec->autocfg.hp_pins[0] = 0x1b;
8199 spec->autocfg.speaker_pins[0] = 0x14;
8200 spec->autocfg.speaker_pins[1] = 0x15;
8201 spec->autocfg.speaker_pins[2] = 0x16;
8202 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008203}
8204
8205static void alc883_mode2_unsol_event(struct hda_codec *codec,
8206 unsigned int res)
8207{
8208 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008209 case ALC880_MIC_EVENT:
8210 alc883_nb_mic_automute(codec);
8211 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008212 default:
8213 alc_sku_unsol_event(codec, res);
8214 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008215 }
8216}
8217
8218static void alc883_mode2_inithook(struct hda_codec *codec)
8219{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008220 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008221 alc883_nb_mic_automute(codec);
8222}
8223
8224static struct hda_verb alc888_asus_eee1601_verbs[] = {
8225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8229 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8230 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8231 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8232 /* enable unsolicited event */
8233 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8234 { } /* end */
8235};
8236
Kailang Yange2757d52008-08-26 13:17:46 +02008237static void alc883_eee1601_inithook(struct hda_codec *codec)
8238{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008239 struct alc_spec *spec = codec->spec;
8240
8241 spec->autocfg.hp_pins[0] = 0x14;
8242 spec->autocfg.speaker_pins[0] = 0x1b;
8243 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008244}
8245
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008246static struct hda_verb alc889A_mb31_verbs[] = {
8247 /* Init rear pin (used as headphone output) */
8248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8249 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8251 /* Init line pin (used as output in 4ch and 6ch mode) */
8252 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8253 /* Init line 2 pin (used as headphone out by default) */
8254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8256 { } /* end */
8257};
8258
8259/* Mute speakers according to the headphone jack state */
8260static void alc889A_mb31_automute(struct hda_codec *codec)
8261{
8262 unsigned int present;
8263
8264 /* Mute only in 2ch or 4ch mode */
8265 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8266 == 0x00) {
8267 present = snd_hda_codec_read(codec, 0x15, 0,
8268 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8269 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8270 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8271 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8272 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8273 }
8274}
8275
8276static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8277{
8278 if ((res >> 26) == ALC880_HP_EVENT)
8279 alc889A_mb31_automute(codec);
8280}
8281
Takashi Iwai4953550a2009-06-30 15:28:30 +02008282
Takashi Iwaicb53c622007-08-10 17:21:45 +02008283#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008284#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008285#endif
8286
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008287/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008288#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8289#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8290#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8291#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8292
8293static hda_nid_t alc883_slave_dig_outs[] = {
8294 ALC1200_DIGOUT_NID, 0,
8295};
8296
8297static hda_nid_t alc1200_slave_dig_outs[] = {
8298 ALC883_DIGOUT_NID, 0,
8299};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008300
8301/*
8302 * configuration and preset
8303 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008304static const char *alc882_models[ALC882_MODEL_LAST] = {
8305 [ALC882_3ST_DIG] = "3stack-dig",
8306 [ALC882_6ST_DIG] = "6stack-dig",
8307 [ALC882_ARIMA] = "arima",
8308 [ALC882_W2JC] = "w2jc",
8309 [ALC882_TARGA] = "targa",
8310 [ALC882_ASUS_A7J] = "asus-a7j",
8311 [ALC882_ASUS_A7M] = "asus-a7m",
8312 [ALC885_MACPRO] = "macpro",
8313 [ALC885_MB5] = "mb5",
8314 [ALC885_MBP3] = "mbp3",
8315 [ALC885_IMAC24] = "imac24",
8316 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008317 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8318 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008319 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008320 [ALC883_TARGA_DIG] = "targa-dig",
8321 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008322 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008323 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008324 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008325 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008326 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008327 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008328 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008329 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008330 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008331 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008332 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8333 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008334 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008335 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008336 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008337 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008338 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008339 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008340 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008341 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008342 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008343 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008344 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008345 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008346 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008347};
8348
Takashi Iwai4953550a2009-06-30 15:28:30 +02008349static struct snd_pci_quirk alc882_cfg_tbl[] = {
8350 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8351
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008352 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008353 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008354 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008355 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8356 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008357 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008358 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8359 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008360 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8361 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008362 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8363 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008364 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8365 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008366 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8367 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008368 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008369 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008370 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008371 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008372 /* default Acer -- disabled as it causes more problems.
8373 * model=auto should work fine now
8374 */
8375 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008376
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008377 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008378
Tobin Davisfebe3372007-06-12 11:27:46 +02008379 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008380 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8381 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008382 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008383 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008384 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008385
8386 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8387 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8388 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008389 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008390 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8391 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8392 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008393 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008394 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008395 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008396 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008397
8398 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008399 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008400 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008401 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008402 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8403 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008404 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008405 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008406 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8407
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008408 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8409 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8410 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008411 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008412 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008413 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008414 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008415 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008416 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8417 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8418 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8419 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8420 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8421 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008422 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008423 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8424 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8425 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008426 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008427 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8428 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008429 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008430 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008431 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008432 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008433 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008434 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008435 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008436 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008437
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008438 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008439 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8440 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008441 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008442 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008443 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008444 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008445 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008446 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008447 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008448 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008449 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008450 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008451 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8452 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008453 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008454 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008455 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008456 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008457 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008458
Jiang zhe17bba1b2008-06-04 12:11:07 +02008459 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8460 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008461 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008462 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008463 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008464
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008465 {}
8466};
8467
Takashi Iwai4953550a2009-06-30 15:28:30 +02008468/* codec SSID table for Intel Mac */
8469static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8470 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8471 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8472 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8473 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8474 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8475 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8476 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8477 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8478 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8479 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8480 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8481 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8482 * no perfect solution yet
8483 */
8484 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8485 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008486};
8487
Takashi Iwai4953550a2009-06-30 15:28:30 +02008488static struct alc_config_preset alc882_presets[] = {
8489 [ALC882_3ST_DIG] = {
8490 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008491 .init_verbs = { alc882_base_init_verbs,
8492 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008493 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8494 .dac_nids = alc882_dac_nids,
8495 .dig_out_nid = ALC882_DIGOUT_NID,
8496 .dig_in_nid = ALC882_DIGIN_NID,
8497 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8498 .channel_mode = alc882_ch_modes,
8499 .need_dac_fix = 1,
8500 .input_mux = &alc882_capture_source,
8501 },
8502 [ALC882_6ST_DIG] = {
8503 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008504 .init_verbs = { alc882_base_init_verbs,
8505 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008506 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8507 .dac_nids = alc882_dac_nids,
8508 .dig_out_nid = ALC882_DIGOUT_NID,
8509 .dig_in_nid = ALC882_DIGIN_NID,
8510 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8511 .channel_mode = alc882_sixstack_modes,
8512 .input_mux = &alc882_capture_source,
8513 },
8514 [ALC882_ARIMA] = {
8515 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008516 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8517 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008518 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8519 .dac_nids = alc882_dac_nids,
8520 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8521 .channel_mode = alc882_sixstack_modes,
8522 .input_mux = &alc882_capture_source,
8523 },
8524 [ALC882_W2JC] = {
8525 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008526 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8527 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008528 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8529 .dac_nids = alc882_dac_nids,
8530 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8531 .channel_mode = alc880_threestack_modes,
8532 .need_dac_fix = 1,
8533 .input_mux = &alc882_capture_source,
8534 .dig_out_nid = ALC882_DIGOUT_NID,
8535 },
8536 [ALC885_MBP3] = {
8537 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8538 .init_verbs = { alc885_mbp3_init_verbs,
8539 alc880_gpio1_init_verbs },
8540 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8541 .dac_nids = alc882_dac_nids,
8542 .channel_mode = alc885_mbp_6ch_modes,
8543 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8544 .input_mux = &alc882_capture_source,
8545 .dig_out_nid = ALC882_DIGOUT_NID,
8546 .dig_in_nid = ALC882_DIGIN_NID,
8547 .unsol_event = alc_automute_amp_unsol_event,
8548 .init_hook = alc885_mbp3_init_hook,
8549 },
8550 [ALC885_MB5] = {
8551 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8552 .init_verbs = { alc885_mb5_init_verbs,
8553 alc880_gpio1_init_verbs },
8554 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8555 .dac_nids = alc882_dac_nids,
8556 .channel_mode = alc885_mb5_6ch_modes,
8557 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8558 .input_mux = &mb5_capture_source,
8559 .dig_out_nid = ALC882_DIGOUT_NID,
8560 .dig_in_nid = ALC882_DIGIN_NID,
8561 },
8562 [ALC885_MACPRO] = {
8563 .mixers = { alc882_macpro_mixer },
8564 .init_verbs = { alc882_macpro_init_verbs },
8565 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8566 .dac_nids = alc882_dac_nids,
8567 .dig_out_nid = ALC882_DIGOUT_NID,
8568 .dig_in_nid = ALC882_DIGIN_NID,
8569 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8570 .channel_mode = alc882_ch_modes,
8571 .input_mux = &alc882_capture_source,
8572 .init_hook = alc885_macpro_init_hook,
8573 },
8574 [ALC885_IMAC24] = {
8575 .mixers = { alc885_imac24_mixer },
8576 .init_verbs = { alc885_imac24_init_verbs },
8577 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8578 .dac_nids = alc882_dac_nids,
8579 .dig_out_nid = ALC882_DIGOUT_NID,
8580 .dig_in_nid = ALC882_DIGIN_NID,
8581 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8582 .channel_mode = alc882_ch_modes,
8583 .input_mux = &alc882_capture_source,
8584 .unsol_event = alc_automute_amp_unsol_event,
8585 .init_hook = alc885_imac24_init_hook,
8586 },
8587 [ALC882_TARGA] = {
8588 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008589 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008590 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008591 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8592 .dac_nids = alc882_dac_nids,
8593 .dig_out_nid = ALC882_DIGOUT_NID,
8594 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8595 .adc_nids = alc882_adc_nids,
8596 .capsrc_nids = alc882_capsrc_nids,
8597 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8598 .channel_mode = alc882_3ST_6ch_modes,
8599 .need_dac_fix = 1,
8600 .input_mux = &alc882_capture_source,
8601 .unsol_event = alc882_targa_unsol_event,
8602 .init_hook = alc882_targa_init_hook,
8603 },
8604 [ALC882_ASUS_A7J] = {
8605 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008606 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8607 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008608 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8609 .dac_nids = alc882_dac_nids,
8610 .dig_out_nid = ALC882_DIGOUT_NID,
8611 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8612 .adc_nids = alc882_adc_nids,
8613 .capsrc_nids = alc882_capsrc_nids,
8614 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8615 .channel_mode = alc882_3ST_6ch_modes,
8616 .need_dac_fix = 1,
8617 .input_mux = &alc882_capture_source,
8618 },
8619 [ALC882_ASUS_A7M] = {
8620 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008621 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8622 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008623 alc882_asus_a7m_verbs },
8624 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8625 .dac_nids = alc882_dac_nids,
8626 .dig_out_nid = ALC882_DIGOUT_NID,
8627 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8628 .channel_mode = alc880_threestack_modes,
8629 .need_dac_fix = 1,
8630 .input_mux = &alc882_capture_source,
8631 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008632 [ALC883_3ST_2ch_DIG] = {
8633 .mixers = { alc883_3ST_2ch_mixer },
8634 .init_verbs = { alc883_init_verbs },
8635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8636 .dac_nids = alc883_dac_nids,
8637 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008638 .dig_in_nid = ALC883_DIGIN_NID,
8639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8640 .channel_mode = alc883_3ST_2ch_modes,
8641 .input_mux = &alc883_capture_source,
8642 },
8643 [ALC883_3ST_6ch_DIG] = {
8644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8645 .init_verbs = { alc883_init_verbs },
8646 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8647 .dac_nids = alc883_dac_nids,
8648 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008649 .dig_in_nid = ALC883_DIGIN_NID,
8650 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8651 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008652 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008653 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008654 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008655 [ALC883_3ST_6ch] = {
8656 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8657 .init_verbs = { alc883_init_verbs },
8658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8659 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8661 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008662 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008663 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008664 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008665 [ALC883_3ST_6ch_INTEL] = {
8666 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8667 .init_verbs = { alc883_init_verbs },
8668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8669 .dac_nids = alc883_dac_nids,
8670 .dig_out_nid = ALC883_DIGOUT_NID,
8671 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008672 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008673 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8674 .channel_mode = alc883_3ST_6ch_intel_modes,
8675 .need_dac_fix = 1,
8676 .input_mux = &alc883_3stack_6ch_intel,
8677 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008678 [ALC883_6ST_DIG] = {
8679 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8680 .init_verbs = { alc883_init_verbs },
8681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8682 .dac_nids = alc883_dac_nids,
8683 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008684 .dig_in_nid = ALC883_DIGIN_NID,
8685 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8686 .channel_mode = alc883_sixstack_modes,
8687 .input_mux = &alc883_capture_source,
8688 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008689 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008690 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02008691 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8692 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008693 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8694 .dac_nids = alc883_dac_nids,
8695 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008696 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8697 .channel_mode = alc883_3ST_6ch_modes,
8698 .need_dac_fix = 1,
8699 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008700 .unsol_event = alc883_targa_unsol_event,
8701 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008702 },
8703 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008704 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02008705 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8706 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8708 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008709 .adc_nids = alc883_adc_nids_alt,
8710 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008711 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008712 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8713 .channel_mode = alc883_3ST_2ch_modes,
8714 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008715 .unsol_event = alc883_targa_unsol_event,
8716 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008717 },
David Heidelberger64a8be72009-06-08 16:15:18 +02008718 [ALC883_TARGA_8ch_DIG] = {
8719 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8720 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008721 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02008722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8723 .dac_nids = alc883_dac_nids,
8724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8725 .adc_nids = alc883_adc_nids_rev,
8726 .capsrc_nids = alc883_capsrc_nids_rev,
8727 .dig_out_nid = ALC883_DIGOUT_NID,
8728 .dig_in_nid = ALC883_DIGIN_NID,
8729 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
8730 .channel_mode = alc883_4ST_8ch_modes,
8731 .need_dac_fix = 1,
8732 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008733 .unsol_event = alc883_targa_unsol_event,
8734 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02008735 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008736 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008737 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008738 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8739 * and the headphone jack. Turn this on and rely on the
8740 * standard mute methods whenever the user wants to turn
8741 * these outputs off.
8742 */
8743 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008746 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8747 .channel_mode = alc883_3ST_2ch_modes,
8748 .input_mux = &alc883_capture_source,
8749 },
Tobin Davis2880a862007-08-07 11:50:26 +02008750 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008751 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008752 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008753 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8754 .dac_nids = alc883_dac_nids,
8755 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8757 .channel_mode = alc883_3ST_2ch_modes,
8758 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008759 .unsol_event = alc_automute_amp_unsol_event,
8760 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008761 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008762 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008763 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008764 alc883_chmode_mixer },
8765 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8766 alc888_acer_aspire_4930g_verbs },
8767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8768 .dac_nids = alc883_dac_nids,
8769 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8770 .adc_nids = alc883_adc_nids_rev,
8771 .capsrc_nids = alc883_capsrc_nids_rev,
8772 .dig_out_nid = ALC883_DIGOUT_NID,
8773 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8774 .channel_mode = alc883_3ST_6ch_modes,
8775 .need_dac_fix = 1,
8776 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008777 ARRAY_SIZE(alc888_2_capture_sources),
8778 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008779 .unsol_event = alc_automute_amp_unsol_event,
8780 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008781 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01008782 [ALC888_ACER_ASPIRE_6530G] = {
8783 .mixers = { alc888_acer_aspire_6530_mixer },
8784 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8785 alc888_acer_aspire_6530g_verbs },
8786 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8787 .dac_nids = alc883_dac_nids,
8788 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8789 .adc_nids = alc883_adc_nids_rev,
8790 .capsrc_nids = alc883_capsrc_nids_rev,
8791 .dig_out_nid = ALC883_DIGOUT_NID,
8792 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8793 .channel_mode = alc883_3ST_2ch_modes,
8794 .num_mux_defs =
8795 ARRAY_SIZE(alc888_2_capture_sources),
8796 .input_mux = alc888_acer_aspire_6530_sources,
8797 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02008798 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01008799 },
Hector Martin3b315d72009-06-02 10:54:19 +02008800 [ALC888_ACER_ASPIRE_8930G] = {
8801 .mixers = { alc888_base_mixer,
8802 alc883_chmode_mixer },
8803 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02008804 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02008805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8806 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02008807 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8808 .adc_nids = alc889_adc_nids,
8809 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02008810 .dig_out_nid = ALC883_DIGOUT_NID,
8811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8812 .channel_mode = alc883_3ST_6ch_modes,
8813 .need_dac_fix = 1,
8814 .const_channel_count = 6,
8815 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02008816 ARRAY_SIZE(alc889_capture_sources),
8817 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02008818 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02008819 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02008820 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008821 [ALC883_MEDION] = {
8822 .mixers = { alc883_fivestack_mixer,
8823 alc883_chmode_mixer },
8824 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008825 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008826 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8827 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008828 .adc_nids = alc883_adc_nids_alt,
8829 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008830 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8831 .channel_mode = alc883_sixstack_modes,
8832 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008833 },
Kailang Yang272a5272007-05-14 11:00:38 +02008834 [ALC883_MEDION_MD2] = {
8835 .mixers = { alc883_medion_md2_mixer},
8836 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8837 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8838 .dac_nids = alc883_dac_nids,
8839 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008840 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8841 .channel_mode = alc883_3ST_2ch_modes,
8842 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008843 .unsol_event = alc_automute_amp_unsol_event,
8844 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008845 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008846 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008847 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008848 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8850 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8852 .channel_mode = alc883_3ST_2ch_modes,
8853 .input_mux = &alc883_capture_source,
8854 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008855 [ALC883_CLEVO_M720] = {
8856 .mixers = { alc883_clevo_m720_mixer },
8857 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8859 .dac_nids = alc883_dac_nids,
8860 .dig_out_nid = ALC883_DIGOUT_NID,
8861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8862 .channel_mode = alc883_3ST_2ch_modes,
8863 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008864 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008865 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01008866 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008867 [ALC883_LENOVO_101E_2ch] = {
8868 .mixers = { alc883_lenovo_101e_2ch_mixer},
8869 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8870 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8871 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008872 .adc_nids = alc883_adc_nids_alt,
8873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008874 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8875 .channel_mode = alc883_3ST_2ch_modes,
8876 .input_mux = &alc883_lenovo_101e_capture_source,
8877 .unsol_event = alc883_lenovo_101e_unsol_event,
8878 .init_hook = alc883_lenovo_101e_all_automute,
8879 },
Kailang Yang272a5272007-05-14 11:00:38 +02008880 [ALC883_LENOVO_NB0763] = {
8881 .mixers = { alc883_lenovo_nb0763_mixer },
8882 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8883 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8884 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008885 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8886 .channel_mode = alc883_3ST_2ch_modes,
8887 .need_dac_fix = 1,
8888 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008889 .unsol_event = alc_automute_amp_unsol_event,
8890 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02008891 },
8892 [ALC888_LENOVO_MS7195_DIG] = {
8893 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8894 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8895 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8896 .dac_nids = alc883_dac_nids,
8897 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8899 .channel_mode = alc883_3ST_6ch_modes,
8900 .need_dac_fix = 1,
8901 .input_mux = &alc883_capture_source,
8902 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8903 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008904 },
8905 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008906 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02008907 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8908 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8909 .dac_nids = alc883_dac_nids,
8910 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8912 .channel_mode = alc883_3ST_2ch_modes,
8913 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008914 .unsol_event = alc_automute_amp_unsol_event,
8915 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008916 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008917 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008918 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008919 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8921 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008922 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8923 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008924 .need_dac_fix = 1,
8925 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008926 .unsol_event = alc_automute_amp_unsol_event,
8927 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008928 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008929 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008930 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008931 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8932 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8933 .dac_nids = alc883_dac_nids,
8934 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008935 .dig_in_nid = ALC883_DIGIN_NID,
8936 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8937 .channel_mode = alc883_sixstack_modes,
8938 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008939 .unsol_event = alc_automute_amp_unsol_event,
8940 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008941 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008942 [ALC883_MITAC] = {
8943 .mixers = { alc883_mitac_mixer },
8944 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8945 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8946 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008947 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8948 .channel_mode = alc883_3ST_2ch_modes,
8949 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008950 .unsol_event = alc_automute_amp_unsol_event,
8951 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008952 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008953 [ALC883_FUJITSU_PI2515] = {
8954 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8955 .init_verbs = { alc883_init_verbs,
8956 alc883_2ch_fujitsu_pi2515_verbs},
8957 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8958 .dac_nids = alc883_dac_nids,
8959 .dig_out_nid = ALC883_DIGOUT_NID,
8960 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8961 .channel_mode = alc883_3ST_2ch_modes,
8962 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008963 .unsol_event = alc_automute_amp_unsol_event,
8964 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01008965 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008966 [ALC888_FUJITSU_XA3530] = {
8967 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8968 .init_verbs = { alc883_init_verbs,
8969 alc888_fujitsu_xa3530_verbs },
8970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8971 .dac_nids = alc883_dac_nids,
8972 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8973 .adc_nids = alc883_adc_nids_rev,
8974 .capsrc_nids = alc883_capsrc_nids_rev,
8975 .dig_out_nid = ALC883_DIGOUT_NID,
8976 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8977 .channel_mode = alc888_4ST_8ch_intel_modes,
8978 .num_mux_defs =
8979 ARRAY_SIZE(alc888_2_capture_sources),
8980 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008981 .unsol_event = alc_automute_amp_unsol_event,
8982 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008983 },
Kailang Yange2757d52008-08-26 13:17:46 +02008984 [ALC888_LENOVO_SKY] = {
8985 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8986 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8988 .dac_nids = alc883_dac_nids,
8989 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008990 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8991 .channel_mode = alc883_sixstack_modes,
8992 .need_dac_fix = 1,
8993 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008994 .unsol_event = alc_automute_amp_unsol_event,
8995 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02008996 },
8997 [ALC888_ASUS_M90V] = {
8998 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8999 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9001 .dac_nids = alc883_dac_nids,
9002 .dig_out_nid = ALC883_DIGOUT_NID,
9003 .dig_in_nid = ALC883_DIGIN_NID,
9004 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9005 .channel_mode = alc883_3ST_6ch_modes,
9006 .need_dac_fix = 1,
9007 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9008 .unsol_event = alc883_mode2_unsol_event,
9009 .init_hook = alc883_mode2_inithook,
9010 },
9011 [ALC888_ASUS_EEE1601] = {
9012 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009013 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009014 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9015 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9016 .dac_nids = alc883_dac_nids,
9017 .dig_out_nid = ALC883_DIGOUT_NID,
9018 .dig_in_nid = ALC883_DIGIN_NID,
9019 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9020 .channel_mode = alc883_3ST_2ch_modes,
9021 .need_dac_fix = 1,
9022 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009023 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009024 .init_hook = alc883_eee1601_inithook,
9025 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009026 [ALC1200_ASUS_P5Q] = {
9027 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9028 .init_verbs = { alc883_init_verbs },
9029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9030 .dac_nids = alc883_dac_nids,
9031 .dig_out_nid = ALC1200_DIGOUT_NID,
9032 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009033 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009034 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9035 .channel_mode = alc883_sixstack_modes,
9036 .input_mux = &alc883_capture_source,
9037 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009038 [ALC889A_MB31] = {
9039 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9040 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9041 alc880_gpio1_init_verbs },
9042 .adc_nids = alc883_adc_nids,
9043 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9044 .dac_nids = alc883_dac_nids,
9045 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9046 .channel_mode = alc889A_mb31_6ch_modes,
9047 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9048 .input_mux = &alc889A_mb31_capture_source,
9049 .dig_out_nid = ALC883_DIGOUT_NID,
9050 .unsol_event = alc889A_mb31_unsol_event,
9051 .init_hook = alc889A_mb31_automute,
9052 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009053 [ALC883_SONY_VAIO_TT] = {
9054 .mixers = { alc883_vaiott_mixer },
9055 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9056 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9057 .dac_nids = alc883_dac_nids,
9058 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9059 .channel_mode = alc883_3ST_2ch_modes,
9060 .input_mux = &alc883_capture_source,
9061 .unsol_event = alc_automute_amp_unsol_event,
9062 .init_hook = alc883_vaiott_init_hook,
9063 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009064};
9065
9066
9067/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009068 * Pin config fixes
9069 */
9070enum {
9071 PINFIX_ABIT_AW9D_MAX
9072};
9073
9074static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9075 { 0x15, 0x01080104 }, /* side */
9076 { 0x16, 0x01011012 }, /* rear */
9077 { 0x17, 0x01016011 }, /* clfe */
9078 { }
9079};
9080
9081static const struct alc_pincfg *alc882_pin_fixes[] = {
9082 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9083};
9084
9085static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9086 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9087 {}
9088};
9089
9090/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009091 * BIOS auto configuration
9092 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009093static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009094 hda_nid_t nid, int pin_type,
9095 int dac_idx)
9096{
9097 /* set as output */
9098 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009099 int idx;
9100
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009101 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9103 idx = 4;
9104 else
9105 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009106 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9107
9108}
9109
Takashi Iwai4953550a2009-06-30 15:28:30 +02009110static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009111{
9112 struct alc_spec *spec = codec->spec;
9113 int i;
9114
9115 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009116 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009117 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009118 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009119 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009120 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009121 }
9122}
9123
Takashi Iwai4953550a2009-06-30 15:28:30 +02009124static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009125{
9126 struct alc_spec *spec = codec->spec;
9127 hda_nid_t pin;
9128
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009129 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009130 if (pin) /* connect to front */
9131 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009132 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009133 pin = spec->autocfg.speaker_pins[0];
9134 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009135 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009136}
9137
Takashi Iwai4953550a2009-06-30 15:28:30 +02009138static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009139{
9140 struct alc_spec *spec = codec->spec;
9141 int i;
9142
9143 for (i = 0; i < AUTO_PIN_LAST; i++) {
9144 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009145 if (!nid)
9146 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009147 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009148 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9149 snd_hda_codec_write(codec, nid, 0,
9150 AC_VERB_SET_AMP_GAIN_MUTE,
9151 AMP_OUT_MUTE);
9152 }
9153}
9154
9155static void alc882_auto_init_input_src(struct hda_codec *codec)
9156{
9157 struct alc_spec *spec = codec->spec;
9158 int c;
9159
9160 for (c = 0; c < spec->num_adc_nids; c++) {
9161 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9162 hda_nid_t nid = spec->capsrc_nids[c];
9163 unsigned int mux_idx;
9164 const struct hda_input_mux *imux;
9165 int conns, mute, idx, item;
9166
9167 conns = snd_hda_get_connections(codec, nid, conn_list,
9168 ARRAY_SIZE(conn_list));
9169 if (conns < 0)
9170 continue;
9171 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9172 imux = &spec->input_mux[mux_idx];
9173 for (idx = 0; idx < conns; idx++) {
9174 /* if the current connection is the selected one,
9175 * unmute it as default - otherwise mute it
9176 */
9177 mute = AMP_IN_MUTE(idx);
9178 for (item = 0; item < imux->num_items; item++) {
9179 if (imux->items[item].index == idx) {
9180 if (spec->cur_mux[c] == item)
9181 mute = AMP_IN_UNMUTE(idx);
9182 break;
9183 }
9184 }
9185 /* check if we have a selector or mixer
9186 * we could check for the widget type instead, but
9187 * just check for Amp-In presence (in case of mixer
9188 * without amp-in there is something wrong, this
9189 * function shouldn't be used or capsrc nid is wrong)
9190 */
9191 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 snd_hda_codec_write(codec, nid, 0,
9193 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009194 mute);
9195 else if (mute != AMP_IN_MUTE(idx))
9196 snd_hda_codec_write(codec, nid, 0,
9197 AC_VERB_SET_CONNECT_SEL,
9198 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009199 }
9200 }
9201}
9202
Takashi Iwai4953550a2009-06-30 15:28:30 +02009203/* add mic boosts if needed */
9204static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009205{
9206 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009207 int err;
9208 hda_nid_t nid;
9209
9210 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9211 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9212 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9213 "Mic Boost",
9214 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9215 if (err < 0)
9216 return err;
9217 }
9218 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9219 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9220 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9221 "Front Mic Boost",
9222 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9223 if (err < 0)
9224 return err;
9225 }
9226 return 0;
9227}
9228
9229/* almost identical with ALC880 parser... */
9230static int alc882_parse_auto_config(struct hda_codec *codec)
9231{
9232 struct alc_spec *spec = codec->spec;
9233 struct auto_pin_cfg *autocfg = &spec->autocfg;
9234 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009235 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009236 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009237
9238 if (err < 0)
9239 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009240 else if (!err)
9241 return 0; /* no config found */
9242
9243 err = alc_auto_add_mic_boost(codec);
9244 if (err < 0)
9245 return err;
9246
9247 /* hack - override the init verbs */
9248 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009249 /* if ADC 0x07 is available, initialize it, too */
9250 wcap = get_wcaps(codec, 0x07);
9251 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9252 if (wcap == AC_WID_AUD_IN)
9253 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009254
Takashi Iwai4953550a2009-06-30 15:28:30 +02009255 /* digital-mic input pin is excluded in alc880_auto_create..()
9256 * because it's under 0x18
9257 */
9258 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9259 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9260 struct hda_input_mux *imux = &spec->private_imux[0];
9261 for (i = 1; i < 3; i++)
9262 memcpy(&spec->private_imux[i],
9263 &spec->private_imux[0],
9264 sizeof(spec->private_imux[0]));
9265 imux->items[imux->num_items].label = "Int DMic";
9266 imux->items[imux->num_items].index = 0x0b;
9267 imux->num_items++;
9268 spec->num_mux_defs = 3;
9269 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009270 }
9271
Takashi Iwai776e1842007-08-29 15:07:11 +02009272 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009273}
9274
9275/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009276static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009277{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009278 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009279 alc882_auto_init_multi_out(codec);
9280 alc882_auto_init_hp_out(codec);
9281 alc882_auto_init_analog_input(codec);
9282 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009283 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009284 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009285}
9286
Takashi Iwai4953550a2009-06-30 15:28:30 +02009287static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009288{
9289 struct alc_spec *spec;
9290 int err, board_config;
9291
9292 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9293 if (spec == NULL)
9294 return -ENOMEM;
9295
9296 codec->spec = spec;
9297
Takashi Iwai4953550a2009-06-30 15:28:30 +02009298 switch (codec->vendor_id) {
9299 case 0x10ec0882:
9300 case 0x10ec0885:
9301 break;
9302 default:
9303 /* ALC883 and variants */
9304 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9305 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009306 }
9307
Takashi Iwai4953550a2009-06-30 15:28:30 +02009308 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9309 alc882_models,
9310 alc882_cfg_tbl);
9311
9312 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9313 board_config = snd_hda_check_board_codec_sid_config(codec,
9314 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9315
9316 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9317 printk(KERN_INFO "hda_codec: Unknown model for %s, "
9318 "trying auto-probe from BIOS...\n",
9319 codec->chip_name);
9320 board_config = ALC882_AUTO;
9321 }
9322
9323 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9324
9325 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009326 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009327 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009328 if (err < 0) {
9329 alc_free(codec);
9330 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009331 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009332 printk(KERN_INFO
9333 "hda_codec: Cannot set up configuration "
9334 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009335 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009336 }
9337 }
9338
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009339 err = snd_hda_attach_beep_device(codec, 0x1);
9340 if (err < 0) {
9341 alc_free(codec);
9342 return err;
9343 }
9344
Takashi Iwai4953550a2009-06-30 15:28:30 +02009345 if (board_config != ALC882_AUTO)
9346 setup_preset(spec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009347
Takashi Iwai4953550a2009-06-30 15:28:30 +02009348 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9349 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9350 /* FIXME: setup DAC5 */
9351 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9352 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9353
9354 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9355 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9356
9357 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009358 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009359
9360 if (!spec->adc_nids && spec->input_mux) {
9361 int i;
9362 spec->num_adc_nids = 0;
9363 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9364 hda_nid_t cap;
9365 hda_nid_t nid = alc882_adc_nids[i];
9366 unsigned int wcap = get_wcaps(codec, nid);
9367 /* get type */
9368 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9369 if (wcap != AC_WID_AUD_IN)
9370 continue;
9371 spec->private_adc_nids[spec->num_adc_nids] = nid;
9372 err = snd_hda_get_connections(codec, nid, &cap, 1);
9373 if (err < 0)
9374 continue;
9375 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9376 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009377 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009378 spec->adc_nids = spec->private_adc_nids;
9379 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009380 }
9381
Takashi Iwai4953550a2009-06-30 15:28:30 +02009382 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009383 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009384
Takashi Iwai2134ea42008-01-10 16:53:55 +01009385 spec->vmaster_nid = 0x0c;
9386
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009387 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009388 if (board_config == ALC882_AUTO)
9389 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009390#ifdef CONFIG_SND_HDA_POWER_SAVE
9391 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009392 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009393#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009394 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395
9396 return 0;
9397}
9398
Takashi Iwai4953550a2009-06-30 15:28:30 +02009399
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009400/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009401 * ALC262 support
9402 */
9403
9404#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9405#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9406
9407#define alc262_dac_nids alc260_dac_nids
9408#define alc262_adc_nids alc882_adc_nids
9409#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009410#define alc262_capsrc_nids alc882_capsrc_nids
9411#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009412
9413#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009414#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009415
Kailang Yang4e555fe2008-08-26 13:05:55 +02009416static hda_nid_t alc262_dmic_adc_nids[1] = {
9417 /* ADC0 */
9418 0x09
9419};
9420
9421static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9422
Kailang Yangdf694da2005-12-05 19:42:22 +01009423static struct snd_kcontrol_new alc262_base_mixer[] = {
9424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9425 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009435 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9438 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009440 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009441};
9442
Takashi Iwaice875f02008-01-28 18:17:43 +01009443/* update HP, line and mono-out pins according to the master switch */
9444static void alc262_hp_master_update(struct hda_codec *codec)
9445{
9446 struct alc_spec *spec = codec->spec;
9447 int val = spec->master_sw;
9448
9449 /* HP & line-out */
9450 snd_hda_codec_write_cache(codec, 0x1b, 0,
9451 AC_VERB_SET_PIN_WIDGET_CONTROL,
9452 val ? PIN_HP : 0);
9453 snd_hda_codec_write_cache(codec, 0x15, 0,
9454 AC_VERB_SET_PIN_WIDGET_CONTROL,
9455 val ? PIN_HP : 0);
9456 /* mono (speaker) depending on the HP jack sense */
9457 val = val && !spec->jack_present;
9458 snd_hda_codec_write_cache(codec, 0x16, 0,
9459 AC_VERB_SET_PIN_WIDGET_CONTROL,
9460 val ? PIN_OUT : 0);
9461}
9462
9463static void alc262_hp_bpc_automute(struct hda_codec *codec)
9464{
9465 struct alc_spec *spec = codec->spec;
9466 unsigned int presence;
9467 presence = snd_hda_codec_read(codec, 0x1b, 0,
9468 AC_VERB_GET_PIN_SENSE, 0);
9469 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9470 alc262_hp_master_update(codec);
9471}
9472
9473static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9474{
9475 if ((res >> 26) != ALC880_HP_EVENT)
9476 return;
9477 alc262_hp_bpc_automute(codec);
9478}
9479
9480static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9481{
9482 struct alc_spec *spec = codec->spec;
9483 unsigned int presence;
9484 presence = snd_hda_codec_read(codec, 0x15, 0,
9485 AC_VERB_GET_PIN_SENSE, 0);
9486 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9487 alc262_hp_master_update(codec);
9488}
9489
9490static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) != ALC880_HP_EVENT)
9494 return;
9495 alc262_hp_wildwest_automute(codec);
9496}
9497
Takashi Iwaib72519b2009-05-08 14:31:55 +02009498#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009499
9500static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9501 struct snd_ctl_elem_value *ucontrol)
9502{
9503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9504 struct alc_spec *spec = codec->spec;
9505 int val = !!*ucontrol->value.integer.value;
9506
9507 if (val == spec->master_sw)
9508 return 0;
9509 spec->master_sw = val;
9510 alc262_hp_master_update(codec);
9511 return 1;
9512}
9513
Takashi Iwaib72519b2009-05-08 14:31:55 +02009514#define ALC262_HP_MASTER_SWITCH \
9515 { \
9516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9517 .name = "Master Playback Switch", \
9518 .info = snd_ctl_boolean_mono_info, \
9519 .get = alc262_hp_master_sw_get, \
9520 .put = alc262_hp_master_sw_put, \
9521 }
9522
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009523static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009524 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009525 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9526 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009528 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9529 HDA_OUTPUT),
9530 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9531 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009534 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009537 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009538 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9539 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9543 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9544 { } /* end */
9545};
9546
Kailang Yangcd7509a2007-01-26 18:33:17 +01009547static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009548 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009553 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9554 HDA_OUTPUT),
9555 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9556 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009559 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009564 { } /* end */
9565};
9566
9567static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9568 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9569 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009570 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009571 { } /* end */
9572};
9573
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009574/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009575static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009576{
9577 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009578
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009579 spec->autocfg.hp_pins[0] = 0x15;
9580 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9581 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009582}
9583
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009584static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009585 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9586 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9592 { } /* end */
9593};
9594
9595static struct hda_verb alc262_hp_t5735_verbs[] = {
9596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9598
9599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9600 { }
9601};
9602
Kailang Yang8c427222008-01-10 13:03:59 +01009603static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009604 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009606 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9607 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9610 { } /* end */
9611};
9612
9613static struct hda_verb alc262_hp_rp5700_verbs[] = {
9614 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9615 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9618 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9619 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9624 {}
9625};
9626
9627static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9628 .num_items = 1,
9629 .items = {
9630 { "Line", 0x1 },
9631 },
9632};
9633
Takashi Iwai42171c12009-05-08 14:11:43 +02009634/* bind hp and internal speaker mute (with plug check) as master switch */
9635static void alc262_hippo_master_update(struct hda_codec *codec)
9636{
9637 struct alc_spec *spec = codec->spec;
9638 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9639 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9640 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9641 unsigned int mute;
9642
9643 /* HP */
9644 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9645 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9646 HDA_AMP_MUTE, mute);
9647 /* mute internal speaker per jack sense */
9648 if (spec->jack_present)
9649 mute = HDA_AMP_MUTE;
9650 if (line_nid)
9651 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9652 HDA_AMP_MUTE, mute);
9653 if (speaker_nid && speaker_nid != line_nid)
9654 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9655 HDA_AMP_MUTE, mute);
9656}
9657
9658#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9659
9660static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9661 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009662{
9663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009664 struct alc_spec *spec = codec->spec;
9665 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009666
Takashi Iwai42171c12009-05-08 14:11:43 +02009667 if (val == spec->master_sw)
9668 return 0;
9669 spec->master_sw = val;
9670 alc262_hippo_master_update(codec);
9671 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009672}
Takashi Iwai5b319542007-07-26 11:49:22 +02009673
Takashi Iwai42171c12009-05-08 14:11:43 +02009674#define ALC262_HIPPO_MASTER_SWITCH \
9675 { \
9676 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9677 .name = "Master Playback Switch", \
9678 .info = snd_ctl_boolean_mono_info, \
9679 .get = alc262_hippo_master_sw_get, \
9680 .put = alc262_hippo_master_sw_put, \
9681 }
9682
9683static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9684 ALC262_HIPPO_MASTER_SWITCH,
9685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9688 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9689 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9697 { } /* end */
9698};
9699
9700static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9701 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9702 ALC262_HIPPO_MASTER_SWITCH,
9703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9712 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9713 { } /* end */
9714};
9715
9716/* mute/unmute internal speaker according to the hp jack and mute state */
9717static void alc262_hippo_automute(struct hda_codec *codec)
9718{
9719 struct alc_spec *spec = codec->spec;
9720 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9721 unsigned int present;
9722
9723 /* need to execute and sync at first */
9724 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9725 present = snd_hda_codec_read(codec, hp_nid, 0,
9726 AC_VERB_GET_PIN_SENSE, 0);
9727 spec->jack_present = (present & 0x80000000) != 0;
9728 alc262_hippo_master_update(codec);
9729}
9730
9731static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9732{
9733 if ((res >> 26) != ALC880_HP_EVENT)
9734 return;
9735 alc262_hippo_automute(codec);
9736}
9737
9738static void alc262_hippo_init_hook(struct hda_codec *codec)
9739{
9740 struct alc_spec *spec = codec->spec;
9741
9742 spec->autocfg.hp_pins[0] = 0x15;
9743 spec->autocfg.speaker_pins[0] = 0x14;
9744 alc262_hippo_automute(codec);
9745}
9746
9747static void alc262_hippo1_init_hook(struct hda_codec *codec)
9748{
9749 struct alc_spec *spec = codec->spec;
9750
9751 spec->autocfg.hp_pins[0] = 0x1b;
9752 spec->autocfg.speaker_pins[0] = 0x14;
9753 alc262_hippo_automute(codec);
9754}
9755
9756
Kailang Yang272a5272007-05-14 11:00:38 +02009757static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009759 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9762 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9763 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9764 { } /* end */
9765};
9766
Kailang Yang83c34212007-07-05 11:43:05 +02009767static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009768 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9769 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9773 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9774 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9775 { } /* end */
9776};
Kailang Yang272a5272007-05-14 11:00:38 +02009777
Tony Vroonba340e82009-02-02 19:01:30 +00009778static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9779 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9780 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9781 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9782 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9790 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9791 { } /* end */
9792};
9793
9794static struct hda_verb alc262_tyan_verbs[] = {
9795 /* Headphone automute */
9796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9798 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9799
9800 /* P11 AUX_IN, white 4-pin connector */
9801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9802 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9803 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9804 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9805
9806 {}
9807};
9808
9809/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009810static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009811{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009812 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009813
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009814 spec->autocfg.hp_pins[0] = 0x1b;
9815 spec->autocfg.speaker_pins[0] = 0x15;
9816 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009817}
9818
Tony Vroonba340e82009-02-02 19:01:30 +00009819
Kailang Yangdf694da2005-12-05 19:42:22 +01009820#define alc262_capture_mixer alc882_capture_mixer
9821#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9822
9823/*
9824 * generic initialization of ADC, input mixers and output mixers
9825 */
9826static struct hda_verb alc262_init_verbs[] = {
9827 /*
9828 * Unmute ADC0-2 and set the default input to mic-in
9829 */
9830 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9832 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9834 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9836
Takashi Iwaicb53c622007-08-10 17:21:45 +02009837 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009838 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009839 * Note: PASD motherboards uses the Line In 2 as the input for
9840 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009841 */
9842 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009848
9849 /*
9850 * Set up output mixers (0x0c - 0x0e)
9851 */
9852 /* set vol=0 to output mixers */
9853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9856 /* set up input amps for analog loopback */
9857 /* Amp Indices: DAC = 0, mixer = 1 */
9858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9864
9865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9871
9872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9874 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009877
Kailang Yangdf694da2005-12-05 19:42:22 +01009878 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009880
Kailang Yangdf694da2005-12-05 19:42:22 +01009881 /* FIXME: use matrix-type input source selection */
9882 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9883 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9886 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9887 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9888 /* Input mixer2 */
9889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9893 /* Input mixer3 */
9894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009898
9899 { }
9900};
9901
Kailang Yang4e555fe2008-08-26 13:05:55 +02009902static struct hda_verb alc262_eapd_verbs[] = {
9903 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9904 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9905 { }
9906};
9907
Kailang Yangccc656c2006-10-17 12:32:26 +02009908static struct hda_verb alc262_hippo_unsol_verbs[] = {
9909 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9911 {}
9912};
9913
9914static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9916 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9918
9919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9921 {}
9922};
9923
Kailang Yang272a5272007-05-14 11:00:38 +02009924static struct hda_verb alc262_sony_unsol_verbs[] = {
9925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9927 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9928
9929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009931 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009932};
9933
Kailang Yang4e555fe2008-08-26 13:05:55 +02009934static struct hda_input_mux alc262_dmic_capture_source = {
9935 .num_items = 2,
9936 .items = {
9937 { "Int DMic", 0x9 },
9938 { "Mic", 0x0 },
9939 },
9940};
9941
9942static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9944 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009948 { } /* end */
9949};
9950
9951static struct hda_verb alc262_toshiba_s06_verbs[] = {
9952 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9956 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9958 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9959 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9960 {}
9961};
9962
9963static void alc262_dmic_automute(struct hda_codec *codec)
9964{
9965 unsigned int present;
9966
9967 present = snd_hda_codec_read(codec, 0x18, 0,
9968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9969 snd_hda_codec_write(codec, 0x22, 0,
9970 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9971}
9972
Kailang Yang4e555fe2008-08-26 13:05:55 +02009973
9974/* unsolicited event for HP jack sensing */
9975static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9976 unsigned int res)
9977{
Kailang Yang4e555fe2008-08-26 13:05:55 +02009978 if ((res >> 26) == ALC880_MIC_EVENT)
9979 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009980 else
9981 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009982}
9983
9984static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9985{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009986 struct alc_spec *spec = codec->spec;
9987
9988 spec->autocfg.hp_pins[0] = 0x15;
9989 spec->autocfg.speaker_pins[0] = 0x14;
9990 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +02009991 alc262_dmic_automute(codec);
9992}
9993
Takashi Iwai834be882006-03-01 14:16:17 +01009994/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009995 * nec model
9996 * 0x15 = headphone
9997 * 0x16 = internal speaker
9998 * 0x18 = external mic
9999 */
10000
10001static struct snd_kcontrol_new alc262_nec_mixer[] = {
10002 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10003 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10004
10005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10008
10009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10011 { } /* end */
10012};
10013
10014static struct hda_verb alc262_nec_verbs[] = {
10015 /* Unmute Speaker */
10016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10017
10018 /* Headphone */
10019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10021
10022 /* External mic to headphone */
10023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10024 /* External mic to speaker */
10025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10026 {}
10027};
10028
10029/*
Takashi Iwai834be882006-03-01 14:16:17 +010010030 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010031 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10032 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010033 */
10034
10035#define ALC_HP_EVENT 0x37
10036
10037static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10038 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010042 {}
10043};
10044
Jiang zhe0e31daf2008-03-20 12:12:39 +010010045static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10046 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10048 {}
10049};
10050
Takashi Iwai834be882006-03-01 14:16:17 +010010051static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010052 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010053 .items = {
10054 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010055 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010056 { "CD", 0x4 },
10057 },
10058};
10059
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010060static struct hda_input_mux alc262_HP_capture_source = {
10061 .num_items = 5,
10062 .items = {
10063 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010064 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010065 { "Line", 0x2 },
10066 { "CD", 0x4 },
10067 { "AUX IN", 0x6 },
10068 },
10069};
10070
zhejiangaccbe492007-08-31 12:36:05 +020010071static struct hda_input_mux alc262_HP_D7000_capture_source = {
10072 .num_items = 4,
10073 .items = {
10074 { "Mic", 0x0 },
10075 { "Front Mic", 0x2 },
10076 { "Line", 0x1 },
10077 { "CD", 0x4 },
10078 },
10079};
10080
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010081/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010082static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10083{
10084 struct alc_spec *spec = codec->spec;
10085 unsigned int mute;
10086
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010087 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010088 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010089 /* need to execute and sync at first */
10090 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010091 /* check laptop HP jack */
10092 present = snd_hda_codec_read(codec, 0x14, 0,
10093 AC_VERB_GET_PIN_SENSE, 0);
10094 /* need to execute and sync at first */
10095 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10096 /* check docking HP jack */
10097 present |= snd_hda_codec_read(codec, 0x1b, 0,
10098 AC_VERB_GET_PIN_SENSE, 0);
10099 if (present & AC_PINSENSE_PRESENCE)
10100 spec->jack_present = 1;
10101 else
10102 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010103 spec->sense_updated = 1;
10104 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010105 /* unmute internal speaker only if both HPs are unplugged and
10106 * master switch is on
10107 */
10108 if (spec->jack_present)
10109 mute = HDA_AMP_MUTE;
10110 else
Takashi Iwai834be882006-03-01 14:16:17 +010010111 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010112 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10113 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010114}
10115
10116/* unsolicited event for HP jack sensing */
10117static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10118 unsigned int res)
10119{
10120 if ((res >> 26) != ALC_HP_EVENT)
10121 return;
10122 alc262_fujitsu_automute(codec, 1);
10123}
10124
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010125static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10126{
10127 alc262_fujitsu_automute(codec, 1);
10128}
10129
Takashi Iwai834be882006-03-01 14:16:17 +010010130/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010131static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10132 .ops = &snd_hda_bind_vol,
10133 .values = {
10134 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10135 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10136 0
10137 },
10138};
Takashi Iwai834be882006-03-01 14:16:17 +010010139
Jiang zhe0e31daf2008-03-20 12:12:39 +010010140/* mute/unmute internal speaker according to the hp jack and mute state */
10141static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10142{
10143 struct alc_spec *spec = codec->spec;
10144 unsigned int mute;
10145
10146 if (force || !spec->sense_updated) {
10147 unsigned int present_int_hp;
10148 /* need to execute and sync at first */
10149 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10150 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10151 AC_VERB_GET_PIN_SENSE, 0);
10152 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10153 spec->sense_updated = 1;
10154 }
10155 if (spec->jack_present) {
10156 /* mute internal speaker */
10157 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10158 HDA_AMP_MUTE, HDA_AMP_MUTE);
10159 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10160 HDA_AMP_MUTE, HDA_AMP_MUTE);
10161 } else {
10162 /* unmute internal speaker if necessary */
10163 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10164 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10165 HDA_AMP_MUTE, mute);
10166 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10167 HDA_AMP_MUTE, mute);
10168 }
10169}
10170
10171/* unsolicited event for HP jack sensing */
10172static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10173 unsigned int res)
10174{
10175 if ((res >> 26) != ALC_HP_EVENT)
10176 return;
10177 alc262_lenovo_3000_automute(codec, 1);
10178}
10179
Takashi Iwai834be882006-03-01 14:16:17 +010010180/* bind hp and internal speaker mute (with plug check) */
10181static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10182 struct snd_ctl_elem_value *ucontrol)
10183{
10184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10185 long *valp = ucontrol->value.integer.value;
10186 int change;
10187
Tony Vroon5d9fab22008-03-14 17:09:18 +010010188 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10189 HDA_AMP_MUTE,
10190 valp ? 0 : HDA_AMP_MUTE);
10191 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10192 HDA_AMP_MUTE,
10193 valp ? 0 : HDA_AMP_MUTE);
10194
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010195 if (change)
10196 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010197 return change;
10198}
10199
10200static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010201 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010202 {
10203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10204 .name = "Master Playback Switch",
10205 .info = snd_hda_mixer_amp_switch_info,
10206 .get = snd_hda_mixer_amp_switch_get,
10207 .put = alc262_fujitsu_master_sw_put,
10208 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10209 },
10210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010215 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10216 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10217 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010218 { } /* end */
10219};
10220
Jiang zhe0e31daf2008-03-20 12:12:39 +010010221/* bind hp and internal speaker mute (with plug check) */
10222static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10223 struct snd_ctl_elem_value *ucontrol)
10224{
10225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10226 long *valp = ucontrol->value.integer.value;
10227 int change;
10228
10229 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10230 HDA_AMP_MUTE,
10231 valp ? 0 : HDA_AMP_MUTE);
10232
10233 if (change)
10234 alc262_lenovo_3000_automute(codec, 0);
10235 return change;
10236}
10237
10238static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10239 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10240 {
10241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10242 .name = "Master Playback Switch",
10243 .info = snd_hda_mixer_amp_switch_info,
10244 .get = snd_hda_mixer_amp_switch_get,
10245 .put = alc262_lenovo_3000_master_sw_put,
10246 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10247 },
10248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10250 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10253 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10254 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10255 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10256 { } /* end */
10257};
10258
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010259static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10260 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010261 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10264 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10265 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10266 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10267 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10268 { } /* end */
10269};
10270
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010271/* additional init verbs for Benq laptops */
10272static struct hda_verb alc262_EAPD_verbs[] = {
10273 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10274 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10275 {}
10276};
10277
Kailang Yang83c34212007-07-05 11:43:05 +020010278static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10281
10282 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10283 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10284 {}
10285};
10286
Tobin Davisf651b502007-10-26 12:40:47 +020010287/* Samsung Q1 Ultra Vista model setup */
10288static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010289 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10290 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10293 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010294 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010295 { } /* end */
10296};
10297
10298static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010299 /* output mixer */
10300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10303 /* speaker */
10304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10308 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10314 /* internal mic */
10315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10317 /* ADC, choose mic */
10318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010328 {}
10329};
10330
Tobin Davisf651b502007-10-26 12:40:47 +020010331/* mute/unmute internal speaker according to the hp jack and mute state */
10332static void alc262_ultra_automute(struct hda_codec *codec)
10333{
10334 struct alc_spec *spec = codec->spec;
10335 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010336
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010337 mute = 0;
10338 /* auto-mute only when HP is used as HP */
10339 if (!spec->cur_mux[0]) {
10340 unsigned int present;
10341 /* need to execute and sync at first */
10342 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10343 present = snd_hda_codec_read(codec, 0x15, 0,
10344 AC_VERB_GET_PIN_SENSE, 0);
10345 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10346 if (spec->jack_present)
10347 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010348 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010349 /* mute/unmute internal speaker */
10350 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10351 HDA_AMP_MUTE, mute);
10352 /* mute/unmute HP */
10353 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10354 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010355}
10356
10357/* unsolicited event for HP jack sensing */
10358static void alc262_ultra_unsol_event(struct hda_codec *codec,
10359 unsigned int res)
10360{
10361 if ((res >> 26) != ALC880_HP_EVENT)
10362 return;
10363 alc262_ultra_automute(codec);
10364}
10365
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010366static struct hda_input_mux alc262_ultra_capture_source = {
10367 .num_items = 2,
10368 .items = {
10369 { "Mic", 0x1 },
10370 { "Headphone", 0x7 },
10371 },
10372};
10373
10374static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10375 struct snd_ctl_elem_value *ucontrol)
10376{
10377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10378 struct alc_spec *spec = codec->spec;
10379 int ret;
10380
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010381 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010382 if (!ret)
10383 return 0;
10384 /* reprogram the HP pin as mic or HP according to the input source */
10385 snd_hda_codec_write_cache(codec, 0x15, 0,
10386 AC_VERB_SET_PIN_WIDGET_CONTROL,
10387 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10388 alc262_ultra_automute(codec); /* mute/unmute HP */
10389 return ret;
10390}
10391
10392static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10393 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10394 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10395 {
10396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10397 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010398 .info = alc_mux_enum_info,
10399 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010400 .put = alc262_ultra_mux_enum_put,
10401 },
10402 { } /* end */
10403};
10404
Kailang Yangdf694da2005-12-05 19:42:22 +010010405/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010406static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10407 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010408{
10409 hda_nid_t nid;
10410 int err;
10411
10412 spec->multiout.num_dacs = 1; /* only use one dac */
10413 spec->multiout.dac_nids = spec->private_dac_nids;
10414 spec->multiout.dac_nids[0] = 2;
10415
10416 nid = cfg->line_out_pins[0];
10417 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010418 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10419 "Front Playback Volume",
10420 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010423 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10424 "Front Playback Switch",
10425 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10426 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010427 return err;
10428 }
10429
Takashi Iwai82bc9552006-03-21 11:24:42 +010010430 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010431 if (nid) {
10432 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010433 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10434 "Speaker Playback Volume",
10435 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10436 HDA_OUTPUT));
10437 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010438 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010439 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10440 "Speaker Playback Switch",
10441 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10442 HDA_OUTPUT));
10443 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010444 return err;
10445 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010446 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10447 "Speaker Playback Switch",
10448 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10449 HDA_OUTPUT));
10450 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010451 return err;
10452 }
10453 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010454 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010455 if (nid) {
10456 /* spec->multiout.hp_nid = 2; */
10457 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010458 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10459 "Headphone Playback Volume",
10460 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10461 HDA_OUTPUT));
10462 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010463 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010464 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10465 "Headphone Playback Switch",
10466 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10467 HDA_OUTPUT));
10468 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010469 return err;
10470 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010471 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10472 "Headphone Playback Switch",
10473 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10474 HDA_OUTPUT));
10475 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010476 return err;
10477 }
10478 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010479 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010480}
10481
Takashi Iwai8c927b42009-06-22 10:56:54 +020010482static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10483 const struct auto_pin_cfg *cfg)
10484{
10485 int err;
10486
10487 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10488 if (err < 0)
10489 return err;
10490 /* digital-mic input pin is excluded in alc880_auto_create..()
10491 * because it's under 0x18
10492 */
10493 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10494 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10495 struct hda_input_mux *imux = &spec->private_imux[0];
10496 imux->items[imux->num_items].label = "Int Mic";
10497 imux->items[imux->num_items].index = 0x09;
10498 imux->num_items++;
10499 }
10500 return 0;
10501}
10502
Kailang Yangdf694da2005-12-05 19:42:22 +010010503
10504/*
10505 * generic initialization of ADC, input mixers and output mixers
10506 */
10507static struct hda_verb alc262_volume_init_verbs[] = {
10508 /*
10509 * Unmute ADC0-2 and set the default input to mic-in
10510 */
10511 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10513 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10517
Takashi Iwaicb53c622007-08-10 17:21:45 +020010518 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010519 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010520 * Note: PASD motherboards uses the Line In 2 as the input for
10521 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010522 */
10523 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010529
10530 /*
10531 * Set up output mixers (0x0c - 0x0f)
10532 */
10533 /* set vol=0 to output mixers */
10534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010537
Kailang Yangdf694da2005-12-05 19:42:22 +010010538 /* set up input amps for analog loopback */
10539 /* Amp Indices: DAC = 0, mixer = 1 */
10540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10546
10547 /* FIXME: use matrix-type input source selection */
10548 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10549 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10554 /* Input mixer2 */
10555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10559 /* Input mixer3 */
10560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10564
10565 { }
10566};
10567
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010568static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10569 /*
10570 * Unmute ADC0-2 and set the default input to mic-in
10571 */
10572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10574 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10576 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10578
Takashi Iwaicb53c622007-08-10 17:21:45 +020010579 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010580 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010581 * Note: PASD motherboards uses the Line In 2 as the input for
10582 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010583 */
10584 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010592
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010593 /*
10594 * Set up output mixers (0x0c - 0x0e)
10595 */
10596 /* set vol=0 to output mixers */
10597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10600
10601 /* set up input amps for analog loopback */
10602 /* Amp Indices: DAC = 0, mixer = 1 */
10603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10609
Takashi Iwaice875f02008-01-28 18:17:43 +010010610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10613
10614 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10616
10617 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10619
10620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10621 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10625
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010627 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10628 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010630 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10631 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10632
10633
10634 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010635 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10636 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010637 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010638 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10639 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10640 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10641 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010646 /* Input mixer2 */
10647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010656 /* Input mixer3 */
10657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10661 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010666
Takashi Iwaice875f02008-01-28 18:17:43 +010010667 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10668
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010669 { }
10670};
10671
Kailang Yangcd7509a2007-01-26 18:33:17 +010010672static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10673 /*
10674 * Unmute ADC0-2 and set the default input to mic-in
10675 */
10676 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682
Takashi Iwaicb53c622007-08-10 17:21:45 +020010683 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010684 * mixer widget
10685 * Note: PASD motherboards uses the Line In 2 as the input for front
10686 * panel mic (mic 2)
10687 */
10688 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010697 /*
10698 * Set up output mixers (0x0c - 0x0e)
10699 */
10700 /* set vol=0 to output mixers */
10701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10704
10705 /* set up input amps for analog loopback */
10706 /* Amp Indices: DAC = 0, mixer = 1 */
10707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10713
10714
10715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10716 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10719 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10721 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10722
10723 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10725
10726 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10728
10729 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10733 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10734 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10735
10736 /* FIXME: use matrix-type input source selection */
10737 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10738 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10744 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10746 /* Input mixer2 */
10747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10749 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10752 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10754 /* Input mixer3 */
10755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10760 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10762
Takashi Iwaice875f02008-01-28 18:17:43 +010010763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10764
Kailang Yangcd7509a2007-01-26 18:33:17 +010010765 { }
10766};
10767
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010768static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10769
10770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10772 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10773
10774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10778
10779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10781 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10782 {}
10783};
10784
10785
Takashi Iwaicb53c622007-08-10 17:21:45 +020010786#ifdef CONFIG_SND_HDA_POWER_SAVE
10787#define alc262_loopbacks alc880_loopbacks
10788#endif
10789
Sasha Alexandrdef319f2009-06-16 16:00:15 -040010790/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010791#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10792#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10793#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10794#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10795
10796/*
10797 * BIOS auto configuration
10798 */
10799static int alc262_parse_auto_config(struct hda_codec *codec)
10800{
10801 struct alc_spec *spec = codec->spec;
10802 int err;
10803 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10804
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010805 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10806 alc262_ignore);
10807 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010808 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010809 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010810 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010811 spec->multiout.max_channels = 2;
10812 spec->no_analog = 1;
10813 goto dig_only;
10814 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010815 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010816 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010817 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10818 if (err < 0)
10819 return err;
10820 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10821 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010822 return err;
10823
10824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10825
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010826 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010827 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010828 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010829 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010830 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010831 if (spec->autocfg.dig_in_pin)
10832 spec->dig_in_nid = ALC262_DIGIN_NID;
10833
Takashi Iwai603c4012008-07-30 15:01:44 +020010834 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010835 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010836
Takashi Iwaid88897e2008-10-31 15:01:37 +010010837 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010838 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010839 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010840
Takashi Iwai776e1842007-08-29 15:07:11 +020010841 err = alc_auto_add_mic_boost(codec);
10842 if (err < 0)
10843 return err;
10844
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010845 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10846
Kailang Yangdf694da2005-12-05 19:42:22 +010010847 return 1;
10848}
10849
10850#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10851#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10852#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010853#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010854
10855
10856/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010857static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010858{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010859 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010860 alc262_auto_init_multi_out(codec);
10861 alc262_auto_init_hp_out(codec);
10862 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010863 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010864 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010865 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010866}
10867
10868/*
10869 * configuration and preset
10870 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010871static const char *alc262_models[ALC262_MODEL_LAST] = {
10872 [ALC262_BASIC] = "basic",
10873 [ALC262_HIPPO] = "hippo",
10874 [ALC262_HIPPO_1] = "hippo_1",
10875 [ALC262_FUJITSU] = "fujitsu",
10876 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010877 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010878 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010879 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010880 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010881 [ALC262_BENQ_T31] = "benq-t31",
10882 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010883 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010884 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010885 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010886 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010887 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010888 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010889 [ALC262_AUTO] = "auto",
10890};
10891
10892static struct snd_pci_quirk alc262_cfg_tbl[] = {
10893 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010894 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010895 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10896 ALC262_HP_BPC),
10897 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10898 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010899 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10900 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010901 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010902 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010903 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010904 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010905 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010906 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010907 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010908 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010909 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10910 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10911 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010912 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10913 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010914 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010915 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010916 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010917 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010918 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020010919 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010010920 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10921 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010922 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010923 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010924 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010925 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010926 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010927 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010928 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10929 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010930 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010931 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010932 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010933 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010934 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010935 {}
10936};
10937
10938static struct alc_config_preset alc262_presets[] = {
10939 [ALC262_BASIC] = {
10940 .mixers = { alc262_base_mixer },
10941 .init_verbs = { alc262_init_verbs },
10942 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10943 .dac_nids = alc262_dac_nids,
10944 .hp_nid = 0x03,
10945 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10946 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010947 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010948 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010949 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010950 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010951 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10953 .dac_nids = alc262_dac_nids,
10954 .hp_nid = 0x03,
10955 .dig_out_nid = ALC262_DIGOUT_NID,
10956 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10957 .channel_mode = alc262_modes,
10958 .input_mux = &alc262_capture_source,
10959 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010960 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010961 },
10962 [ALC262_HIPPO_1] = {
10963 .mixers = { alc262_hippo1_mixer },
10964 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .dac_nids = alc262_dac_nids,
10967 .hp_nid = 0x02,
10968 .dig_out_nid = ALC262_DIGOUT_NID,
10969 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10970 .channel_mode = alc262_modes,
10971 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010972 .unsol_event = alc262_hippo_unsol_event,
10973 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010974 },
Takashi Iwai834be882006-03-01 14:16:17 +010010975 [ALC262_FUJITSU] = {
10976 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010977 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10978 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10981 .hp_nid = 0x03,
10982 .dig_out_nid = ALC262_DIGOUT_NID,
10983 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10984 .channel_mode = alc262_modes,
10985 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010986 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010987 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010988 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010989 [ALC262_HP_BPC] = {
10990 .mixers = { alc262_HP_BPC_mixer },
10991 .init_verbs = { alc262_HP_BPC_init_verbs },
10992 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10993 .dac_nids = alc262_dac_nids,
10994 .hp_nid = 0x03,
10995 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10996 .channel_mode = alc262_modes,
10997 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010998 .unsol_event = alc262_hp_bpc_unsol_event,
10999 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011000 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011001 [ALC262_HP_BPC_D7000_WF] = {
11002 .mixers = { alc262_HP_BPC_WildWest_mixer },
11003 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11004 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11005 .dac_nids = alc262_dac_nids,
11006 .hp_nid = 0x03,
11007 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11008 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011009 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011010 .unsol_event = alc262_hp_wildwest_unsol_event,
11011 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011012 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011013 [ALC262_HP_BPC_D7000_WL] = {
11014 .mixers = { alc262_HP_BPC_WildWest_mixer,
11015 alc262_HP_BPC_WildWest_option_mixer },
11016 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11018 .dac_nids = alc262_dac_nids,
11019 .hp_nid = 0x03,
11020 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11021 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011022 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011023 .unsol_event = alc262_hp_wildwest_unsol_event,
11024 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011025 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011026 [ALC262_HP_TC_T5735] = {
11027 .mixers = { alc262_hp_t5735_mixer },
11028 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11029 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11030 .dac_nids = alc262_dac_nids,
11031 .hp_nid = 0x03,
11032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11033 .channel_mode = alc262_modes,
11034 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011035 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011036 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011037 },
11038 [ALC262_HP_RP5700] = {
11039 .mixers = { alc262_hp_rp5700_mixer },
11040 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11041 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11042 .dac_nids = alc262_dac_nids,
11043 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11044 .channel_mode = alc262_modes,
11045 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011046 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011047 [ALC262_BENQ_ED8] = {
11048 .mixers = { alc262_base_mixer },
11049 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11051 .dac_nids = alc262_dac_nids,
11052 .hp_nid = 0x03,
11053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11054 .channel_mode = alc262_modes,
11055 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011056 },
Kailang Yang272a5272007-05-14 11:00:38 +020011057 [ALC262_SONY_ASSAMD] = {
11058 .mixers = { alc262_sony_mixer },
11059 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11060 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11061 .dac_nids = alc262_dac_nids,
11062 .hp_nid = 0x02,
11063 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11064 .channel_mode = alc262_modes,
11065 .input_mux = &alc262_capture_source,
11066 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011067 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011068 },
11069 [ALC262_BENQ_T31] = {
11070 .mixers = { alc262_benq_t31_mixer },
11071 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11073 .dac_nids = alc262_dac_nids,
11074 .hp_nid = 0x03,
11075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11076 .channel_mode = alc262_modes,
11077 .input_mux = &alc262_capture_source,
11078 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011079 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011080 },
Tobin Davisf651b502007-10-26 12:40:47 +020011081 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011082 .mixers = { alc262_ultra_mixer },
11083 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011084 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11086 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011087 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11088 .channel_mode = alc262_modes,
11089 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011090 .adc_nids = alc262_adc_nids, /* ADC0 */
11091 .capsrc_nids = alc262_capsrc_nids,
11092 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011093 .unsol_event = alc262_ultra_unsol_event,
11094 .init_hook = alc262_ultra_automute,
11095 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011096 [ALC262_LENOVO_3000] = {
11097 .mixers = { alc262_lenovo_3000_mixer },
11098 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11099 alc262_lenovo_3000_unsol_verbs },
11100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11101 .dac_nids = alc262_dac_nids,
11102 .hp_nid = 0x03,
11103 .dig_out_nid = ALC262_DIGOUT_NID,
11104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11105 .channel_mode = alc262_modes,
11106 .input_mux = &alc262_fujitsu_capture_source,
11107 .unsol_event = alc262_lenovo_3000_unsol_event,
11108 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011109 [ALC262_NEC] = {
11110 .mixers = { alc262_nec_mixer },
11111 .init_verbs = { alc262_nec_verbs },
11112 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11113 .dac_nids = alc262_dac_nids,
11114 .hp_nid = 0x03,
11115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11116 .channel_mode = alc262_modes,
11117 .input_mux = &alc262_capture_source,
11118 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011119 [ALC262_TOSHIBA_S06] = {
11120 .mixers = { alc262_toshiba_s06_mixer },
11121 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11122 alc262_eapd_verbs },
11123 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11124 .capsrc_nids = alc262_dmic_capsrc_nids,
11125 .dac_nids = alc262_dac_nids,
11126 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011127 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011128 .dig_out_nid = ALC262_DIGOUT_NID,
11129 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11130 .channel_mode = alc262_modes,
11131 .input_mux = &alc262_dmic_capture_source,
11132 .unsol_event = alc262_toshiba_s06_unsol_event,
11133 .init_hook = alc262_toshiba_s06_init_hook,
11134 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011135 [ALC262_TOSHIBA_RX1] = {
11136 .mixers = { alc262_toshiba_rx1_mixer },
11137 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11138 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11139 .dac_nids = alc262_dac_nids,
11140 .hp_nid = 0x03,
11141 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11142 .channel_mode = alc262_modes,
11143 .input_mux = &alc262_capture_source,
11144 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011145 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011146 },
Tony Vroonba340e82009-02-02 19:01:30 +000011147 [ALC262_TYAN] = {
11148 .mixers = { alc262_tyan_mixer },
11149 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11150 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11151 .dac_nids = alc262_dac_nids,
11152 .hp_nid = 0x02,
11153 .dig_out_nid = ALC262_DIGOUT_NID,
11154 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11155 .channel_mode = alc262_modes,
11156 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011157 .unsol_event = alc_automute_amp_unsol_event,
11158 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011159 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011160};
11161
11162static int patch_alc262(struct hda_codec *codec)
11163{
11164 struct alc_spec *spec;
11165 int board_config;
11166 int err;
11167
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011169 if (spec == NULL)
11170 return -ENOMEM;
11171
11172 codec->spec = spec;
11173#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011174 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11175 * under-run
11176 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011177 {
11178 int tmp;
11179 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11180 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11181 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11182 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11183 }
11184#endif
11185
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011186 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11187
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011188 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11189 alc262_models,
11190 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011191
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011192 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011193 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11194 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011195 board_config = ALC262_AUTO;
11196 }
11197
11198 if (board_config == ALC262_AUTO) {
11199 /* automatic parse from the BIOS config */
11200 err = alc262_parse_auto_config(codec);
11201 if (err < 0) {
11202 alc_free(codec);
11203 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011204 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011205 printk(KERN_INFO
11206 "hda_codec: Cannot set up configuration "
11207 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011208 board_config = ALC262_BASIC;
11209 }
11210 }
11211
Takashi Iwai07eba612009-02-19 08:06:35 +010011212 if (!spec->no_analog) {
11213 err = snd_hda_attach_beep_device(codec, 0x1);
11214 if (err < 0) {
11215 alc_free(codec);
11216 return err;
11217 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011218 }
11219
Kailang Yangdf694da2005-12-05 19:42:22 +010011220 if (board_config != ALC262_AUTO)
11221 setup_preset(spec, &alc262_presets[board_config]);
11222
Kailang Yangdf694da2005-12-05 19:42:22 +010011223 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11224 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011225
Kailang Yangdf694da2005-12-05 19:42:22 +010011226 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11227 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11228
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011229 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011230 int i;
11231 /* check whether the digital-mic has to be supported */
11232 for (i = 0; i < spec->input_mux->num_items; i++) {
11233 if (spec->input_mux->items[i].index >= 9)
11234 break;
11235 }
11236 if (i < spec->input_mux->num_items) {
11237 /* use only ADC0 */
11238 spec->adc_nids = alc262_dmic_adc_nids;
11239 spec->num_adc_nids = 1;
11240 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011241 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011242 /* all analog inputs */
11243 /* check whether NID 0x07 is valid */
11244 unsigned int wcap = get_wcaps(codec, 0x07);
11245
11246 /* get type */
11247 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11248 if (wcap != AC_WID_AUD_IN) {
11249 spec->adc_nids = alc262_adc_nids_alt;
11250 spec->num_adc_nids =
11251 ARRAY_SIZE(alc262_adc_nids_alt);
11252 spec->capsrc_nids = alc262_capsrc_nids_alt;
11253 } else {
11254 spec->adc_nids = alc262_adc_nids;
11255 spec->num_adc_nids =
11256 ARRAY_SIZE(alc262_adc_nids);
11257 spec->capsrc_nids = alc262_capsrc_nids;
11258 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011259 }
11260 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011261 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011262 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011263 if (!spec->no_analog)
11264 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011265
Takashi Iwai2134ea42008-01-10 16:53:55 +010011266 spec->vmaster_nid = 0x0c;
11267
Kailang Yangdf694da2005-12-05 19:42:22 +010011268 codec->patch_ops = alc_patch_ops;
11269 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011270 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011271#ifdef CONFIG_SND_HDA_POWER_SAVE
11272 if (!spec->loopback.amplist)
11273 spec->loopback.amplist = alc262_loopbacks;
11274#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011275 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011276
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 return 0;
11278}
11279
Kailang Yangdf694da2005-12-05 19:42:22 +010011280/*
Kailang Yanga361d842007-06-05 12:30:55 +020011281 * ALC268 channel source setting (2 channel)
11282 */
11283#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11284#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011285
Kailang Yanga361d842007-06-05 12:30:55 +020011286static hda_nid_t alc268_dac_nids[2] = {
11287 /* front, hp */
11288 0x02, 0x03
11289};
11290
11291static hda_nid_t alc268_adc_nids[2] = {
11292 /* ADC0-1 */
11293 0x08, 0x07
11294};
11295
11296static hda_nid_t alc268_adc_nids_alt[1] = {
11297 /* ADC0 */
11298 0x08
11299};
11300
Takashi Iwaie1406342008-02-11 18:32:32 +010011301static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11302
Kailang Yanga361d842007-06-05 12:30:55 +020011303static struct snd_kcontrol_new alc268_base_mixer[] = {
11304 /* output mixer control */
11305 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11306 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11307 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11310 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11311 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011312 { }
11313};
11314
Takashi Iwai42171c12009-05-08 14:11:43 +020011315static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11316 /* output mixer control */
11317 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11318 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11319 ALC262_HIPPO_MASTER_SWITCH,
11320 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11321 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11322 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11323 { }
11324};
11325
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011326/* bind Beep switches of both NID 0x0f and 0x10 */
11327static struct hda_bind_ctls alc268_bind_beep_sw = {
11328 .ops = &snd_hda_bind_sw,
11329 .values = {
11330 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11331 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11332 0
11333 },
11334};
11335
11336static struct snd_kcontrol_new alc268_beep_mixer[] = {
11337 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11338 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11339 { }
11340};
11341
Kailang Yangd1a991a2007-08-15 16:21:59 +020011342static struct hda_verb alc268_eapd_verbs[] = {
11343 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11344 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11345 { }
11346};
11347
Takashi Iwaid2738092007-08-16 14:59:45 +020011348/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011349static struct hda_verb alc268_toshiba_verbs[] = {
11350 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11351 { } /* end */
11352};
11353
Kailang Yang8ef355d2008-08-26 13:10:22 +020011354static struct hda_input_mux alc268_acer_lc_capture_source = {
11355 .num_items = 2,
11356 .items = {
11357 { "i-Mic", 0x6 },
11358 { "E-Mic", 0x0 },
11359 },
11360};
11361
Takashi Iwaid2738092007-08-16 14:59:45 +020011362/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011363/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011364static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11365 .ops = &snd_hda_bind_vol,
11366 .values = {
11367 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11368 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11369 0
11370 },
11371};
11372
Takashi Iwai889c4392007-08-23 18:56:52 +020011373/* mute/unmute internal speaker according to the hp jack and mute state */
11374static void alc268_acer_automute(struct hda_codec *codec, int force)
11375{
11376 struct alc_spec *spec = codec->spec;
11377 unsigned int mute;
11378
11379 if (force || !spec->sense_updated) {
11380 unsigned int present;
11381 present = snd_hda_codec_read(codec, 0x14, 0,
11382 AC_VERB_GET_PIN_SENSE, 0);
11383 spec->jack_present = (present & 0x80000000) != 0;
11384 spec->sense_updated = 1;
11385 }
11386 if (spec->jack_present)
11387 mute = HDA_AMP_MUTE; /* mute internal speaker */
11388 else /* unmute internal speaker if necessary */
11389 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11390 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11391 HDA_AMP_MUTE, mute);
11392}
11393
11394
11395/* bind hp and internal speaker mute (with plug check) */
11396static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11397 struct snd_ctl_elem_value *ucontrol)
11398{
11399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11400 long *valp = ucontrol->value.integer.value;
11401 int change;
11402
11403 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11404 HDA_AMP_MUTE,
11405 valp[0] ? 0 : HDA_AMP_MUTE);
11406 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11407 HDA_AMP_MUTE,
11408 valp[1] ? 0 : HDA_AMP_MUTE);
11409 if (change)
11410 alc268_acer_automute(codec, 0);
11411 return change;
11412}
Takashi Iwaid2738092007-08-16 14:59:45 +020011413
Kailang Yang8ef355d2008-08-26 13:10:22 +020011414static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11415 /* output mixer control */
11416 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11417 {
11418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11419 .name = "Master Playback Switch",
11420 .info = snd_hda_mixer_amp_switch_info,
11421 .get = snd_hda_mixer_amp_switch_get,
11422 .put = alc268_acer_master_sw_put,
11423 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11424 },
11425 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11426 { }
11427};
11428
Takashi Iwaid2738092007-08-16 14:59:45 +020011429static struct snd_kcontrol_new alc268_acer_mixer[] = {
11430 /* output mixer control */
11431 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11432 {
11433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11434 .name = "Master Playback Switch",
11435 .info = snd_hda_mixer_amp_switch_info,
11436 .get = snd_hda_mixer_amp_switch_get,
11437 .put = alc268_acer_master_sw_put,
11438 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11439 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011440 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11442 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011443 { }
11444};
11445
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011446static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11447 /* output mixer control */
11448 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11449 {
11450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11451 .name = "Master Playback Switch",
11452 .info = snd_hda_mixer_amp_switch_info,
11453 .get = snd_hda_mixer_amp_switch_get,
11454 .put = alc268_acer_master_sw_put,
11455 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11456 },
11457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11458 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11459 { }
11460};
11461
Kailang Yang8ef355d2008-08-26 13:10:22 +020011462static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11467 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11468 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11469 { }
11470};
11471
Takashi Iwaid2738092007-08-16 14:59:45 +020011472static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11474 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011477 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11480 { }
11481};
11482
11483/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011484#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11485#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011486
11487static void alc268_acer_unsol_event(struct hda_codec *codec,
11488 unsigned int res)
11489{
Takashi Iwai889c4392007-08-23 18:56:52 +020011490 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011491 return;
11492 alc268_acer_automute(codec, 1);
11493}
11494
Takashi Iwai889c4392007-08-23 18:56:52 +020011495static void alc268_acer_init_hook(struct hda_codec *codec)
11496{
11497 alc268_acer_automute(codec, 1);
11498}
11499
Kailang Yang8ef355d2008-08-26 13:10:22 +020011500/* toggle speaker-output according to the hp-jack state */
11501static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11502{
11503 unsigned int present;
11504 unsigned char bits;
11505
11506 present = snd_hda_codec_read(codec, 0x15, 0,
11507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11508 bits = present ? AMP_IN_MUTE(0) : 0;
11509 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11510 AMP_IN_MUTE(0), bits);
11511 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11512 AMP_IN_MUTE(0), bits);
11513}
11514
11515
11516static void alc268_acer_mic_automute(struct hda_codec *codec)
11517{
11518 unsigned int present;
11519
11520 present = snd_hda_codec_read(codec, 0x18, 0,
11521 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11522 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11523 present ? 0x0 : 0x6);
11524}
11525
11526static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11527 unsigned int res)
11528{
11529 if ((res >> 26) == ALC880_HP_EVENT)
11530 alc268_aspire_one_speaker_automute(codec);
11531 if ((res >> 26) == ALC880_MIC_EVENT)
11532 alc268_acer_mic_automute(codec);
11533}
11534
11535static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11536{
11537 alc268_aspire_one_speaker_automute(codec);
11538 alc268_acer_mic_automute(codec);
11539}
11540
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011541static struct snd_kcontrol_new alc268_dell_mixer[] = {
11542 /* output mixer control */
11543 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11548 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11549 { }
11550};
11551
11552static struct hda_verb alc268_dell_verbs[] = {
11553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11555 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11556 { }
11557};
11558
11559/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011560static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011561{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011562 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011563
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011564 spec->autocfg.hp_pins[0] = 0x15;
11565 spec->autocfg.speaker_pins[0] = 0x14;
11566 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011567}
11568
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011569static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11571 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11575 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11576 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11577 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11578 { }
11579};
11580
11581static struct hda_verb alc267_quanta_il1_verbs[] = {
11582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11584 { }
11585};
11586
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011587static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11588{
11589 unsigned int present;
11590
11591 present = snd_hda_codec_read(codec, 0x18, 0,
11592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11593 snd_hda_codec_write(codec, 0x23, 0,
11594 AC_VERB_SET_CONNECT_SEL,
11595 present ? 0x00 : 0x01);
11596}
11597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011598static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011600 struct alc_spec *spec = codec->spec;
11601
11602 spec->autocfg.hp_pins[0] = 0x15;
11603 spec->autocfg.speaker_pins[0] = 0x14;
11604 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011605 alc267_quanta_il1_mic_automute(codec);
11606}
11607
11608static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11609 unsigned int res)
11610{
11611 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011612 case ALC880_MIC_EVENT:
11613 alc267_quanta_il1_mic_automute(codec);
11614 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011615 default:
11616 alc_sku_unsol_event(codec, res);
11617 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011618 }
11619}
11620
Kailang Yanga361d842007-06-05 12:30:55 +020011621/*
11622 * generic initialization of ADC, input mixers and output mixers
11623 */
11624static struct hda_verb alc268_base_init_verbs[] = {
11625 /* Unmute DAC0-1 and set vol = 0 */
11626 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011628
11629 /*
11630 * Set up output mixers (0x0c - 0x0e)
11631 */
11632 /* set vol=0 to output mixers */
11633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011634 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11635
11636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11637 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11638
11639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11641 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11646 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11647
11648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011653
11654 /* set PCBEEP vol = 0, mute connections */
11655 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11656 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11657 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011658
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011659 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011660
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011661 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11663 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011665
Kailang Yanga361d842007-06-05 12:30:55 +020011666 { }
11667};
11668
11669/*
11670 * generic initialization of ADC, input mixers and output mixers
11671 */
11672static struct hda_verb alc268_volume_init_verbs[] = {
11673 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11675 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011676
11677 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11680 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11681 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11682
Kailang Yanga361d842007-06-05 12:30:55 +020011683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11686
11687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011689
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011690 /* set PCBEEP vol = 0, mute connections */
11691 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11693 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011694
11695 { }
11696};
11697
Kailang Yanga361d842007-06-05 12:30:55 +020011698static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11699 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11700 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11701 {
11702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11703 /* The multiple "Capture Source" controls confuse alsamixer
11704 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011705 */
11706 /* .name = "Capture Source", */
11707 .name = "Input Source",
11708 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011709 .info = alc_mux_enum_info,
11710 .get = alc_mux_enum_get,
11711 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011712 },
11713 { } /* end */
11714};
11715
11716static struct snd_kcontrol_new alc268_capture_mixer[] = {
11717 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11718 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11719 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11720 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11721 {
11722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11723 /* The multiple "Capture Source" controls confuse alsamixer
11724 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011725 */
11726 /* .name = "Capture Source", */
11727 .name = "Input Source",
11728 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011729 .info = alc_mux_enum_info,
11730 .get = alc_mux_enum_get,
11731 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011732 },
11733 { } /* end */
11734};
11735
11736static struct hda_input_mux alc268_capture_source = {
11737 .num_items = 4,
11738 .items = {
11739 { "Mic", 0x0 },
11740 { "Front Mic", 0x1 },
11741 { "Line", 0x2 },
11742 { "CD", 0x3 },
11743 },
11744};
11745
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011746static struct hda_input_mux alc268_acer_capture_source = {
11747 .num_items = 3,
11748 .items = {
11749 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011750 { "Internal Mic", 0x1 },
11751 { "Line", 0x2 },
11752 },
11753};
11754
11755static struct hda_input_mux alc268_acer_dmic_capture_source = {
11756 .num_items = 3,
11757 .items = {
11758 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011759 { "Internal Mic", 0x6 },
11760 { "Line", 0x2 },
11761 },
11762};
11763
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011764#ifdef CONFIG_SND_DEBUG
11765static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011766 /* Volume widgets */
11767 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11768 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11769 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11770 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11771 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11772 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11773 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11774 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11775 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11776 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11777 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11778 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11779 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011780 /* The below appears problematic on some hardwares */
11781 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011782 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11783 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11784 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11785 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11786
11787 /* Modes for retasking pin widgets */
11788 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11789 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11790 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11791 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11792
11793 /* Controls for GPIO pins, assuming they are configured as outputs */
11794 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11795 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11796 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11797 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11798
11799 /* Switches to allow the digital SPDIF output pin to be enabled.
11800 * The ALC268 does not have an SPDIF input.
11801 */
11802 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11803
11804 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11805 * this output to turn on an external amplifier.
11806 */
11807 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11808 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11809
11810 { } /* end */
11811};
11812#endif
11813
Kailang Yanga361d842007-06-05 12:30:55 +020011814/* create input playback/capture controls for the given pin */
11815static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11816 const char *ctlname, int idx)
11817{
11818 char name[32];
11819 int err;
11820
11821 sprintf(name, "%s Playback Volume", ctlname);
11822 if (nid == 0x14) {
11823 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11824 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11825 HDA_OUTPUT));
11826 if (err < 0)
11827 return err;
11828 } else if (nid == 0x15) {
11829 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11830 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11831 HDA_OUTPUT));
11832 if (err < 0)
11833 return err;
11834 } else
11835 return -1;
11836 sprintf(name, "%s Playback Switch", ctlname);
11837 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11838 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11839 if (err < 0)
11840 return err;
11841 return 0;
11842}
11843
11844/* add playback controls from the parsed DAC table */
11845static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11846 const struct auto_pin_cfg *cfg)
11847{
11848 hda_nid_t nid;
11849 int err;
11850
11851 spec->multiout.num_dacs = 2; /* only use one dac */
11852 spec->multiout.dac_nids = spec->private_dac_nids;
11853 spec->multiout.dac_nids[0] = 2;
11854 spec->multiout.dac_nids[1] = 3;
11855
11856 nid = cfg->line_out_pins[0];
11857 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011858 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011859
11860 nid = cfg->speaker_pins[0];
11861 if (nid == 0x1d) {
11862 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11863 "Speaker Playback Volume",
11864 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11865 if (err < 0)
11866 return err;
11867 }
11868 nid = cfg->hp_pins[0];
11869 if (nid)
11870 alc268_new_analog_output(spec, nid, "Headphone", 0);
11871
11872 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11873 if (nid == 0x16) {
11874 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11875 "Mono Playback Switch",
11876 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11877 if (err < 0)
11878 return err;
11879 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011880 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011881}
11882
11883/* create playback/capture controls for input pins */
11884static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11885 const struct auto_pin_cfg *cfg)
11886{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011887 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011888 int i, idx1;
11889
11890 for (i = 0; i < AUTO_PIN_LAST; i++) {
11891 switch(cfg->input_pins[i]) {
11892 case 0x18:
11893 idx1 = 0; /* Mic 1 */
11894 break;
11895 case 0x19:
11896 idx1 = 1; /* Mic 2 */
11897 break;
11898 case 0x1a:
11899 idx1 = 2; /* Line In */
11900 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011901 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011902 idx1 = 3; /* CD */
11903 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011904 case 0x12:
11905 case 0x13:
11906 idx1 = 6; /* digital mics */
11907 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011908 default:
11909 continue;
11910 }
11911 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11912 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011913 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011914 }
11915 return 0;
11916}
11917
11918static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11919{
11920 struct alc_spec *spec = codec->spec;
11921 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11922 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11923 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11924 unsigned int dac_vol1, dac_vol2;
11925
11926 if (speaker_nid) {
11927 snd_hda_codec_write(codec, speaker_nid, 0,
11928 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11929 snd_hda_codec_write(codec, 0x0f, 0,
11930 AC_VERB_SET_AMP_GAIN_MUTE,
11931 AMP_IN_UNMUTE(1));
11932 snd_hda_codec_write(codec, 0x10, 0,
11933 AC_VERB_SET_AMP_GAIN_MUTE,
11934 AMP_IN_UNMUTE(1));
11935 } else {
11936 snd_hda_codec_write(codec, 0x0f, 0,
11937 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11938 snd_hda_codec_write(codec, 0x10, 0,
11939 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11940 }
11941
11942 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011943 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011944 dac_vol2 = AMP_OUT_ZERO;
11945 else if (line_nid == 0x15)
11946 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011947 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011948 dac_vol2 = AMP_OUT_ZERO;
11949 else if (hp_nid == 0x15)
11950 dac_vol1 = AMP_OUT_ZERO;
11951 if (line_nid != 0x16 || hp_nid != 0x16 ||
11952 spec->autocfg.line_out_pins[1] != 0x16 ||
11953 spec->autocfg.line_out_pins[2] != 0x16)
11954 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11955
11956 snd_hda_codec_write(codec, 0x02, 0,
11957 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11958 snd_hda_codec_write(codec, 0x03, 0,
11959 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11960}
11961
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011962/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020011963#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11964#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011965#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011966#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11967
11968/*
11969 * BIOS auto configuration
11970 */
11971static int alc268_parse_auto_config(struct hda_codec *codec)
11972{
11973 struct alc_spec *spec = codec->spec;
11974 int err;
11975 static hda_nid_t alc268_ignore[] = { 0 };
11976
11977 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11978 alc268_ignore);
11979 if (err < 0)
11980 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011981 if (!spec->autocfg.line_outs) {
11982 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11983 spec->multiout.max_channels = 2;
11984 spec->no_analog = 1;
11985 goto dig_only;
11986 }
Kailang Yanga361d842007-06-05 12:30:55 +020011987 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011988 }
Kailang Yanga361d842007-06-05 12:30:55 +020011989 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11990 if (err < 0)
11991 return err;
11992 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11993 if (err < 0)
11994 return err;
11995
11996 spec->multiout.max_channels = 2;
11997
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011998 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011999 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012000 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012001 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012002 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12003 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012004 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012005 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012006
Takashi Iwai892981f2009-03-02 08:04:35 +010012007 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012008 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012009
Takashi Iwaid88897e2008-10-31 15:01:37 +010012010 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012011 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012012 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012013
Takashi Iwai776e1842007-08-29 15:07:11 +020012014 err = alc_auto_add_mic_boost(codec);
12015 if (err < 0)
12016 return err;
12017
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012018 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12019
Kailang Yanga361d842007-06-05 12:30:55 +020012020 return 1;
12021}
12022
12023#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12024#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12025#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12026
12027/* init callback for auto-configuration model -- overriding the default init */
12028static void alc268_auto_init(struct hda_codec *codec)
12029{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012030 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012031 alc268_auto_init_multi_out(codec);
12032 alc268_auto_init_hp_out(codec);
12033 alc268_auto_init_mono_speaker_out(codec);
12034 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012035 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012036 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012037}
12038
12039/*
12040 * configuration and preset
12041 */
12042static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012043 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012044 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012045 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012046 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012047 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012048 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012049 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012050 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012051#ifdef CONFIG_SND_DEBUG
12052 [ALC268_TEST] = "test",
12053#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012054 [ALC268_AUTO] = "auto",
12055};
12056
12057static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012058 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012059 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012060 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012061 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012062 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012063 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12064 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012065 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012066 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012067 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12068 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012069 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012070 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12071 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12072 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012073 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012074 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012075 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012076 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012077 {}
12078};
12079
12080static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012081 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012082 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012083 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12084 alc267_quanta_il1_verbs },
12085 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12086 .dac_nids = alc268_dac_nids,
12087 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12088 .adc_nids = alc268_adc_nids_alt,
12089 .hp_nid = 0x03,
12090 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12091 .channel_mode = alc268_modes,
12092 .input_mux = &alc268_capture_source,
12093 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012094 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012095 },
Kailang Yanga361d842007-06-05 12:30:55 +020012096 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012097 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12098 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012099 .init_verbs = { alc268_base_init_verbs },
12100 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12101 .dac_nids = alc268_dac_nids,
12102 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12103 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012104 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012105 .hp_nid = 0x03,
12106 .dig_out_nid = ALC268_DIGOUT_NID,
12107 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12108 .channel_mode = alc268_modes,
12109 .input_mux = &alc268_capture_source,
12110 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012111 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012112 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012113 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012114 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12115 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012116 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12117 .dac_nids = alc268_dac_nids,
12118 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12119 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012120 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012121 .hp_nid = 0x03,
12122 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12123 .channel_mode = alc268_modes,
12124 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012125 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012126 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012127 },
12128 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012129 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12130 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012131 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12132 alc268_acer_verbs },
12133 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12134 .dac_nids = alc268_dac_nids,
12135 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12136 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012137 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012138 .hp_nid = 0x02,
12139 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12140 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012141 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012142 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012143 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012144 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012145 [ALC268_ACER_DMIC] = {
12146 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12147 alc268_beep_mixer },
12148 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12149 alc268_acer_verbs },
12150 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12151 .dac_nids = alc268_dac_nids,
12152 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12153 .adc_nids = alc268_adc_nids_alt,
12154 .capsrc_nids = alc268_capsrc_nids,
12155 .hp_nid = 0x02,
12156 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12157 .channel_mode = alc268_modes,
12158 .input_mux = &alc268_acer_dmic_capture_source,
12159 .unsol_event = alc268_acer_unsol_event,
12160 .init_hook = alc268_acer_init_hook,
12161 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012162 [ALC268_ACER_ASPIRE_ONE] = {
12163 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012164 alc268_beep_mixer,
12165 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012166 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12167 alc268_acer_aspire_one_verbs },
12168 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12169 .dac_nids = alc268_dac_nids,
12170 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12171 .adc_nids = alc268_adc_nids_alt,
12172 .capsrc_nids = alc268_capsrc_nids,
12173 .hp_nid = 0x03,
12174 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12175 .channel_mode = alc268_modes,
12176 .input_mux = &alc268_acer_lc_capture_source,
12177 .unsol_event = alc268_acer_lc_unsol_event,
12178 .init_hook = alc268_acer_lc_init_hook,
12179 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012180 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012181 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012182 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12183 alc268_dell_verbs },
12184 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12185 .dac_nids = alc268_dac_nids,
12186 .hp_nid = 0x02,
12187 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12188 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012189 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012190 .init_hook = alc268_dell_init_hook,
12191 .input_mux = &alc268_capture_source,
12192 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012193 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012194 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12195 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012196 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12197 alc268_toshiba_verbs },
12198 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12199 .dac_nids = alc268_dac_nids,
12200 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12201 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012202 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012203 .hp_nid = 0x03,
12204 .dig_out_nid = ALC268_DIGOUT_NID,
12205 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12206 .channel_mode = alc268_modes,
12207 .input_mux = &alc268_capture_source,
12208 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012209 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012210 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012211#ifdef CONFIG_SND_DEBUG
12212 [ALC268_TEST] = {
12213 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12214 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12215 alc268_volume_init_verbs },
12216 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12217 .dac_nids = alc268_dac_nids,
12218 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12219 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012220 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012221 .hp_nid = 0x03,
12222 .dig_out_nid = ALC268_DIGOUT_NID,
12223 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12224 .channel_mode = alc268_modes,
12225 .input_mux = &alc268_capture_source,
12226 },
12227#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012228};
12229
12230static int patch_alc268(struct hda_codec *codec)
12231{
12232 struct alc_spec *spec;
12233 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012234 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012235
12236 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12237 if (spec == NULL)
12238 return -ENOMEM;
12239
12240 codec->spec = spec;
12241
12242 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12243 alc268_models,
12244 alc268_cfg_tbl);
12245
12246 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012247 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12248 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012249 board_config = ALC268_AUTO;
12250 }
12251
12252 if (board_config == ALC268_AUTO) {
12253 /* automatic parse from the BIOS config */
12254 err = alc268_parse_auto_config(codec);
12255 if (err < 0) {
12256 alc_free(codec);
12257 return err;
12258 } else if (!err) {
12259 printk(KERN_INFO
12260 "hda_codec: Cannot set up configuration "
12261 "from BIOS. Using base mode...\n");
12262 board_config = ALC268_3ST;
12263 }
12264 }
12265
12266 if (board_config != ALC268_AUTO)
12267 setup_preset(spec, &alc268_presets[board_config]);
12268
Kailang Yanga361d842007-06-05 12:30:55 +020012269 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12270 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012271 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012272
Kailang Yanga361d842007-06-05 12:30:55 +020012273 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12274
Takashi Iwai22971e32009-02-10 11:56:44 +010012275 has_beep = 0;
12276 for (i = 0; i < spec->num_mixers; i++) {
12277 if (spec->mixers[i] == alc268_beep_mixer) {
12278 has_beep = 1;
12279 break;
12280 }
12281 }
12282
12283 if (has_beep) {
12284 err = snd_hda_attach_beep_device(codec, 0x1);
12285 if (err < 0) {
12286 alc_free(codec);
12287 return err;
12288 }
12289 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12290 /* override the amp caps for beep generator */
12291 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012292 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12293 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12294 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12295 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012296 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012297
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012298 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012299 /* check whether NID 0x07 is valid */
12300 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012301 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012302
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012303 /* get type */
12304 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012305 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012306 spec->adc_nids = alc268_adc_nids_alt;
12307 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012308 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012309 } else {
12310 spec->adc_nids = alc268_adc_nids;
12311 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012312 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012313 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012314 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012315 /* set default input source */
12316 for (i = 0; i < spec->num_adc_nids; i++)
12317 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12318 0, AC_VERB_SET_CONNECT_SEL,
12319 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012320 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012321
12322 spec->vmaster_nid = 0x02;
12323
Kailang Yanga361d842007-06-05 12:30:55 +020012324 codec->patch_ops = alc_patch_ops;
12325 if (board_config == ALC268_AUTO)
12326 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012327
Takashi Iwaidaead532008-11-28 12:55:36 +010012328 codec->proc_widget_hook = print_realtek_coef;
12329
Kailang Yanga361d842007-06-05 12:30:55 +020012330 return 0;
12331}
12332
12333/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012334 * ALC269 channel source setting (2 channel)
12335 */
12336#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12337
12338#define alc269_dac_nids alc260_dac_nids
12339
12340static hda_nid_t alc269_adc_nids[1] = {
12341 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012342 0x08,
12343};
12344
Takashi Iwaie01bf502008-08-21 16:25:07 +020012345static hda_nid_t alc269_capsrc_nids[1] = {
12346 0x23,
12347};
12348
12349/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12350 * not a mux!
12351 */
12352
Kailang Yangf53281e2008-07-18 12:36:43 +020012353static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12354 .num_items = 2,
12355 .items = {
12356 { "i-Mic", 0x5 },
12357 { "e-Mic", 0x0 },
12358 },
12359};
12360
12361static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12362 .num_items = 2,
12363 .items = {
12364 { "i-Mic", 0x1 },
12365 { "e-Mic", 0x0 },
12366 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012367};
12368
12369#define alc269_modes alc260_modes
12370#define alc269_capture_source alc880_lg_lw_capture_source
12371
12372static struct snd_kcontrol_new alc269_base_mixer[] = {
12373 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12374 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12375 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12379 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12380 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12381 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12382 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12384 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12385 { } /* end */
12386};
12387
Kailang Yang60db6b52008-08-26 13:13:00 +020012388static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12389 /* output mixer control */
12390 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12391 {
12392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12393 .name = "Master Playback Switch",
12394 .info = snd_hda_mixer_amp_switch_info,
12395 .get = snd_hda_mixer_amp_switch_get,
12396 .put = alc268_acer_master_sw_put,
12397 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12398 },
12399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12402 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12403 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12404 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012405 { }
12406};
12407
Tony Vroon64154832008-11-06 15:08:49 +000012408static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12409 /* output mixer control */
12410 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12411 {
12412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12413 .name = "Master Playback Switch",
12414 .info = snd_hda_mixer_amp_switch_info,
12415 .get = snd_hda_mixer_amp_switch_get,
12416 .put = alc268_acer_master_sw_put,
12417 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12418 },
12419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12422 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12423 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12424 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12425 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12426 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12427 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012428 { }
12429};
12430
Kailang Yangf53281e2008-07-18 12:36:43 +020012431static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012432 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012433 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012435 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012436 { } /* end */
12437};
12438
Kailang Yangf6a92242007-12-13 16:52:54 +010012439/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012440static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12441 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12442 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012443 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12444 { } /* end */
12445};
12446
12447/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012448#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012449
Kailang Yang60db6b52008-08-26 13:13:00 +020012450static struct hda_verb alc269_quanta_fl1_verbs[] = {
12451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12456 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12457 { }
12458};
12459
Tony Vroon64154832008-11-06 15:08:49 +000012460static struct hda_verb alc269_lifebook_verbs[] = {
12461 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12462 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12466 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12468 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12469 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12470 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12471 { }
12472};
12473
Kailang Yang60db6b52008-08-26 13:13:00 +020012474/* toggle speaker-output according to the hp-jack state */
12475static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12476{
12477 unsigned int present;
12478 unsigned char bits;
12479
12480 present = snd_hda_codec_read(codec, 0x15, 0,
12481 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12482 bits = present ? AMP_IN_MUTE(0) : 0;
12483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12484 AMP_IN_MUTE(0), bits);
12485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12486 AMP_IN_MUTE(0), bits);
12487
12488 snd_hda_codec_write(codec, 0x20, 0,
12489 AC_VERB_SET_COEF_INDEX, 0x0c);
12490 snd_hda_codec_write(codec, 0x20, 0,
12491 AC_VERB_SET_PROC_COEF, 0x680);
12492
12493 snd_hda_codec_write(codec, 0x20, 0,
12494 AC_VERB_SET_COEF_INDEX, 0x0c);
12495 snd_hda_codec_write(codec, 0x20, 0,
12496 AC_VERB_SET_PROC_COEF, 0x480);
12497}
12498
Tony Vroon64154832008-11-06 15:08:49 +000012499/* toggle speaker-output according to the hp-jacks state */
12500static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12501{
12502 unsigned int present;
12503 unsigned char bits;
12504
12505 /* Check laptop headphone socket */
12506 present = snd_hda_codec_read(codec, 0x15, 0,
12507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12508
12509 /* Check port replicator headphone socket */
12510 present |= snd_hda_codec_read(codec, 0x1a, 0,
12511 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12512
12513 bits = present ? AMP_IN_MUTE(0) : 0;
12514 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12515 AMP_IN_MUTE(0), bits);
12516 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12517 AMP_IN_MUTE(0), bits);
12518
12519 snd_hda_codec_write(codec, 0x20, 0,
12520 AC_VERB_SET_COEF_INDEX, 0x0c);
12521 snd_hda_codec_write(codec, 0x20, 0,
12522 AC_VERB_SET_PROC_COEF, 0x680);
12523
12524 snd_hda_codec_write(codec, 0x20, 0,
12525 AC_VERB_SET_COEF_INDEX, 0x0c);
12526 snd_hda_codec_write(codec, 0x20, 0,
12527 AC_VERB_SET_PROC_COEF, 0x480);
12528}
12529
Kailang Yang60db6b52008-08-26 13:13:00 +020012530static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12531{
12532 unsigned int present;
12533
12534 present = snd_hda_codec_read(codec, 0x18, 0,
12535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12536 snd_hda_codec_write(codec, 0x23, 0,
12537 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12538}
12539
Tony Vroon64154832008-11-06 15:08:49 +000012540static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12541{
12542 unsigned int present_laptop;
12543 unsigned int present_dock;
12544
12545 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12546 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12547
12548 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12549 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12550
12551 /* Laptop mic port overrides dock mic port, design decision */
12552 if (present_dock)
12553 snd_hda_codec_write(codec, 0x23, 0,
12554 AC_VERB_SET_CONNECT_SEL, 0x3);
12555 if (present_laptop)
12556 snd_hda_codec_write(codec, 0x23, 0,
12557 AC_VERB_SET_CONNECT_SEL, 0x0);
12558 if (!present_dock && !present_laptop)
12559 snd_hda_codec_write(codec, 0x23, 0,
12560 AC_VERB_SET_CONNECT_SEL, 0x1);
12561}
12562
Kailang Yang60db6b52008-08-26 13:13:00 +020012563static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12564 unsigned int res)
12565{
12566 if ((res >> 26) == ALC880_HP_EVENT)
12567 alc269_quanta_fl1_speaker_automute(codec);
12568 if ((res >> 26) == ALC880_MIC_EVENT)
12569 alc269_quanta_fl1_mic_automute(codec);
12570}
12571
Tony Vroon64154832008-11-06 15:08:49 +000012572static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12573 unsigned int res)
12574{
12575 if ((res >> 26) == ALC880_HP_EVENT)
12576 alc269_lifebook_speaker_automute(codec);
12577 if ((res >> 26) == ALC880_MIC_EVENT)
12578 alc269_lifebook_mic_autoswitch(codec);
12579}
12580
Kailang Yang60db6b52008-08-26 13:13:00 +020012581static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12582{
12583 alc269_quanta_fl1_speaker_automute(codec);
12584 alc269_quanta_fl1_mic_automute(codec);
12585}
12586
Tony Vroon64154832008-11-06 15:08:49 +000012587static void alc269_lifebook_init_hook(struct hda_codec *codec)
12588{
12589 alc269_lifebook_speaker_automute(codec);
12590 alc269_lifebook_mic_autoswitch(codec);
12591}
12592
Kailang Yang60db6b52008-08-26 13:13:00 +020012593static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12595 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12596 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12601 {}
12602};
12603
12604static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12606 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12607 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12609 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12611 {}
12612};
12613
12614/* toggle speaker-output according to the hp-jack state */
12615static void alc269_speaker_automute(struct hda_codec *codec)
12616{
12617 unsigned int present;
12618 unsigned char bits;
12619
12620 present = snd_hda_codec_read(codec, 0x15, 0,
12621 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12622 bits = present ? AMP_IN_MUTE(0) : 0;
12623 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12624 AMP_IN_MUTE(0), bits);
12625 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12626 AMP_IN_MUTE(0), bits);
12627}
12628
12629static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12630{
12631 unsigned int present;
12632
12633 present = snd_hda_codec_read(codec, 0x18, 0,
12634 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12635 snd_hda_codec_write(codec, 0x23, 0,
12636 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12637}
12638
12639static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12640{
12641 unsigned int present;
12642
12643 present = snd_hda_codec_read(codec, 0x18, 0,
12644 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12645 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12646 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12647 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12648 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12649}
12650
12651/* unsolicited event for HP jack sensing */
12652static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12653 unsigned int res)
12654{
12655 if ((res >> 26) == ALC880_HP_EVENT)
12656 alc269_speaker_automute(codec);
12657
12658 if ((res >> 26) == ALC880_MIC_EVENT)
12659 alc269_eeepc_dmic_automute(codec);
12660}
12661
12662static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12663{
12664 alc269_speaker_automute(codec);
12665 alc269_eeepc_dmic_automute(codec);
12666}
12667
12668/* unsolicited event for HP jack sensing */
12669static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12670 unsigned int res)
12671{
12672 if ((res >> 26) == ALC880_HP_EVENT)
12673 alc269_speaker_automute(codec);
12674
12675 if ((res >> 26) == ALC880_MIC_EVENT)
12676 alc269_eeepc_amic_automute(codec);
12677}
12678
12679static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12680{
12681 alc269_speaker_automute(codec);
12682 alc269_eeepc_amic_automute(codec);
12683}
12684
Kailang Yangf6a92242007-12-13 16:52:54 +010012685/*
12686 * generic initialization of ADC, input mixers and output mixers
12687 */
12688static struct hda_verb alc269_init_verbs[] = {
12689 /*
12690 * Unmute ADC0 and set the default input to mic-in
12691 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012693
12694 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12695 * analog-loopback mixer widget
12696 * Note: PASD motherboards uses the Line In 2 as the input for
12697 * front panel mic (mic 2)
12698 */
12699 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12705
12706 /*
12707 * Set up output mixers (0x0c - 0x0e)
12708 */
12709 /* set vol=0 to output mixers */
12710 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12711 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12712
12713 /* set up input amps for analog loopback */
12714 /* Amp Indices: DAC = 0, mixer = 1 */
12715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12721
12722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12724 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12727 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12728 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12729
12730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12733 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12737
12738 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12740
12741 /* FIXME: use matrix-type input source selection */
12742 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12743 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12748
12749 /* set EAPD */
12750 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12751 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12752 { }
12753};
12754
12755/* add playback controls from the parsed DAC table */
12756static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12757 const struct auto_pin_cfg *cfg)
12758{
12759 hda_nid_t nid;
12760 int err;
12761
12762 spec->multiout.num_dacs = 1; /* only use one dac */
12763 spec->multiout.dac_nids = spec->private_dac_nids;
12764 spec->multiout.dac_nids[0] = 2;
12765
12766 nid = cfg->line_out_pins[0];
12767 if (nid) {
12768 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12769 "Front Playback Volume",
12770 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12771 if (err < 0)
12772 return err;
12773 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12774 "Front Playback Switch",
12775 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12776 if (err < 0)
12777 return err;
12778 }
12779
12780 nid = cfg->speaker_pins[0];
12781 if (nid) {
12782 if (!cfg->line_out_pins[0]) {
12783 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12784 "Speaker Playback Volume",
12785 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12786 HDA_OUTPUT));
12787 if (err < 0)
12788 return err;
12789 }
12790 if (nid == 0x16) {
12791 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12792 "Speaker Playback Switch",
12793 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12794 HDA_OUTPUT));
12795 if (err < 0)
12796 return err;
12797 } else {
12798 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12799 "Speaker Playback Switch",
12800 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12801 HDA_OUTPUT));
12802 if (err < 0)
12803 return err;
12804 }
12805 }
12806 nid = cfg->hp_pins[0];
12807 if (nid) {
12808 /* spec->multiout.hp_nid = 2; */
12809 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12810 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12811 "Headphone Playback Volume",
12812 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12813 HDA_OUTPUT));
12814 if (err < 0)
12815 return err;
12816 }
12817 if (nid == 0x16) {
12818 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12819 "Headphone Playback Switch",
12820 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12821 HDA_OUTPUT));
12822 if (err < 0)
12823 return err;
12824 } else {
12825 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12826 "Headphone Playback Switch",
12827 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12828 HDA_OUTPUT));
12829 if (err < 0)
12830 return err;
12831 }
12832 }
12833 return 0;
12834}
12835
Takashi Iwai8c927b42009-06-22 10:56:54 +020012836#define alc269_auto_create_analog_input_ctls \
12837 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010012838
12839#ifdef CONFIG_SND_HDA_POWER_SAVE
12840#define alc269_loopbacks alc880_loopbacks
12841#endif
12842
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012843/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010012844#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12845#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12846#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12847#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12848
Takashi Iwaif03d3112009-03-05 14:18:16 +010012849static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12850 .substreams = 1,
12851 .channels_min = 2,
12852 .channels_max = 8,
12853 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12854 /* NID is set in alc_build_pcms */
12855 .ops = {
12856 .open = alc880_playback_pcm_open,
12857 .prepare = alc880_playback_pcm_prepare,
12858 .cleanup = alc880_playback_pcm_cleanup
12859 },
12860};
12861
12862static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12863 .substreams = 1,
12864 .channels_min = 2,
12865 .channels_max = 2,
12866 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12867 /* NID is set in alc_build_pcms */
12868};
12869
Kailang Yangf6a92242007-12-13 16:52:54 +010012870/*
12871 * BIOS auto configuration
12872 */
12873static int alc269_parse_auto_config(struct hda_codec *codec)
12874{
12875 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012876 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012877 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12878
12879 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12880 alc269_ignore);
12881 if (err < 0)
12882 return err;
12883
12884 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12885 if (err < 0)
12886 return err;
12887 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12888 if (err < 0)
12889 return err;
12890
12891 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12892
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012893 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012894 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12895
Takashi Iwai603c4012008-07-30 15:01:44 +020012896 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012897 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012898
Takashi Iwaid88897e2008-10-31 15:01:37 +010012899 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012900 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012901 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012902 /* set default input source */
12903 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12904 0, AC_VERB_SET_CONNECT_SEL,
12905 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012906
12907 err = alc_auto_add_mic_boost(codec);
12908 if (err < 0)
12909 return err;
12910
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012911 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012912 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012913
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012914 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12915
Kailang Yangf6a92242007-12-13 16:52:54 +010012916 return 1;
12917}
12918
12919#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12920#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12921#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12922
12923
12924/* init callback for auto-configuration model -- overriding the default init */
12925static void alc269_auto_init(struct hda_codec *codec)
12926{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012927 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012928 alc269_auto_init_multi_out(codec);
12929 alc269_auto_init_hp_out(codec);
12930 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012931 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012932 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012933}
12934
12935/*
12936 * configuration and preset
12937 */
12938static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012939 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012940 [ALC269_QUANTA_FL1] = "quanta",
12941 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012942 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012943 [ALC269_FUJITSU] = "fujitsu",
12944 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012945};
12946
12947static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012948 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012949 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12950 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012951 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12952 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12953 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12954 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12955 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12956 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012957 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12958 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012959 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12960 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012961 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012962 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012963 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012964 {}
12965};
12966
12967static struct alc_config_preset alc269_presets[] = {
12968 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012969 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012970 .init_verbs = { alc269_init_verbs },
12971 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12972 .dac_nids = alc269_dac_nids,
12973 .hp_nid = 0x03,
12974 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12975 .channel_mode = alc269_modes,
12976 .input_mux = &alc269_capture_source,
12977 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012978 [ALC269_QUANTA_FL1] = {
12979 .mixers = { alc269_quanta_fl1_mixer },
12980 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12981 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12982 .dac_nids = alc269_dac_nids,
12983 .hp_nid = 0x03,
12984 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12985 .channel_mode = alc269_modes,
12986 .input_mux = &alc269_capture_source,
12987 .unsol_event = alc269_quanta_fl1_unsol_event,
12988 .init_hook = alc269_quanta_fl1_init_hook,
12989 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012990 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012991 .mixers = { alc269_eeepc_mixer },
12992 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012993 .init_verbs = { alc269_init_verbs,
12994 alc269_eeepc_amic_init_verbs },
12995 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12996 .dac_nids = alc269_dac_nids,
12997 .hp_nid = 0x03,
12998 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12999 .channel_mode = alc269_modes,
13000 .input_mux = &alc269_eeepc_amic_capture_source,
13001 .unsol_event = alc269_eeepc_amic_unsol_event,
13002 .init_hook = alc269_eeepc_amic_inithook,
13003 },
13004 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013005 .mixers = { alc269_eeepc_mixer },
13006 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013007 .init_verbs = { alc269_init_verbs,
13008 alc269_eeepc_dmic_init_verbs },
13009 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13010 .dac_nids = alc269_dac_nids,
13011 .hp_nid = 0x03,
13012 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13013 .channel_mode = alc269_modes,
13014 .input_mux = &alc269_eeepc_dmic_capture_source,
13015 .unsol_event = alc269_eeepc_dmic_unsol_event,
13016 .init_hook = alc269_eeepc_dmic_inithook,
13017 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013018 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013019 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013020 .cap_mixer = alc269_epc_capture_mixer,
13021 .init_verbs = { alc269_init_verbs,
13022 alc269_eeepc_dmic_init_verbs },
13023 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13024 .dac_nids = alc269_dac_nids,
13025 .hp_nid = 0x03,
13026 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13027 .channel_mode = alc269_modes,
13028 .input_mux = &alc269_eeepc_dmic_capture_source,
13029 .unsol_event = alc269_eeepc_dmic_unsol_event,
13030 .init_hook = alc269_eeepc_dmic_inithook,
13031 },
Tony Vroon64154832008-11-06 15:08:49 +000013032 [ALC269_LIFEBOOK] = {
13033 .mixers = { alc269_lifebook_mixer },
13034 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13035 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13036 .dac_nids = alc269_dac_nids,
13037 .hp_nid = 0x03,
13038 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13039 .channel_mode = alc269_modes,
13040 .input_mux = &alc269_capture_source,
13041 .unsol_event = alc269_lifebook_unsol_event,
13042 .init_hook = alc269_lifebook_init_hook,
13043 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013044};
13045
13046static int patch_alc269(struct hda_codec *codec)
13047{
13048 struct alc_spec *spec;
13049 int board_config;
13050 int err;
13051
13052 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13053 if (spec == NULL)
13054 return -ENOMEM;
13055
13056 codec->spec = spec;
13057
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013058 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13059
Kailang Yangf6a92242007-12-13 16:52:54 +010013060 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13061 alc269_models,
13062 alc269_cfg_tbl);
13063
13064 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013065 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13066 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013067 board_config = ALC269_AUTO;
13068 }
13069
13070 if (board_config == ALC269_AUTO) {
13071 /* automatic parse from the BIOS config */
13072 err = alc269_parse_auto_config(codec);
13073 if (err < 0) {
13074 alc_free(codec);
13075 return err;
13076 } else if (!err) {
13077 printk(KERN_INFO
13078 "hda_codec: Cannot set up configuration "
13079 "from BIOS. Using base mode...\n");
13080 board_config = ALC269_BASIC;
13081 }
13082 }
13083
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013084 err = snd_hda_attach_beep_device(codec, 0x1);
13085 if (err < 0) {
13086 alc_free(codec);
13087 return err;
13088 }
13089
Kailang Yangf6a92242007-12-13 16:52:54 +010013090 if (board_config != ALC269_AUTO)
13091 setup_preset(spec, &alc269_presets[board_config]);
13092
Takashi Iwaif03d3112009-03-05 14:18:16 +010013093 if (codec->subsystem_id == 0x17aa3bf8) {
13094 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13095 * fix the sample rate of analog I/O to 44.1kHz
13096 */
13097 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13098 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13099 } else {
13100 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13101 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13102 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013103 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13104 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13105
13106 spec->adc_nids = alc269_adc_nids;
13107 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013108 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013109 if (!spec->cap_mixer)
13110 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013111 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013112
13113 codec->patch_ops = alc_patch_ops;
13114 if (board_config == ALC269_AUTO)
13115 spec->init_hook = alc269_auto_init;
13116#ifdef CONFIG_SND_HDA_POWER_SAVE
13117 if (!spec->loopback.amplist)
13118 spec->loopback.amplist = alc269_loopbacks;
13119#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013120 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013121
13122 return 0;
13123}
13124
13125/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013126 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13127 */
13128
13129/*
13130 * set the path ways for 2 channel output
13131 * need to set the codec line out and mic 1 pin widgets to inputs
13132 */
13133static struct hda_verb alc861_threestack_ch2_init[] = {
13134 /* set pin widget 1Ah (line in) for input */
13135 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013136 /* set pin widget 18h (mic1/2) for input, for mic also enable
13137 * the vref
13138 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013139 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13140
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013141 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13142#if 0
13143 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13144 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13145#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013146 { } /* end */
13147};
13148/*
13149 * 6ch mode
13150 * need to set the codec line out and mic 1 pin widgets to outputs
13151 */
13152static struct hda_verb alc861_threestack_ch6_init[] = {
13153 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13154 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13155 /* set pin widget 18h (mic1) for output (CLFE)*/
13156 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13157
13158 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013159 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013160
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013161 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13162#if 0
13163 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13164 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13165#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013166 { } /* end */
13167};
13168
13169static struct hda_channel_mode alc861_threestack_modes[2] = {
13170 { 2, alc861_threestack_ch2_init },
13171 { 6, alc861_threestack_ch6_init },
13172};
Takashi Iwai22309c32006-08-09 16:57:28 +020013173/* Set mic1 as input and unmute the mixer */
13174static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13175 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13176 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13177 { } /* end */
13178};
13179/* Set mic1 as output and mute mixer */
13180static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13181 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13182 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13183 { } /* end */
13184};
13185
13186static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13187 { 2, alc861_uniwill_m31_ch2_init },
13188 { 4, alc861_uniwill_m31_ch4_init },
13189};
Kailang Yangdf694da2005-12-05 19:42:22 +010013190
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013191/* Set mic1 and line-in as input and unmute the mixer */
13192static struct hda_verb alc861_asus_ch2_init[] = {
13193 /* set pin widget 1Ah (line in) for input */
13194 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013195 /* set pin widget 18h (mic1/2) for input, for mic also enable
13196 * the vref
13197 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013198 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13199
13200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13201#if 0
13202 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13203 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13204#endif
13205 { } /* end */
13206};
13207/* Set mic1 nad line-in as output and mute mixer */
13208static struct hda_verb alc861_asus_ch6_init[] = {
13209 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13210 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13211 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13212 /* set pin widget 18h (mic1) for output (CLFE)*/
13213 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13214 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13215 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13216 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13217
13218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13219#if 0
13220 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13222#endif
13223 { } /* end */
13224};
13225
13226static struct hda_channel_mode alc861_asus_modes[2] = {
13227 { 2, alc861_asus_ch2_init },
13228 { 6, alc861_asus_ch6_init },
13229};
13230
Kailang Yangdf694da2005-12-05 19:42:22 +010013231/* patch-ALC861 */
13232
13233static struct snd_kcontrol_new alc861_base_mixer[] = {
13234 /* output mixer control */
13235 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13236 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13237 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13238 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13239 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13240
13241 /*Input mixer control */
13242 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13243 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13244 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13245 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13246 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13247 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13249 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13250 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013252
Kailang Yangdf694da2005-12-05 19:42:22 +010013253 { } /* end */
13254};
13255
13256static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13257 /* output mixer control */
13258 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13259 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13260 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13261 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13262 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13263
13264 /* Input mixer control */
13265 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13266 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13267 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13268 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13269 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13270 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13272 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13273 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013275
Kailang Yangdf694da2005-12-05 19:42:22 +010013276 {
13277 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13278 .name = "Channel Mode",
13279 .info = alc_ch_mode_info,
13280 .get = alc_ch_mode_get,
13281 .put = alc_ch_mode_put,
13282 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13283 },
13284 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013285};
13286
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013287static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013288 /* output mixer control */
13289 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13291 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013292
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013293 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013294};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013295
Takashi Iwai22309c32006-08-09 16:57:28 +020013296static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13297 /* output mixer control */
13298 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13299 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13300 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13301 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13302 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13303
13304 /* Input mixer control */
13305 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13306 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13307 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13308 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13309 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13310 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13312 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13313 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13314 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013315
Takashi Iwai22309c32006-08-09 16:57:28 +020013316 {
13317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13318 .name = "Channel Mode",
13319 .info = alc_ch_mode_info,
13320 .get = alc_ch_mode_get,
13321 .put = alc_ch_mode_put,
13322 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13323 },
13324 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013325};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013326
13327static struct snd_kcontrol_new alc861_asus_mixer[] = {
13328 /* output mixer control */
13329 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13330 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13331 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13332 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13333 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13334
13335 /* Input mixer control */
13336 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13337 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13338 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13339 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13340 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13341 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13343 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13346
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013347 {
13348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13349 .name = "Channel Mode",
13350 .info = alc_ch_mode_info,
13351 .get = alc_ch_mode_get,
13352 .put = alc_ch_mode_put,
13353 .private_value = ARRAY_SIZE(alc861_asus_modes),
13354 },
13355 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013356};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013357
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013358/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013359static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013360 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13361 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013362 { }
13363};
13364
Kailang Yangdf694da2005-12-05 19:42:22 +010013365/*
13366 * generic initialization of ADC, input mixers and output mixers
13367 */
13368static struct hda_verb alc861_base_init_verbs[] = {
13369 /*
13370 * Unmute ADC0 and set the default input to mic-in
13371 */
13372 /* port-A for surround (rear panel) */
13373 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13374 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13375 /* port-B for mic-in (rear panel) with vref */
13376 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13377 /* port-C for line-in (rear panel) */
13378 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13379 /* port-D for Front */
13380 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13381 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13382 /* port-E for HP out (front panel) */
13383 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13384 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013385 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013386 /* port-F for mic-in (front panel) with vref */
13387 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13388 /* port-G for CLFE (rear panel) */
13389 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13390 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13391 /* port-H for side (rear panel) */
13392 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13393 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13394 /* CD-in */
13395 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13396 /* route front mic to ADC1*/
13397 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13398 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013399
Kailang Yangdf694da2005-12-05 19:42:22 +010013400 /* Unmute DAC0~3 & spdif out*/
13401 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13403 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13404 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013406
Kailang Yangdf694da2005-12-05 19:42:22 +010013407 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13408 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13409 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13410 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13411 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013412
Kailang Yangdf694da2005-12-05 19:42:22 +010013413 /* Unmute Stereo Mixer 15 */
13414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013418
13419 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13421 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13422 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13424 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13425 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013427 /* hp used DAC 3 (Front) */
13428 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13430
13431 { }
13432};
13433
13434static struct hda_verb alc861_threestack_init_verbs[] = {
13435 /*
13436 * Unmute ADC0 and set the default input to mic-in
13437 */
13438 /* port-A for surround (rear panel) */
13439 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13440 /* port-B for mic-in (rear panel) with vref */
13441 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13442 /* port-C for line-in (rear panel) */
13443 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13444 /* port-D for Front */
13445 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13446 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13447 /* port-E for HP out (front panel) */
13448 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13449 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013450 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013451 /* port-F for mic-in (front panel) with vref */
13452 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13453 /* port-G for CLFE (rear panel) */
13454 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13455 /* port-H for side (rear panel) */
13456 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13457 /* CD-in */
13458 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13459 /* route front mic to ADC1*/
13460 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13462 /* Unmute DAC0~3 & spdif out*/
13463 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13464 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13465 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13466 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013468
Kailang Yangdf694da2005-12-05 19:42:22 +010013469 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13470 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13471 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13472 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13473 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013474
Kailang Yangdf694da2005-12-05 19:42:22 +010013475 /* Unmute Stereo Mixer 15 */
13476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013480
13481 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13482 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13483 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13485 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13486 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013489 /* hp used DAC 3 (Front) */
13490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013491 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13492 { }
13493};
Takashi Iwai22309c32006-08-09 16:57:28 +020013494
13495static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13496 /*
13497 * Unmute ADC0 and set the default input to mic-in
13498 */
13499 /* port-A for surround (rear panel) */
13500 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13501 /* port-B for mic-in (rear panel) with vref */
13502 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13503 /* port-C for line-in (rear panel) */
13504 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13505 /* port-D for Front */
13506 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13507 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13508 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013509 /* this has to be set to VREF80 */
13510 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013511 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013512 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013513 /* port-F for mic-in (front panel) with vref */
13514 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13515 /* port-G for CLFE (rear panel) */
13516 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13517 /* port-H for side (rear panel) */
13518 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13519 /* CD-in */
13520 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13521 /* route front mic to ADC1*/
13522 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13523 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13524 /* Unmute DAC0~3 & spdif out*/
13525 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13526 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13527 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13528 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013530
Takashi Iwai22309c32006-08-09 16:57:28 +020013531 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13532 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13533 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13534 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13535 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013536
Takashi Iwai22309c32006-08-09 16:57:28 +020013537 /* Unmute Stereo Mixer 15 */
13538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013541 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013542
13543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13545 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013551 /* hp used DAC 3 (Front) */
13552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13554 { }
13555};
13556
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013557static struct hda_verb alc861_asus_init_verbs[] = {
13558 /*
13559 * Unmute ADC0 and set the default input to mic-in
13560 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013561 /* port-A for surround (rear panel)
13562 * according to codec#0 this is the HP jack
13563 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013564 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13565 /* route front PCM to HP */
13566 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13567 /* port-B for mic-in (rear panel) with vref */
13568 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13569 /* port-C for line-in (rear panel) */
13570 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13571 /* port-D for Front */
13572 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13573 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13574 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013575 /* this has to be set to VREF80 */
13576 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013577 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013578 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013579 /* port-F for mic-in (front panel) with vref */
13580 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13581 /* port-G for CLFE (rear panel) */
13582 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13583 /* port-H for side (rear panel) */
13584 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13585 /* CD-in */
13586 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13587 /* route front mic to ADC1*/
13588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13590 /* Unmute DAC0~3 & spdif out*/
13591 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13592 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13593 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13594 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13596 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13597 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13598 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13599 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13600 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013601
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013602 /* Unmute Stereo Mixer 15 */
13603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013607
13608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13611 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013616 /* hp used DAC 3 (Front) */
13617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13619 { }
13620};
13621
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013622/* additional init verbs for ASUS laptops */
13623static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13624 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13625 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13626 { }
13627};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013628
Kailang Yangdf694da2005-12-05 19:42:22 +010013629/*
13630 * generic initialization of ADC, input mixers and output mixers
13631 */
13632static struct hda_verb alc861_auto_init_verbs[] = {
13633 /*
13634 * Unmute ADC0 and set the default input to mic-in
13635 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013638
Kailang Yangdf694da2005-12-05 19:42:22 +010013639 /* Unmute DAC0~3 & spdif out*/
13640 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13641 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13642 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13643 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013645
Kailang Yangdf694da2005-12-05 19:42:22 +010013646 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13647 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13648 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13649 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13650 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013651
Kailang Yangdf694da2005-12-05 19:42:22 +010013652 /* Unmute Stereo Mixer 15 */
13653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13654 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13657
13658 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13659 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13660 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13661 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13662 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13664 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13666
13667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013673 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013675
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013677
13678 { }
13679};
13680
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013681static struct hda_verb alc861_toshiba_init_verbs[] = {
13682 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013683
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013684 { }
13685};
13686
13687/* toggle speaker-output according to the hp-jack state */
13688static void alc861_toshiba_automute(struct hda_codec *codec)
13689{
13690 unsigned int present;
13691
13692 present = snd_hda_codec_read(codec, 0x0f, 0,
13693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013694 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13696 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13697 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013698}
13699
13700static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13701 unsigned int res)
13702{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013703 if ((res >> 26) == ALC880_HP_EVENT)
13704 alc861_toshiba_automute(codec);
13705}
13706
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013707/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013708#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13709#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13710#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13711#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13712
13713
13714#define ALC861_DIGOUT_NID 0x07
13715
13716static struct hda_channel_mode alc861_8ch_modes[1] = {
13717 { 8, NULL }
13718};
13719
13720static hda_nid_t alc861_dac_nids[4] = {
13721 /* front, surround, clfe, side */
13722 0x03, 0x06, 0x05, 0x04
13723};
13724
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013725static hda_nid_t alc660_dac_nids[3] = {
13726 /* front, clfe, surround */
13727 0x03, 0x05, 0x06
13728};
13729
Kailang Yangdf694da2005-12-05 19:42:22 +010013730static hda_nid_t alc861_adc_nids[1] = {
13731 /* ADC0-2 */
13732 0x08,
13733};
13734
13735static struct hda_input_mux alc861_capture_source = {
13736 .num_items = 5,
13737 .items = {
13738 { "Mic", 0x0 },
13739 { "Front Mic", 0x3 },
13740 { "Line", 0x1 },
13741 { "CD", 0x4 },
13742 { "Mixer", 0x5 },
13743 },
13744};
13745
13746/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13748 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013749{
13750 int i;
13751 hda_nid_t nid;
13752
13753 spec->multiout.dac_nids = spec->private_dac_nids;
13754 for (i = 0; i < cfg->line_outs; i++) {
13755 nid = cfg->line_out_pins[i];
13756 if (nid) {
13757 if (i >= ARRAY_SIZE(alc861_dac_nids))
13758 continue;
13759 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13760 }
13761 }
13762 spec->multiout.num_dacs = cfg->line_outs;
13763 return 0;
13764}
13765
13766/* add playback controls from the parsed DAC table */
13767static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13768 const struct auto_pin_cfg *cfg)
13769{
13770 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013771 static const char *chname[4] = {
13772 "Front", "Surround", NULL /*CLFE*/, "Side"
13773 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013774 hda_nid_t nid;
13775 int i, idx, err;
13776
13777 for (i = 0; i < cfg->line_outs; i++) {
13778 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013779 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013780 continue;
13781 if (nid == 0x05) {
13782 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013783 err = add_control(spec, ALC_CTL_BIND_MUTE,
13784 "Center Playback Switch",
13785 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13786 HDA_OUTPUT));
13787 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013789 err = add_control(spec, ALC_CTL_BIND_MUTE,
13790 "LFE Playback Switch",
13791 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13792 HDA_OUTPUT));
13793 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013794 return err;
13795 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013796 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13797 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013798 if (nid == alc861_dac_nids[idx])
13799 break;
13800 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013801 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13802 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13803 HDA_OUTPUT));
13804 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 return err;
13806 }
13807 }
13808 return 0;
13809}
13810
13811static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13812{
13813 int err;
13814 hda_nid_t nid;
13815
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013816 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 return 0;
13818
13819 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13820 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013821 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13822 "Headphone Playback Switch",
13823 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13824 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013825 return err;
13826 spec->multiout.hp_nid = nid;
13827 }
13828 return 0;
13829}
13830
13831/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013832static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13833 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013834{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013835 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013836 int i, err, idx, idx1;
13837
13838 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013839 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013840 case 0x0c:
13841 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013842 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013843 break;
13844 case 0x0f:
13845 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013846 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013847 break;
13848 case 0x0d:
13849 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013850 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013851 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013852 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013853 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013854 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013855 break;
13856 case 0x11:
13857 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013858 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013859 break;
13860 default:
13861 continue;
13862 }
13863
Takashi Iwai4a471b72005-12-07 13:56:29 +010013864 err = new_analog_input(spec, cfg->input_pins[i],
13865 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013866 if (err < 0)
13867 return err;
13868
Takashi Iwai4a471b72005-12-07 13:56:29 +010013869 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013870 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013871 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 }
13873 return 0;
13874}
13875
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013876static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13877 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 int pin_type, int dac_idx)
13879{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013880 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13881 pin_type);
13882 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13883 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013884}
13885
13886static void alc861_auto_init_multi_out(struct hda_codec *codec)
13887{
13888 struct alc_spec *spec = codec->spec;
13889 int i;
13890
13891 for (i = 0; i < spec->autocfg.line_outs; i++) {
13892 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013893 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013894 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013895 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013896 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 }
13898}
13899
13900static void alc861_auto_init_hp_out(struct hda_codec *codec)
13901{
13902 struct alc_spec *spec = codec->spec;
13903 hda_nid_t pin;
13904
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013905 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013906 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013907 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13908 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013909 pin = spec->autocfg.speaker_pins[0];
13910 if (pin)
13911 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013912}
13913
13914static void alc861_auto_init_analog_input(struct hda_codec *codec)
13915{
13916 struct alc_spec *spec = codec->spec;
13917 int i;
13918
13919 for (i = 0; i < AUTO_PIN_LAST; i++) {
13920 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013921 if (nid >= 0x0c && nid <= 0x11)
13922 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 }
13924}
13925
13926/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927/* return 1 if successful, 0 if the proper config is not found,
13928 * or a negative error code
13929 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013930static int alc861_parse_auto_config(struct hda_codec *codec)
13931{
13932 struct alc_spec *spec = codec->spec;
13933 int err;
13934 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13935
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013936 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13937 alc861_ignore);
13938 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013939 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013940 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 return 0; /* can't find valid BIOS pin config */
13942
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013943 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13944 if (err < 0)
13945 return err;
13946 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13947 if (err < 0)
13948 return err;
13949 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13950 if (err < 0)
13951 return err;
13952 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13953 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013954 return err;
13955
13956 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13957
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013958 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013959 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13960
Takashi Iwai603c4012008-07-30 15:01:44 +020013961 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013962 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013963
Takashi Iwaid88897e2008-10-31 15:01:37 +010013964 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013965
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013966 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013967 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013968
13969 spec->adc_nids = alc861_adc_nids;
13970 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013971 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013972
Takashi Iwai4a79ba32009-04-22 16:31:35 +020013973 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
13974
Kailang Yangdf694da2005-12-05 19:42:22 +010013975 return 1;
13976}
13977
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013978/* additional initialization for auto-configuration model */
13979static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013980{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013981 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013982 alc861_auto_init_multi_out(codec);
13983 alc861_auto_init_hp_out(codec);
13984 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013985 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013986 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013987}
13988
Takashi Iwaicb53c622007-08-10 17:21:45 +020013989#ifdef CONFIG_SND_HDA_POWER_SAVE
13990static struct hda_amp_list alc861_loopbacks[] = {
13991 { 0x15, HDA_INPUT, 0 },
13992 { 0x15, HDA_INPUT, 1 },
13993 { 0x15, HDA_INPUT, 2 },
13994 { 0x15, HDA_INPUT, 3 },
13995 { } /* end */
13996};
13997#endif
13998
Kailang Yangdf694da2005-12-05 19:42:22 +010013999
14000/*
14001 * configuration and preset
14002 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014003static const char *alc861_models[ALC861_MODEL_LAST] = {
14004 [ALC861_3ST] = "3stack",
14005 [ALC660_3ST] = "3stack-660",
14006 [ALC861_3ST_DIG] = "3stack-dig",
14007 [ALC861_6ST_DIG] = "6stack-dig",
14008 [ALC861_UNIWILL_M31] = "uniwill-m31",
14009 [ALC861_TOSHIBA] = "toshiba",
14010 [ALC861_ASUS] = "asus",
14011 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14012 [ALC861_AUTO] = "auto",
14013};
14014
14015static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014016 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014017 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14018 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14019 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014020 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014021 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014022 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014023 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14024 * Any other models that need this preset?
14025 */
14026 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014027 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14028 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014029 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14030 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14031 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14032 /* FIXME: the below seems conflict */
14033 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14034 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14035 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014036 {}
14037};
14038
14039static struct alc_config_preset alc861_presets[] = {
14040 [ALC861_3ST] = {
14041 .mixers = { alc861_3ST_mixer },
14042 .init_verbs = { alc861_threestack_init_verbs },
14043 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14044 .dac_nids = alc861_dac_nids,
14045 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14046 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014047 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014048 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14049 .adc_nids = alc861_adc_nids,
14050 .input_mux = &alc861_capture_source,
14051 },
14052 [ALC861_3ST_DIG] = {
14053 .mixers = { alc861_base_mixer },
14054 .init_verbs = { alc861_threestack_init_verbs },
14055 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14056 .dac_nids = alc861_dac_nids,
14057 .dig_out_nid = ALC861_DIGOUT_NID,
14058 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14059 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014060 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014061 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14062 .adc_nids = alc861_adc_nids,
14063 .input_mux = &alc861_capture_source,
14064 },
14065 [ALC861_6ST_DIG] = {
14066 .mixers = { alc861_base_mixer },
14067 .init_verbs = { alc861_base_init_verbs },
14068 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14069 .dac_nids = alc861_dac_nids,
14070 .dig_out_nid = ALC861_DIGOUT_NID,
14071 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14072 .channel_mode = alc861_8ch_modes,
14073 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14074 .adc_nids = alc861_adc_nids,
14075 .input_mux = &alc861_capture_source,
14076 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014077 [ALC660_3ST] = {
14078 .mixers = { alc861_3ST_mixer },
14079 .init_verbs = { alc861_threestack_init_verbs },
14080 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14081 .dac_nids = alc660_dac_nids,
14082 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14083 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014084 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014085 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14086 .adc_nids = alc861_adc_nids,
14087 .input_mux = &alc861_capture_source,
14088 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014089 [ALC861_UNIWILL_M31] = {
14090 .mixers = { alc861_uniwill_m31_mixer },
14091 .init_verbs = { alc861_uniwill_m31_init_verbs },
14092 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14093 .dac_nids = alc861_dac_nids,
14094 .dig_out_nid = ALC861_DIGOUT_NID,
14095 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14096 .channel_mode = alc861_uniwill_m31_modes,
14097 .need_dac_fix = 1,
14098 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14099 .adc_nids = alc861_adc_nids,
14100 .input_mux = &alc861_capture_source,
14101 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014102 [ALC861_TOSHIBA] = {
14103 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014104 .init_verbs = { alc861_base_init_verbs,
14105 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014106 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14107 .dac_nids = alc861_dac_nids,
14108 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14109 .channel_mode = alc883_3ST_2ch_modes,
14110 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14111 .adc_nids = alc861_adc_nids,
14112 .input_mux = &alc861_capture_source,
14113 .unsol_event = alc861_toshiba_unsol_event,
14114 .init_hook = alc861_toshiba_automute,
14115 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014116 [ALC861_ASUS] = {
14117 .mixers = { alc861_asus_mixer },
14118 .init_verbs = { alc861_asus_init_verbs },
14119 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14120 .dac_nids = alc861_dac_nids,
14121 .dig_out_nid = ALC861_DIGOUT_NID,
14122 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14123 .channel_mode = alc861_asus_modes,
14124 .need_dac_fix = 1,
14125 .hp_nid = 0x06,
14126 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14127 .adc_nids = alc861_adc_nids,
14128 .input_mux = &alc861_capture_source,
14129 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014130 [ALC861_ASUS_LAPTOP] = {
14131 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14132 .init_verbs = { alc861_asus_init_verbs,
14133 alc861_asus_laptop_init_verbs },
14134 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14135 .dac_nids = alc861_dac_nids,
14136 .dig_out_nid = ALC861_DIGOUT_NID,
14137 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14138 .channel_mode = alc883_3ST_2ch_modes,
14139 .need_dac_fix = 1,
14140 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14141 .adc_nids = alc861_adc_nids,
14142 .input_mux = &alc861_capture_source,
14143 },
14144};
Kailang Yangdf694da2005-12-05 19:42:22 +010014145
14146
14147static int patch_alc861(struct hda_codec *codec)
14148{
14149 struct alc_spec *spec;
14150 int board_config;
14151 int err;
14152
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014154 if (spec == NULL)
14155 return -ENOMEM;
14156
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014157 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014158
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014159 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14160 alc861_models,
14161 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014162
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014163 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014164 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14165 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014166 board_config = ALC861_AUTO;
14167 }
14168
14169 if (board_config == ALC861_AUTO) {
14170 /* automatic parse from the BIOS config */
14171 err = alc861_parse_auto_config(codec);
14172 if (err < 0) {
14173 alc_free(codec);
14174 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014176 printk(KERN_INFO
14177 "hda_codec: Cannot set up configuration "
14178 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014179 board_config = ALC861_3ST_DIG;
14180 }
14181 }
14182
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014183 err = snd_hda_attach_beep_device(codec, 0x23);
14184 if (err < 0) {
14185 alc_free(codec);
14186 return err;
14187 }
14188
Kailang Yangdf694da2005-12-05 19:42:22 +010014189 if (board_config != ALC861_AUTO)
14190 setup_preset(spec, &alc861_presets[board_config]);
14191
Kailang Yangdf694da2005-12-05 19:42:22 +010014192 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14193 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14194
Kailang Yangdf694da2005-12-05 19:42:22 +010014195 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14196 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14197
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014198 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14199
Takashi Iwai2134ea42008-01-10 16:53:55 +010014200 spec->vmaster_nid = 0x03;
14201
Kailang Yangdf694da2005-12-05 19:42:22 +010014202 codec->patch_ops = alc_patch_ops;
14203 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014204 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014205#ifdef CONFIG_SND_HDA_POWER_SAVE
14206 if (!spec->loopback.amplist)
14207 spec->loopback.amplist = alc861_loopbacks;
14208#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014209 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014210
Kailang Yangdf694da2005-12-05 19:42:22 +010014211 return 0;
14212}
14213
14214/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014215 * ALC861-VD support
14216 *
14217 * Based on ALC882
14218 *
14219 * In addition, an independent DAC
14220 */
14221#define ALC861VD_DIGOUT_NID 0x06
14222
14223static hda_nid_t alc861vd_dac_nids[4] = {
14224 /* front, surr, clfe, side surr */
14225 0x02, 0x03, 0x04, 0x05
14226};
14227
14228/* dac_nids for ALC660vd are in a different order - according to
14229 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014230 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014231 * of ALC660vd codecs, but for now there is only 3stack mixer
14232 * - and it is the same as in 861vd.
14233 * adc_nids in ALC660vd are (is) the same as in 861vd
14234 */
14235static hda_nid_t alc660vd_dac_nids[3] = {
14236 /* front, rear, clfe, rear_surr */
14237 0x02, 0x04, 0x03
14238};
14239
14240static hda_nid_t alc861vd_adc_nids[1] = {
14241 /* ADC0 */
14242 0x09,
14243};
14244
Takashi Iwaie1406342008-02-11 18:32:32 +010014245static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14246
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014247/* input MUX */
14248/* FIXME: should be a matrix-type input source selection */
14249static struct hda_input_mux alc861vd_capture_source = {
14250 .num_items = 4,
14251 .items = {
14252 { "Mic", 0x0 },
14253 { "Front Mic", 0x1 },
14254 { "Line", 0x2 },
14255 { "CD", 0x4 },
14256 },
14257};
14258
Kailang Yang272a5272007-05-14 11:00:38 +020014259static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014260 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014261 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014262 { "Ext Mic", 0x0 },
14263 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014264 },
14265};
14266
Kailang Yangd1a991a2007-08-15 16:21:59 +020014267static struct hda_input_mux alc861vd_hp_capture_source = {
14268 .num_items = 2,
14269 .items = {
14270 { "Front Mic", 0x0 },
14271 { "ATAPI Mic", 0x1 },
14272 },
14273};
14274
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014275/*
14276 * 2ch mode
14277 */
14278static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14279 { 2, NULL }
14280};
14281
14282/*
14283 * 6ch mode
14284 */
14285static struct hda_verb alc861vd_6stack_ch6_init[] = {
14286 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14287 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14288 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14289 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14290 { } /* end */
14291};
14292
14293/*
14294 * 8ch mode
14295 */
14296static struct hda_verb alc861vd_6stack_ch8_init[] = {
14297 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14298 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14299 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14300 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14301 { } /* end */
14302};
14303
14304static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14305 { 6, alc861vd_6stack_ch6_init },
14306 { 8, alc861vd_6stack_ch8_init },
14307};
14308
14309static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14310 {
14311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14312 .name = "Channel Mode",
14313 .info = alc_ch_mode_info,
14314 .get = alc_ch_mode_get,
14315 .put = alc_ch_mode_put,
14316 },
14317 { } /* end */
14318};
14319
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014320/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14321 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14322 */
14323static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14324 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14326
14327 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14328 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14329
14330 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14331 HDA_OUTPUT),
14332 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14333 HDA_OUTPUT),
14334 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14335 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14336
14337 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14338 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14339
14340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14341
14342 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14345
14346 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14349
14350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14352
14353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14355
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014356 { } /* end */
14357};
14358
14359static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14360 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14362
14363 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14364
14365 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14368
14369 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14372
14373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14375
14376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14378
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014379 { } /* end */
14380};
14381
Kailang Yangbdd148a2007-05-08 15:19:08 +020014382static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14383 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14384 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14385 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14386
14387 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14388
14389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14390 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14391 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14392
14393 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14394 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14395 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14396
14397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14399
14400 { } /* end */
14401};
14402
Tobin Davisb419f342008-03-07 11:57:51 +010014403/* Pin assignment: Speaker=0x14, HP = 0x15,
14404 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014405 */
14406static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014407 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14408 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14410 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014411 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14412 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14413 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14414 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14415 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14416 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014417 { } /* end */
14418};
14419
Kailang Yangd1a991a2007-08-15 16:21:59 +020014420/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14421 * Front Mic=0x18, ATAPI Mic = 0x19,
14422 */
14423static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14424 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14426 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14427 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14428 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14430 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14431 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014432
Kailang Yangd1a991a2007-08-15 16:21:59 +020014433 { } /* end */
14434};
14435
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014436/*
14437 * generic initialization of ADC, input mixers and output mixers
14438 */
14439static struct hda_verb alc861vd_volume_init_verbs[] = {
14440 /*
14441 * Unmute ADC0 and set the default input to mic-in
14442 */
14443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14445
14446 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14447 * the analog-loopback mixer widget
14448 */
14449 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014455
14456 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014461
14462 /*
14463 * Set up output mixers (0x02 - 0x05)
14464 */
14465 /* set vol=0 to output mixers */
14466 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14467 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14468 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14469 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14470
14471 /* set up input amps for analog loopback */
14472 /* Amp Indices: DAC = 0, mixer = 1 */
14473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14478 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14480 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14481
14482 { }
14483};
14484
14485/*
14486 * 3-stack pin configuration:
14487 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14488 */
14489static struct hda_verb alc861vd_3stack_init_verbs[] = {
14490 /*
14491 * Set pin mode and muting
14492 */
14493 /* set front pin widgets 0x14 for output */
14494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14496 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14497
14498 /* Mic (rear) pin: input vref at 80% */
14499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14501 /* Front Mic pin: input vref at 80% */
14502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14504 /* Line In pin: input */
14505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14507 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14511 /* CD pin widget for input */
14512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14513
14514 { }
14515};
14516
14517/*
14518 * 6-stack pin configuration:
14519 */
14520static struct hda_verb alc861vd_6stack_init_verbs[] = {
14521 /*
14522 * Set pin mode and muting
14523 */
14524 /* set front pin widgets 0x14 for output */
14525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14527 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14528
14529 /* Rear Pin: output 1 (0x0d) */
14530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14533 /* CLFE Pin: output 2 (0x0e) */
14534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14536 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14537 /* Side Pin: output 3 (0x0f) */
14538 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14540 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14541
14542 /* Mic (rear) pin: input vref at 80% */
14543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14545 /* Front Mic pin: input vref at 80% */
14546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14548 /* Line In pin: input */
14549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14551 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14553 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14554 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14555 /* CD pin widget for input */
14556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14557
14558 { }
14559};
14560
Kailang Yangbdd148a2007-05-08 15:19:08 +020014561static struct hda_verb alc861vd_eapd_verbs[] = {
14562 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14563 { }
14564};
14565
Kailang Yangf9423e72008-05-27 12:32:25 +020014566static struct hda_verb alc660vd_eapd_verbs[] = {
14567 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14568 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14569 { }
14570};
14571
Kailang Yangbdd148a2007-05-08 15:19:08 +020014572static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14576 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014578 {}
14579};
14580
Kailang Yangbdd148a2007-05-08 15:19:08 +020014581static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14582{
14583 unsigned int present;
14584 unsigned char bits;
14585
14586 present = snd_hda_codec_read(codec, 0x18, 0,
14587 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014588 bits = present ? HDA_AMP_MUTE : 0;
14589 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14590 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014591}
14592
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014593static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014594{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014595 struct alc_spec *spec = codec->spec;
14596
14597 spec->autocfg.hp_pins[0] = 0x1b;
14598 spec->autocfg.speaker_pins[0] = 0x14;
14599 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014600 alc861vd_lenovo_mic_automute(codec);
14601}
14602
14603static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14604 unsigned int res)
14605{
14606 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014607 case ALC880_MIC_EVENT:
14608 alc861vd_lenovo_mic_automute(codec);
14609 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014610 default:
14611 alc_automute_amp_unsol_event(codec, res);
14612 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014613 }
14614}
14615
Kailang Yang272a5272007-05-14 11:00:38 +020014616static struct hda_verb alc861vd_dallas_verbs[] = {
14617 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14618 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14619 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14620 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14621
14622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014630
Kailang Yang272a5272007-05-14 11:00:38 +020014631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14632 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14637 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14638 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14639
14640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14641 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14647 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14648
14649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14653
14654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014655 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014656 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14657
14658 { } /* end */
14659};
14660
14661/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014662static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014663{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014664 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014665
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014666 spec->autocfg.hp_pins[0] = 0x15;
14667 spec->autocfg.speaker_pins[0] = 0x14;
14668 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014669}
14670
Takashi Iwaicb53c622007-08-10 17:21:45 +020014671#ifdef CONFIG_SND_HDA_POWER_SAVE
14672#define alc861vd_loopbacks alc880_loopbacks
14673#endif
14674
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014675/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014676#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14677#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14678#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14679#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14680
14681/*
14682 * configuration and preset
14683 */
14684static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14685 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014686 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014687 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014688 [ALC861VD_3ST] = "3stack",
14689 [ALC861VD_3ST_DIG] = "3stack-digout",
14690 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014691 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014692 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014693 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014694 [ALC861VD_AUTO] = "auto",
14695};
14696
14697static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014698 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14699 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014700 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014701 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014702 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014703 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014704 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014705 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014706 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014707 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014708 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014709 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014710 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014711 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014712 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014713 {}
14714};
14715
14716static struct alc_config_preset alc861vd_presets[] = {
14717 [ALC660VD_3ST] = {
14718 .mixers = { alc861vd_3st_mixer },
14719 .init_verbs = { alc861vd_volume_init_verbs,
14720 alc861vd_3stack_init_verbs },
14721 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14722 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014723 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14724 .channel_mode = alc861vd_3stack_2ch_modes,
14725 .input_mux = &alc861vd_capture_source,
14726 },
Mike Crash6963f842007-06-25 12:12:51 +020014727 [ALC660VD_3ST_DIG] = {
14728 .mixers = { alc861vd_3st_mixer },
14729 .init_verbs = { alc861vd_volume_init_verbs,
14730 alc861vd_3stack_init_verbs },
14731 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14732 .dac_nids = alc660vd_dac_nids,
14733 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014734 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14735 .channel_mode = alc861vd_3stack_2ch_modes,
14736 .input_mux = &alc861vd_capture_source,
14737 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014738 [ALC861VD_3ST] = {
14739 .mixers = { alc861vd_3st_mixer },
14740 .init_verbs = { alc861vd_volume_init_verbs,
14741 alc861vd_3stack_init_verbs },
14742 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14743 .dac_nids = alc861vd_dac_nids,
14744 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14745 .channel_mode = alc861vd_3stack_2ch_modes,
14746 .input_mux = &alc861vd_capture_source,
14747 },
14748 [ALC861VD_3ST_DIG] = {
14749 .mixers = { alc861vd_3st_mixer },
14750 .init_verbs = { alc861vd_volume_init_verbs,
14751 alc861vd_3stack_init_verbs },
14752 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14753 .dac_nids = alc861vd_dac_nids,
14754 .dig_out_nid = ALC861VD_DIGOUT_NID,
14755 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14756 .channel_mode = alc861vd_3stack_2ch_modes,
14757 .input_mux = &alc861vd_capture_source,
14758 },
14759 [ALC861VD_6ST_DIG] = {
14760 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14761 .init_verbs = { alc861vd_volume_init_verbs,
14762 alc861vd_6stack_init_verbs },
14763 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14764 .dac_nids = alc861vd_dac_nids,
14765 .dig_out_nid = ALC861VD_DIGOUT_NID,
14766 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14767 .channel_mode = alc861vd_6stack_modes,
14768 .input_mux = &alc861vd_capture_source,
14769 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014770 [ALC861VD_LENOVO] = {
14771 .mixers = { alc861vd_lenovo_mixer },
14772 .init_verbs = { alc861vd_volume_init_verbs,
14773 alc861vd_3stack_init_verbs,
14774 alc861vd_eapd_verbs,
14775 alc861vd_lenovo_unsol_verbs },
14776 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14777 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014778 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14779 .channel_mode = alc861vd_3stack_2ch_modes,
14780 .input_mux = &alc861vd_capture_source,
14781 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014782 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014783 },
Kailang Yang272a5272007-05-14 11:00:38 +020014784 [ALC861VD_DALLAS] = {
14785 .mixers = { alc861vd_dallas_mixer },
14786 .init_verbs = { alc861vd_dallas_verbs },
14787 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14788 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014789 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14790 .channel_mode = alc861vd_3stack_2ch_modes,
14791 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014792 .unsol_event = alc_automute_amp_unsol_event,
14793 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014794 },
14795 [ALC861VD_HP] = {
14796 .mixers = { alc861vd_hp_mixer },
14797 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14798 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14799 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014800 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014801 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14802 .channel_mode = alc861vd_3stack_2ch_modes,
14803 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014804 .unsol_event = alc_automute_amp_unsol_event,
14805 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014806 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014807 [ALC660VD_ASUS_V1S] = {
14808 .mixers = { alc861vd_lenovo_mixer },
14809 .init_verbs = { alc861vd_volume_init_verbs,
14810 alc861vd_3stack_init_verbs,
14811 alc861vd_eapd_verbs,
14812 alc861vd_lenovo_unsol_verbs },
14813 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14814 .dac_nids = alc660vd_dac_nids,
14815 .dig_out_nid = ALC861VD_DIGOUT_NID,
14816 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14817 .channel_mode = alc861vd_3stack_2ch_modes,
14818 .input_mux = &alc861vd_capture_source,
14819 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014820 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014821 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822};
14823
14824/*
14825 * BIOS auto configuration
14826 */
14827static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14828 hda_nid_t nid, int pin_type, int dac_idx)
14829{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014830 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014831}
14832
14833static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14834{
14835 struct alc_spec *spec = codec->spec;
14836 int i;
14837
14838 for (i = 0; i <= HDA_SIDE; i++) {
14839 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014840 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841 if (nid)
14842 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014843 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014844 }
14845}
14846
14847
14848static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14849{
14850 struct alc_spec *spec = codec->spec;
14851 hda_nid_t pin;
14852
14853 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014854 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014855 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014856 pin = spec->autocfg.speaker_pins[0];
14857 if (pin)
14858 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014859}
14860
14861#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14862#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14863
14864static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14865{
14866 struct alc_spec *spec = codec->spec;
14867 int i;
14868
14869 for (i = 0; i < AUTO_PIN_LAST; i++) {
14870 hda_nid_t nid = spec->autocfg.input_pins[i];
14871 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014872 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014873 if (nid != ALC861VD_PIN_CD_NID &&
14874 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014875 snd_hda_codec_write(codec, nid, 0,
14876 AC_VERB_SET_AMP_GAIN_MUTE,
14877 AMP_OUT_MUTE);
14878 }
14879 }
14880}
14881
Takashi Iwaif511b012008-08-15 16:46:42 +020014882#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14883
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014884#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14885#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14886
14887/* add playback controls from the parsed DAC table */
14888/* Based on ALC880 version. But ALC861VD has separate,
14889 * different NIDs for mute/unmute switch and volume control */
14890static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14891 const struct auto_pin_cfg *cfg)
14892{
14893 char name[32];
14894 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14895 hda_nid_t nid_v, nid_s;
14896 int i, err;
14897
14898 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014899 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014900 continue;
14901 nid_v = alc861vd_idx_to_mixer_vol(
14902 alc880_dac_to_idx(
14903 spec->multiout.dac_nids[i]));
14904 nid_s = alc861vd_idx_to_mixer_switch(
14905 alc880_dac_to_idx(
14906 spec->multiout.dac_nids[i]));
14907
14908 if (i == 2) {
14909 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014910 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14911 "Center Playback Volume",
14912 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14913 HDA_OUTPUT));
14914 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014915 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014916 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14917 "LFE Playback Volume",
14918 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14919 HDA_OUTPUT));
14920 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014922 err = add_control(spec, ALC_CTL_BIND_MUTE,
14923 "Center Playback Switch",
14924 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14925 HDA_INPUT));
14926 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014927 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014928 err = add_control(spec, ALC_CTL_BIND_MUTE,
14929 "LFE Playback Switch",
14930 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14931 HDA_INPUT));
14932 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014933 return err;
14934 } else {
14935 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014936 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14937 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14938 HDA_OUTPUT));
14939 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014940 return err;
14941 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014942 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014943 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014944 HDA_INPUT));
14945 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014946 return err;
14947 }
14948 }
14949 return 0;
14950}
14951
14952/* add playback controls for speaker and HP outputs */
14953/* Based on ALC880 version. But ALC861VD has separate,
14954 * different NIDs for mute/unmute switch and volume control */
14955static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14956 hda_nid_t pin, const char *pfx)
14957{
14958 hda_nid_t nid_v, nid_s;
14959 int err;
14960 char name[32];
14961
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014962 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014963 return 0;
14964
14965 if (alc880_is_fixed_pin(pin)) {
14966 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14967 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014968 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014969 spec->multiout.hp_nid = nid_v;
14970 else
14971 spec->multiout.extra_out_nid[0] = nid_v;
14972 /* control HP volume/switch on the output mixer amp */
14973 nid_v = alc861vd_idx_to_mixer_vol(
14974 alc880_fixed_pin_idx(pin));
14975 nid_s = alc861vd_idx_to_mixer_switch(
14976 alc880_fixed_pin_idx(pin));
14977
14978 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014979 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14980 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14981 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014982 return err;
14983 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014984 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14985 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14986 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987 return err;
14988 } else if (alc880_is_multi_pin(pin)) {
14989 /* set manual connection */
14990 /* we have only a switch on HP-out PIN */
14991 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014992 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14993 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14994 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995 return err;
14996 }
14997 return 0;
14998}
14999
15000/* parse the BIOS configuration and set up the alc_spec
15001 * return 1 if successful, 0 if the proper config is not found,
15002 * or a negative error code
15003 * Based on ALC880 version - had to change it to override
15004 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15005static int alc861vd_parse_auto_config(struct hda_codec *codec)
15006{
15007 struct alc_spec *spec = codec->spec;
15008 int err;
15009 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15010
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015011 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15012 alc861vd_ignore);
15013 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015015 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015016 return 0; /* can't find valid BIOS pin config */
15017
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015018 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15019 if (err < 0)
15020 return err;
15021 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15022 if (err < 0)
15023 return err;
15024 err = alc861vd_auto_create_extra_out(spec,
15025 spec->autocfg.speaker_pins[0],
15026 "Speaker");
15027 if (err < 0)
15028 return err;
15029 err = alc861vd_auto_create_extra_out(spec,
15030 spec->autocfg.hp_pins[0],
15031 "Headphone");
15032 if (err < 0)
15033 return err;
15034 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15035 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015036 return err;
15037
15038 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15039
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015040 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015041 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15042
Takashi Iwai603c4012008-07-30 15:01:44 +020015043 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015044 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015045
Takashi Iwaid88897e2008-10-31 15:01:37 +010015046 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015047
15048 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015049 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015050
Takashi Iwai776e1842007-08-29 15:07:11 +020015051 err = alc_auto_add_mic_boost(codec);
15052 if (err < 0)
15053 return err;
15054
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015055 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15056
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015057 return 1;
15058}
15059
15060/* additional initialization for auto-configuration model */
15061static void alc861vd_auto_init(struct hda_codec *codec)
15062{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015063 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015064 alc861vd_auto_init_multi_out(codec);
15065 alc861vd_auto_init_hp_out(codec);
15066 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015067 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015068 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015069 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015070}
15071
15072static int patch_alc861vd(struct hda_codec *codec)
15073{
15074 struct alc_spec *spec;
15075 int err, board_config;
15076
15077 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15078 if (spec == NULL)
15079 return -ENOMEM;
15080
15081 codec->spec = spec;
15082
15083 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15084 alc861vd_models,
15085 alc861vd_cfg_tbl);
15086
15087 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015088 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15089 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015090 board_config = ALC861VD_AUTO;
15091 }
15092
15093 if (board_config == ALC861VD_AUTO) {
15094 /* automatic parse from the BIOS config */
15095 err = alc861vd_parse_auto_config(codec);
15096 if (err < 0) {
15097 alc_free(codec);
15098 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015099 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015100 printk(KERN_INFO
15101 "hda_codec: Cannot set up configuration "
15102 "from BIOS. Using base mode...\n");
15103 board_config = ALC861VD_3ST;
15104 }
15105 }
15106
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015107 err = snd_hda_attach_beep_device(codec, 0x23);
15108 if (err < 0) {
15109 alc_free(codec);
15110 return err;
15111 }
15112
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015113 if (board_config != ALC861VD_AUTO)
15114 setup_preset(spec, &alc861vd_presets[board_config]);
15115
Kailang Yang2f893282008-05-27 12:14:47 +020015116 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015117 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015118 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015119 }
15120
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015121 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15122 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15123
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015124 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15125 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15126
15127 spec->adc_nids = alc861vd_adc_nids;
15128 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015129 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015130
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015131 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015132 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015133
Takashi Iwai2134ea42008-01-10 16:53:55 +010015134 spec->vmaster_nid = 0x02;
15135
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015136 codec->patch_ops = alc_patch_ops;
15137
15138 if (board_config == ALC861VD_AUTO)
15139 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015140#ifdef CONFIG_SND_HDA_POWER_SAVE
15141 if (!spec->loopback.amplist)
15142 spec->loopback.amplist = alc861vd_loopbacks;
15143#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015144 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015145
15146 return 0;
15147}
15148
15149/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015150 * ALC662 support
15151 *
15152 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15153 * configuration. Each pin widget can choose any input DACs and a mixer.
15154 * Each ADC is connected from a mixer of all inputs. This makes possible
15155 * 6-channel independent captures.
15156 *
15157 * In addition, an independent DAC for the multi-playback (not used in this
15158 * driver yet).
15159 */
15160#define ALC662_DIGOUT_NID 0x06
15161#define ALC662_DIGIN_NID 0x0a
15162
15163static hda_nid_t alc662_dac_nids[4] = {
15164 /* front, rear, clfe, rear_surr */
15165 0x02, 0x03, 0x04
15166};
15167
Kailang Yang622e84c2009-04-21 07:39:04 +020015168static hda_nid_t alc272_dac_nids[2] = {
15169 0x02, 0x03
15170};
15171
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015172static hda_nid_t alc662_adc_nids[1] = {
15173 /* ADC1-2 */
15174 0x09,
15175};
Takashi Iwaie1406342008-02-11 18:32:32 +010015176
Kailang Yang622e84c2009-04-21 07:39:04 +020015177static hda_nid_t alc272_adc_nids[1] = {
15178 /* ADC1-2 */
15179 0x08,
15180};
15181
Kailang Yang77a261b2008-02-19 11:38:05 +010015182static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015183static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15184
Takashi Iwaie1406342008-02-11 18:32:32 +010015185
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015186/* input MUX */
15187/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015188static struct hda_input_mux alc662_capture_source = {
15189 .num_items = 4,
15190 .items = {
15191 { "Mic", 0x0 },
15192 { "Front Mic", 0x1 },
15193 { "Line", 0x2 },
15194 { "CD", 0x4 },
15195 },
15196};
15197
15198static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15199 .num_items = 2,
15200 .items = {
15201 { "Mic", 0x1 },
15202 { "Line", 0x2 },
15203 },
15204};
Kailang Yang291702f2007-10-16 14:28:03 +020015205
15206static struct hda_input_mux alc662_eeepc_capture_source = {
15207 .num_items = 2,
15208 .items = {
15209 { "i-Mic", 0x1 },
15210 { "e-Mic", 0x0 },
15211 },
15212};
15213
Kailang Yang6dda9f42008-05-27 12:05:31 +020015214static struct hda_input_mux alc663_capture_source = {
15215 .num_items = 3,
15216 .items = {
15217 { "Mic", 0x0 },
15218 { "Front Mic", 0x1 },
15219 { "Line", 0x2 },
15220 },
15221};
15222
15223static struct hda_input_mux alc663_m51va_capture_source = {
15224 .num_items = 2,
15225 .items = {
15226 { "Ext-Mic", 0x0 },
15227 { "D-Mic", 0x9 },
15228 },
15229};
15230
Chris Pockelé9541ba12009-05-12 08:08:53 +020015231#if 1 /* set to 0 for testing other input sources below */
15232static struct hda_input_mux alc272_nc10_capture_source = {
15233 .num_items = 2,
15234 .items = {
15235 { "Autoselect Mic", 0x0 },
15236 { "Internal Mic", 0x1 },
15237 },
15238};
15239#else
15240static struct hda_input_mux alc272_nc10_capture_source = {
15241 .num_items = 16,
15242 .items = {
15243 { "Autoselect Mic", 0x0 },
15244 { "Internal Mic", 0x1 },
15245 { "In-0x02", 0x2 },
15246 { "In-0x03", 0x3 },
15247 { "In-0x04", 0x4 },
15248 { "In-0x05", 0x5 },
15249 { "In-0x06", 0x6 },
15250 { "In-0x07", 0x7 },
15251 { "In-0x08", 0x8 },
15252 { "In-0x09", 0x9 },
15253 { "In-0x0a", 0x0a },
15254 { "In-0x0b", 0x0b },
15255 { "In-0x0c", 0x0c },
15256 { "In-0x0d", 0x0d },
15257 { "In-0x0e", 0x0e },
15258 { "In-0x0f", 0x0f },
15259 },
15260};
15261#endif
15262
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015263/*
15264 * 2ch mode
15265 */
15266static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15267 { 2, NULL }
15268};
15269
15270/*
15271 * 2ch mode
15272 */
15273static struct hda_verb alc662_3ST_ch2_init[] = {
15274 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15275 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15276 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15277 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15278 { } /* end */
15279};
15280
15281/*
15282 * 6ch mode
15283 */
15284static struct hda_verb alc662_3ST_ch6_init[] = {
15285 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15286 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15287 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15288 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15289 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15290 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15291 { } /* end */
15292};
15293
15294static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15295 { 2, alc662_3ST_ch2_init },
15296 { 6, alc662_3ST_ch6_init },
15297};
15298
15299/*
15300 * 2ch mode
15301 */
15302static struct hda_verb alc662_sixstack_ch6_init[] = {
15303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15305 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15306 { } /* end */
15307};
15308
15309/*
15310 * 6ch mode
15311 */
15312static struct hda_verb alc662_sixstack_ch8_init[] = {
15313 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15314 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15315 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15316 { } /* end */
15317};
15318
15319static struct hda_channel_mode alc662_5stack_modes[2] = {
15320 { 2, alc662_sixstack_ch6_init },
15321 { 6, alc662_sixstack_ch8_init },
15322};
15323
15324/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15325 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15326 */
15327
15328static struct snd_kcontrol_new alc662_base_mixer[] = {
15329 /* output mixer control */
15330 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015331 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015332 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015333 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015334 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15335 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015336 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15337 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15339
15340 /*Input mixer control */
15341 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15342 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15343 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15344 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15345 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15346 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015349 { } /* end */
15350};
15351
15352static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15353 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015354 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015364 { } /* end */
15365};
15366
15367static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15368 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015369 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015370 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015371 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015372 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15373 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015374 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15375 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015385 { } /* end */
15386};
15387
15388static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15389 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15390 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015391 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15392 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015398 { } /* end */
15399};
15400
Kailang Yang291702f2007-10-16 14:28:03 +020015401static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015402 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15403 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015404
15405 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15406 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15407 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15408
15409 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15410 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15411 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15412 { } /* end */
15413};
15414
Kailang Yang8c427222008-01-10 13:03:59 +010015415static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015416 ALC262_HIPPO_MASTER_SWITCH,
15417 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015418 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015419 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015421 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15426 { } /* end */
15427};
15428
Kailang Yangf1d4e282008-08-26 14:03:29 +020015429static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15430 .ops = &snd_hda_bind_vol,
15431 .values = {
15432 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15433 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15434 0
15435 },
15436};
15437
15438static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15439 .ops = &snd_hda_bind_sw,
15440 .values = {
15441 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15442 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15443 0
15444 },
15445};
15446
Kailang Yang6dda9f42008-05-27 12:05:31 +020015447static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015448 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15449 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15452 { } /* end */
15453};
15454
15455static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15456 .ops = &snd_hda_bind_sw,
15457 .values = {
15458 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15459 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15460 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15461 0
15462 },
15463};
15464
15465static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15466 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15467 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15470 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15471 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15472
15473 { } /* end */
15474};
15475
15476static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15477 .ops = &snd_hda_bind_sw,
15478 .values = {
15479 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15480 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15481 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15482 0
15483 },
15484};
15485
15486static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15487 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15488 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15491 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15492 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15493 { } /* end */
15494};
15495
15496static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015497 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15498 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15502 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15503 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15504 { } /* end */
15505};
15506
15507static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15508 .ops = &snd_hda_bind_vol,
15509 .values = {
15510 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15511 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15512 0
15513 },
15514};
15515
15516static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15517 .ops = &snd_hda_bind_sw,
15518 .values = {
15519 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15520 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15521 0
15522 },
15523};
15524
15525static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15526 HDA_BIND_VOL("Master Playback Volume",
15527 &alc663_asus_two_bind_master_vol),
15528 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015533 { } /* end */
15534};
15535
15536static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15537 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15538 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015543 { } /* end */
15544};
15545
15546static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15547 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15548 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15549 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15550 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15552
15553 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15554 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15555 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15556 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15557 { } /* end */
15558};
15559
15560static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15561 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15562 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15564
15565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15567 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15568 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15569 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15570 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15571 { } /* end */
15572};
15573
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015574static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15575 {
15576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15577 .name = "Channel Mode",
15578 .info = alc_ch_mode_info,
15579 .get = alc_ch_mode_get,
15580 .put = alc_ch_mode_put,
15581 },
15582 { } /* end */
15583};
15584
15585static struct hda_verb alc662_init_verbs[] = {
15586 /* ADC: mute amp left and right */
15587 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15588 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15589 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15590
Takashi Iwaicb53c622007-08-10 17:21:45 +020015591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15592 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15593 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15594 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15595 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015596
Kailang Yangb60dd392007-09-20 12:50:29 +020015597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015603
15604 /* Front Pin: output 0 (0x0c) */
15605 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607
15608 /* Rear Pin: output 1 (0x0d) */
15609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15611
15612 /* CLFE Pin: output 2 (0x0e) */
15613 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15614 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15615
15616 /* Mic (rear) pin: input vref at 80% */
15617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15619 /* Front Mic pin: input vref at 80% */
15620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15621 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15622 /* Line In pin: input */
15623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15625 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15628 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15629 /* CD pin widget for input */
15630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15631
15632 /* FIXME: use matrix-type input source selection */
15633 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15634 /* Input mixer */
15635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015637
15638 /* always trun on EAPD */
15639 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15640 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15641
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015642 { }
15643};
15644
15645static struct hda_verb alc662_sue_init_verbs[] = {
15646 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15647 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015648 {}
15649};
15650
15651static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15652 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15654 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015655};
15656
Kailang Yang8c427222008-01-10 13:03:59 +010015657/* Set Unsolicited Event*/
15658static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15660 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15661 {}
15662};
15663
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015664/*
15665 * generic initialization of ADC, input mixers and output mixers
15666 */
15667static struct hda_verb alc662_auto_init_verbs[] = {
15668 /*
15669 * Unmute ADC and set the default input to mic-in
15670 */
15671 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15673
15674 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15675 * mixer widget
15676 * Note: PASD motherboards uses the Line In 2 as the input for front
15677 * panel mic (mic 2)
15678 */
15679 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015685
15686 /*
15687 * Set up output mixers (0x0c - 0x0f)
15688 */
15689 /* set vol=0 to output mixers */
15690 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15691 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15693
15694 /* set up input amps for analog loopback */
15695 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015702
15703
15704 /* FIXME: use matrix-type input source selection */
15705 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15706 /* Input mixer */
15707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015709 { }
15710};
15711
Takashi Iwai24fb9172008-09-02 14:48:20 +020015712/* additional verbs for ALC663 */
15713static struct hda_verb alc663_auto_init_verbs[] = {
15714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15716 { }
15717};
15718
Kailang Yang6dda9f42008-05-27 12:05:31 +020015719static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15721 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015722 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15723 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015724 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015727 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15728 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15729 {}
15730};
15731
Kailang Yangf1d4e282008-08-26 14:03:29 +020015732static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15733 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15734 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15735 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15738 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15739 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15740 {}
15741};
15742
15743static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15744 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15745 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15746 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15747 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15750 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15751 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15752 {}
15753};
15754
15755static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15758 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15761 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15762 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15763 {}
15764};
15765
15766static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15768 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15769 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15770 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15776 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15777 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15778 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15779 {}
15780};
15781
15782static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15784 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15785 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15786 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15789 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15791 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15792 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15793 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15795 {}
15796};
15797
Kailang Yang6dda9f42008-05-27 12:05:31 +020015798static struct hda_verb alc663_g71v_init_verbs[] = {
15799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15800 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15801 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15802
15803 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15804 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15805 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15806
15807 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15808 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15809 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15810 {}
15811};
15812
15813static struct hda_verb alc663_g50v_init_verbs[] = {
15814 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15815 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15816 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15817
15818 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15819 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15820 {}
15821};
15822
Kailang Yangf1d4e282008-08-26 14:03:29 +020015823static struct hda_verb alc662_ecs_init_verbs[] = {
15824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15826 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15827 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15828 {}
15829};
15830
Kailang Yang622e84c2009-04-21 07:39:04 +020015831static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15832 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15833 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15836 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15837 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15838 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15841 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15842 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15843 {}
15844};
15845
15846static struct hda_verb alc272_dell_init_verbs[] = {
15847 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15848 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15851 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15852 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15853 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15856 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15857 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15858 {}
15859};
15860
Kailang Yangf1d4e282008-08-26 14:03:29 +020015861static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15862 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15863 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15864 { } /* end */
15865};
15866
Kailang Yang622e84c2009-04-21 07:39:04 +020015867static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15868 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15869 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15870 { } /* end */
15871};
15872
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015873static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15874{
15875 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015876 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015877
15878 present = snd_hda_codec_read(codec, 0x14, 0,
15879 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015880 bits = present ? HDA_AMP_MUTE : 0;
15881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15882 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015883}
15884
15885static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15886{
15887 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015888 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015889
15890 present = snd_hda_codec_read(codec, 0x1b, 0,
15891 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015892 bits = present ? HDA_AMP_MUTE : 0;
15893 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15894 HDA_AMP_MUTE, bits);
15895 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15896 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015897}
15898
15899static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15900 unsigned int res)
15901{
15902 if ((res >> 26) == ALC880_HP_EVENT)
15903 alc662_lenovo_101e_all_automute(codec);
15904 if ((res >> 26) == ALC880_FRONT_EVENT)
15905 alc662_lenovo_101e_ispeaker_automute(codec);
15906}
15907
Kailang Yang291702f2007-10-16 14:28:03 +020015908static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15909{
15910 unsigned int present;
15911
15912 present = snd_hda_codec_read(codec, 0x18, 0,
15913 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15914 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15915 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15916 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15917 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15918 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15919 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15920 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15921 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15922}
15923
15924/* unsolicited event for HP jack sensing */
15925static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15926 unsigned int res)
15927{
Kailang Yang291702f2007-10-16 14:28:03 +020015928 if ((res >> 26) == ALC880_MIC_EVENT)
15929 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015930 else
15931 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015932}
15933
15934static void alc662_eeepc_inithook(struct hda_codec *codec)
15935{
Takashi Iwai42171c12009-05-08 14:11:43 +020015936 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015937 alc662_eeepc_mic_automute(codec);
15938}
15939
Kailang Yang8c427222008-01-10 13:03:59 +010015940static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15941{
Takashi Iwai42171c12009-05-08 14:11:43 +020015942 struct alc_spec *spec = codec->spec;
15943
15944 spec->autocfg.hp_pins[0] = 0x14;
15945 spec->autocfg.speaker_pins[0] = 0x1b;
15946 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015947}
15948
Kailang Yang6dda9f42008-05-27 12:05:31 +020015949static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15950{
15951 unsigned int present;
15952 unsigned char bits;
15953
15954 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015955 AC_VERB_GET_PIN_SENSE, 0)
15956 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015957 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015958 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15959 AMP_IN_MUTE(0), bits);
15960 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15961 AMP_IN_MUTE(0), bits);
15962}
15963
15964static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15965{
15966 unsigned int present;
15967 unsigned char bits;
15968
15969 present = snd_hda_codec_read(codec, 0x21, 0,
15970 AC_VERB_GET_PIN_SENSE, 0)
15971 & AC_PINSENSE_PRESENCE;
15972 bits = present ? HDA_AMP_MUTE : 0;
15973 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15974 AMP_IN_MUTE(0), bits);
15975 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15976 AMP_IN_MUTE(0), bits);
15977 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15978 AMP_IN_MUTE(0), bits);
15979 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15980 AMP_IN_MUTE(0), bits);
15981}
15982
15983static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15984{
15985 unsigned int present;
15986 unsigned char bits;
15987
15988 present = snd_hda_codec_read(codec, 0x15, 0,
15989 AC_VERB_GET_PIN_SENSE, 0)
15990 & AC_PINSENSE_PRESENCE;
15991 bits = present ? HDA_AMP_MUTE : 0;
15992 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15993 AMP_IN_MUTE(0), bits);
15994 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15995 AMP_IN_MUTE(0), bits);
15996 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15997 AMP_IN_MUTE(0), bits);
15998 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15999 AMP_IN_MUTE(0), bits);
16000}
16001
16002static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16003{
16004 unsigned int present;
16005 unsigned char bits;
16006
16007 present = snd_hda_codec_read(codec, 0x1b, 0,
16008 AC_VERB_GET_PIN_SENSE, 0)
16009 & AC_PINSENSE_PRESENCE;
16010 bits = present ? 0 : PIN_OUT;
16011 snd_hda_codec_write(codec, 0x14, 0,
16012 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16013}
16014
16015static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16016{
16017 unsigned int present1, present2;
16018
16019 present1 = snd_hda_codec_read(codec, 0x21, 0,
16020 AC_VERB_GET_PIN_SENSE, 0)
16021 & AC_PINSENSE_PRESENCE;
16022 present2 = snd_hda_codec_read(codec, 0x15, 0,
16023 AC_VERB_GET_PIN_SENSE, 0)
16024 & AC_PINSENSE_PRESENCE;
16025
16026 if (present1 || present2) {
16027 snd_hda_codec_write_cache(codec, 0x14, 0,
16028 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16029 } else {
16030 snd_hda_codec_write_cache(codec, 0x14, 0,
16031 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16032 }
16033}
16034
16035static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16036{
16037 unsigned int present1, present2;
16038
16039 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16040 AC_VERB_GET_PIN_SENSE, 0)
16041 & AC_PINSENSE_PRESENCE;
16042 present2 = snd_hda_codec_read(codec, 0x15, 0,
16043 AC_VERB_GET_PIN_SENSE, 0)
16044 & AC_PINSENSE_PRESENCE;
16045
16046 if (present1 || present2) {
16047 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16048 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16049 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16050 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16051 } else {
16052 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16053 AMP_IN_MUTE(0), 0);
16054 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16055 AMP_IN_MUTE(0), 0);
16056 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016057}
16058
16059static void alc663_m51va_mic_automute(struct hda_codec *codec)
16060{
16061 unsigned int present;
16062
16063 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016064 AC_VERB_GET_PIN_SENSE, 0)
16065 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016066 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016067 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016068 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016069 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016070 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016071 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016072 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016073 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016074}
16075
16076static void alc663_m51va_unsol_event(struct hda_codec *codec,
16077 unsigned int res)
16078{
16079 switch (res >> 26) {
16080 case ALC880_HP_EVENT:
16081 alc663_m51va_speaker_automute(codec);
16082 break;
16083 case ALC880_MIC_EVENT:
16084 alc663_m51va_mic_automute(codec);
16085 break;
16086 }
16087}
16088
16089static void alc663_m51va_inithook(struct hda_codec *codec)
16090{
16091 alc663_m51va_speaker_automute(codec);
16092 alc663_m51va_mic_automute(codec);
16093}
16094
Kailang Yangf1d4e282008-08-26 14:03:29 +020016095/* ***************** Mode1 ******************************/
16096static void alc663_mode1_unsol_event(struct hda_codec *codec,
16097 unsigned int res)
16098{
16099 switch (res >> 26) {
16100 case ALC880_HP_EVENT:
16101 alc663_m51va_speaker_automute(codec);
16102 break;
16103 case ALC880_MIC_EVENT:
16104 alc662_eeepc_mic_automute(codec);
16105 break;
16106 }
16107}
16108
16109static void alc663_mode1_inithook(struct hda_codec *codec)
16110{
16111 alc663_m51va_speaker_automute(codec);
16112 alc662_eeepc_mic_automute(codec);
16113}
16114/* ***************** Mode2 ******************************/
16115static void alc662_mode2_unsol_event(struct hda_codec *codec,
16116 unsigned int res)
16117{
16118 switch (res >> 26) {
16119 case ALC880_HP_EVENT:
16120 alc662_f5z_speaker_automute(codec);
16121 break;
16122 case ALC880_MIC_EVENT:
16123 alc662_eeepc_mic_automute(codec);
16124 break;
16125 }
16126}
16127
16128static void alc662_mode2_inithook(struct hda_codec *codec)
16129{
16130 alc662_f5z_speaker_automute(codec);
16131 alc662_eeepc_mic_automute(codec);
16132}
16133/* ***************** Mode3 ******************************/
16134static void alc663_mode3_unsol_event(struct hda_codec *codec,
16135 unsigned int res)
16136{
16137 switch (res >> 26) {
16138 case ALC880_HP_EVENT:
16139 alc663_two_hp_m1_speaker_automute(codec);
16140 break;
16141 case ALC880_MIC_EVENT:
16142 alc662_eeepc_mic_automute(codec);
16143 break;
16144 }
16145}
16146
16147static void alc663_mode3_inithook(struct hda_codec *codec)
16148{
16149 alc663_two_hp_m1_speaker_automute(codec);
16150 alc662_eeepc_mic_automute(codec);
16151}
16152/* ***************** Mode4 ******************************/
16153static void alc663_mode4_unsol_event(struct hda_codec *codec,
16154 unsigned int res)
16155{
16156 switch (res >> 26) {
16157 case ALC880_HP_EVENT:
16158 alc663_21jd_two_speaker_automute(codec);
16159 break;
16160 case ALC880_MIC_EVENT:
16161 alc662_eeepc_mic_automute(codec);
16162 break;
16163 }
16164}
16165
16166static void alc663_mode4_inithook(struct hda_codec *codec)
16167{
16168 alc663_21jd_two_speaker_automute(codec);
16169 alc662_eeepc_mic_automute(codec);
16170}
16171/* ***************** Mode5 ******************************/
16172static void alc663_mode5_unsol_event(struct hda_codec *codec,
16173 unsigned int res)
16174{
16175 switch (res >> 26) {
16176 case ALC880_HP_EVENT:
16177 alc663_15jd_two_speaker_automute(codec);
16178 break;
16179 case ALC880_MIC_EVENT:
16180 alc662_eeepc_mic_automute(codec);
16181 break;
16182 }
16183}
16184
16185static void alc663_mode5_inithook(struct hda_codec *codec)
16186{
16187 alc663_15jd_two_speaker_automute(codec);
16188 alc662_eeepc_mic_automute(codec);
16189}
16190/* ***************** Mode6 ******************************/
16191static void alc663_mode6_unsol_event(struct hda_codec *codec,
16192 unsigned int res)
16193{
16194 switch (res >> 26) {
16195 case ALC880_HP_EVENT:
16196 alc663_two_hp_m2_speaker_automute(codec);
16197 break;
16198 case ALC880_MIC_EVENT:
16199 alc662_eeepc_mic_automute(codec);
16200 break;
16201 }
16202}
16203
16204static void alc663_mode6_inithook(struct hda_codec *codec)
16205{
16206 alc663_two_hp_m2_speaker_automute(codec);
16207 alc662_eeepc_mic_automute(codec);
16208}
16209
Kailang Yang6dda9f42008-05-27 12:05:31 +020016210static void alc663_g71v_hp_automute(struct hda_codec *codec)
16211{
16212 unsigned int present;
16213 unsigned char bits;
16214
16215 present = snd_hda_codec_read(codec, 0x21, 0,
16216 AC_VERB_GET_PIN_SENSE, 0)
16217 & AC_PINSENSE_PRESENCE;
16218 bits = present ? HDA_AMP_MUTE : 0;
16219 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16220 HDA_AMP_MUTE, bits);
16221 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16222 HDA_AMP_MUTE, bits);
16223}
16224
16225static void alc663_g71v_front_automute(struct hda_codec *codec)
16226{
16227 unsigned int present;
16228 unsigned char bits;
16229
16230 present = snd_hda_codec_read(codec, 0x15, 0,
16231 AC_VERB_GET_PIN_SENSE, 0)
16232 & AC_PINSENSE_PRESENCE;
16233 bits = present ? HDA_AMP_MUTE : 0;
16234 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16235 HDA_AMP_MUTE, bits);
16236}
16237
16238static void alc663_g71v_unsol_event(struct hda_codec *codec,
16239 unsigned int res)
16240{
16241 switch (res >> 26) {
16242 case ALC880_HP_EVENT:
16243 alc663_g71v_hp_automute(codec);
16244 break;
16245 case ALC880_FRONT_EVENT:
16246 alc663_g71v_front_automute(codec);
16247 break;
16248 case ALC880_MIC_EVENT:
16249 alc662_eeepc_mic_automute(codec);
16250 break;
16251 }
16252}
16253
16254static void alc663_g71v_inithook(struct hda_codec *codec)
16255{
16256 alc663_g71v_front_automute(codec);
16257 alc663_g71v_hp_automute(codec);
16258 alc662_eeepc_mic_automute(codec);
16259}
16260
16261static void alc663_g50v_unsol_event(struct hda_codec *codec,
16262 unsigned int res)
16263{
16264 switch (res >> 26) {
16265 case ALC880_HP_EVENT:
16266 alc663_m51va_speaker_automute(codec);
16267 break;
16268 case ALC880_MIC_EVENT:
16269 alc662_eeepc_mic_automute(codec);
16270 break;
16271 }
16272}
16273
16274static void alc663_g50v_inithook(struct hda_codec *codec)
16275{
16276 alc663_m51va_speaker_automute(codec);
16277 alc662_eeepc_mic_automute(codec);
16278}
16279
Kailang Yangf1d4e282008-08-26 14:03:29 +020016280static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16281 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016282 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016283
16284 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16285 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16286 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16287
16288 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16289 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16290 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16291 { } /* end */
16292};
16293
Chris Pockelé9541ba12009-05-12 08:08:53 +020016294static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16295 /* Master Playback automatically created from Speaker and Headphone */
16296 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16297 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16298 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16300
16301 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16302 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16303 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16304
16305 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16306 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16307 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16308 { } /* end */
16309};
16310
Takashi Iwaicb53c622007-08-10 17:21:45 +020016311#ifdef CONFIG_SND_HDA_POWER_SAVE
16312#define alc662_loopbacks alc880_loopbacks
16313#endif
16314
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016316/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016317#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16318#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16319#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16320#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16321
16322/*
16323 * configuration and preset
16324 */
16325static const char *alc662_models[ALC662_MODEL_LAST] = {
16326 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16327 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16328 [ALC662_3ST_6ch] = "3stack-6ch",
16329 [ALC662_5ST_DIG] = "6stack-dig",
16330 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016331 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016332 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016333 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016334 [ALC663_ASUS_M51VA] = "m51va",
16335 [ALC663_ASUS_G71V] = "g71v",
16336 [ALC663_ASUS_H13] = "h13",
16337 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016338 [ALC663_ASUS_MODE1] = "asus-mode1",
16339 [ALC662_ASUS_MODE2] = "asus-mode2",
16340 [ALC663_ASUS_MODE3] = "asus-mode3",
16341 [ALC663_ASUS_MODE4] = "asus-mode4",
16342 [ALC663_ASUS_MODE5] = "asus-mode5",
16343 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016344 [ALC272_DELL] = "dell",
16345 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016346 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016347 [ALC662_AUTO] = "auto",
16348};
16349
16350static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016351 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016352 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16353 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016354 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16355 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16356 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16357 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16358 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16359 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16360 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16361 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16362 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16363 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16364 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16365 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016366 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16367 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16368 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016369 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16370 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16371 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16372 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016373 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016374 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16375 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016376 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016377 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16378 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16379 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016380 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16381 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16382 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016383 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16384 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16385 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016386 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016387 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16388 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016389 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016390 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016391 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016392 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16393 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16394 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016395 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016396 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16397 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016398 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016399 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016400 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016401 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016402 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16403 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016404 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016405 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16406 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016407 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016408 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016409 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016410 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016411 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016412 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16413 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016414 {}
16415};
16416
16417static struct alc_config_preset alc662_presets[] = {
16418 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016419 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016420 .init_verbs = { alc662_init_verbs },
16421 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16422 .dac_nids = alc662_dac_nids,
16423 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016424 .dig_in_nid = ALC662_DIGIN_NID,
16425 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16426 .channel_mode = alc662_3ST_2ch_modes,
16427 .input_mux = &alc662_capture_source,
16428 },
16429 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016430 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016431 .init_verbs = { alc662_init_verbs },
16432 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16433 .dac_nids = alc662_dac_nids,
16434 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016435 .dig_in_nid = ALC662_DIGIN_NID,
16436 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16437 .channel_mode = alc662_3ST_6ch_modes,
16438 .need_dac_fix = 1,
16439 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016440 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016441 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016442 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016443 .init_verbs = { alc662_init_verbs },
16444 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16445 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016446 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16447 .channel_mode = alc662_3ST_6ch_modes,
16448 .need_dac_fix = 1,
16449 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016450 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016451 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016452 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016453 .init_verbs = { alc662_init_verbs },
16454 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16455 .dac_nids = alc662_dac_nids,
16456 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016457 .dig_in_nid = ALC662_DIGIN_NID,
16458 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16459 .channel_mode = alc662_5stack_modes,
16460 .input_mux = &alc662_capture_source,
16461 },
16462 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016463 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016464 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16465 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16466 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016467 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16468 .channel_mode = alc662_3ST_2ch_modes,
16469 .input_mux = &alc662_lenovo_101e_capture_source,
16470 .unsol_event = alc662_lenovo_101e_unsol_event,
16471 .init_hook = alc662_lenovo_101e_all_automute,
16472 },
Kailang Yang291702f2007-10-16 14:28:03 +020016473 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016474 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016475 .init_verbs = { alc662_init_verbs,
16476 alc662_eeepc_sue_init_verbs },
16477 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16478 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016479 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16480 .channel_mode = alc662_3ST_2ch_modes,
16481 .input_mux = &alc662_eeepc_capture_source,
16482 .unsol_event = alc662_eeepc_unsol_event,
16483 .init_hook = alc662_eeepc_inithook,
16484 },
Kailang Yang8c427222008-01-10 13:03:59 +010016485 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016486 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016487 alc662_chmode_mixer },
16488 .init_verbs = { alc662_init_verbs,
16489 alc662_eeepc_ep20_sue_init_verbs },
16490 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16491 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016492 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16493 .channel_mode = alc662_3ST_6ch_modes,
16494 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016495 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016496 .init_hook = alc662_eeepc_ep20_inithook,
16497 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016498 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016499 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016500 .init_verbs = { alc662_init_verbs,
16501 alc662_ecs_init_verbs },
16502 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16503 .dac_nids = alc662_dac_nids,
16504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16505 .channel_mode = alc662_3ST_2ch_modes,
16506 .input_mux = &alc662_eeepc_capture_source,
16507 .unsol_event = alc662_eeepc_unsol_event,
16508 .init_hook = alc662_eeepc_inithook,
16509 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016510 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016511 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016512 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16513 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16514 .dac_nids = alc662_dac_nids,
16515 .dig_out_nid = ALC662_DIGOUT_NID,
16516 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16517 .channel_mode = alc662_3ST_2ch_modes,
16518 .input_mux = &alc663_m51va_capture_source,
16519 .unsol_event = alc663_m51va_unsol_event,
16520 .init_hook = alc663_m51va_inithook,
16521 },
16522 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016523 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016524 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16525 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16526 .dac_nids = alc662_dac_nids,
16527 .dig_out_nid = ALC662_DIGOUT_NID,
16528 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16529 .channel_mode = alc662_3ST_2ch_modes,
16530 .input_mux = &alc662_eeepc_capture_source,
16531 .unsol_event = alc663_g71v_unsol_event,
16532 .init_hook = alc663_g71v_inithook,
16533 },
16534 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016535 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016536 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16537 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16538 .dac_nids = alc662_dac_nids,
16539 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16540 .channel_mode = alc662_3ST_2ch_modes,
16541 .input_mux = &alc663_m51va_capture_source,
16542 .unsol_event = alc663_m51va_unsol_event,
16543 .init_hook = alc663_m51va_inithook,
16544 },
16545 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016546 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016547 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16548 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16549 .dac_nids = alc662_dac_nids,
16550 .dig_out_nid = ALC662_DIGOUT_NID,
16551 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16552 .channel_mode = alc662_3ST_6ch_modes,
16553 .input_mux = &alc663_capture_source,
16554 .unsol_event = alc663_g50v_unsol_event,
16555 .init_hook = alc663_g50v_inithook,
16556 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016557 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016558 .mixers = { alc663_m51va_mixer },
16559 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016560 .init_verbs = { alc662_init_verbs,
16561 alc663_21jd_amic_init_verbs },
16562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16563 .hp_nid = 0x03,
16564 .dac_nids = alc662_dac_nids,
16565 .dig_out_nid = ALC662_DIGOUT_NID,
16566 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16567 .channel_mode = alc662_3ST_2ch_modes,
16568 .input_mux = &alc662_eeepc_capture_source,
16569 .unsol_event = alc663_mode1_unsol_event,
16570 .init_hook = alc663_mode1_inithook,
16571 },
16572 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016573 .mixers = { alc662_1bjd_mixer },
16574 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016575 .init_verbs = { alc662_init_verbs,
16576 alc662_1bjd_amic_init_verbs },
16577 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16578 .dac_nids = alc662_dac_nids,
16579 .dig_out_nid = ALC662_DIGOUT_NID,
16580 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16581 .channel_mode = alc662_3ST_2ch_modes,
16582 .input_mux = &alc662_eeepc_capture_source,
16583 .unsol_event = alc662_mode2_unsol_event,
16584 .init_hook = alc662_mode2_inithook,
16585 },
16586 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016587 .mixers = { alc663_two_hp_m1_mixer },
16588 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016589 .init_verbs = { alc662_init_verbs,
16590 alc663_two_hp_amic_m1_init_verbs },
16591 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16592 .hp_nid = 0x03,
16593 .dac_nids = alc662_dac_nids,
16594 .dig_out_nid = ALC662_DIGOUT_NID,
16595 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16596 .channel_mode = alc662_3ST_2ch_modes,
16597 .input_mux = &alc662_eeepc_capture_source,
16598 .unsol_event = alc663_mode3_unsol_event,
16599 .init_hook = alc663_mode3_inithook,
16600 },
16601 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016602 .mixers = { alc663_asus_21jd_clfe_mixer },
16603 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016604 .init_verbs = { alc662_init_verbs,
16605 alc663_21jd_amic_init_verbs},
16606 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16607 .hp_nid = 0x03,
16608 .dac_nids = alc662_dac_nids,
16609 .dig_out_nid = ALC662_DIGOUT_NID,
16610 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16611 .channel_mode = alc662_3ST_2ch_modes,
16612 .input_mux = &alc662_eeepc_capture_source,
16613 .unsol_event = alc663_mode4_unsol_event,
16614 .init_hook = alc663_mode4_inithook,
16615 },
16616 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016617 .mixers = { alc663_asus_15jd_clfe_mixer },
16618 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016619 .init_verbs = { alc662_init_verbs,
16620 alc663_15jd_amic_init_verbs },
16621 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16622 .hp_nid = 0x03,
16623 .dac_nids = alc662_dac_nids,
16624 .dig_out_nid = ALC662_DIGOUT_NID,
16625 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16626 .channel_mode = alc662_3ST_2ch_modes,
16627 .input_mux = &alc662_eeepc_capture_source,
16628 .unsol_event = alc663_mode5_unsol_event,
16629 .init_hook = alc663_mode5_inithook,
16630 },
16631 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016632 .mixers = { alc663_two_hp_m2_mixer },
16633 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016634 .init_verbs = { alc662_init_verbs,
16635 alc663_two_hp_amic_m2_init_verbs },
16636 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16637 .hp_nid = 0x03,
16638 .dac_nids = alc662_dac_nids,
16639 .dig_out_nid = ALC662_DIGOUT_NID,
16640 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16641 .channel_mode = alc662_3ST_2ch_modes,
16642 .input_mux = &alc662_eeepc_capture_source,
16643 .unsol_event = alc663_mode6_unsol_event,
16644 .init_hook = alc663_mode6_inithook,
16645 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016646 [ALC272_DELL] = {
16647 .mixers = { alc663_m51va_mixer },
16648 .cap_mixer = alc272_auto_capture_mixer,
16649 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16650 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16651 .dac_nids = alc662_dac_nids,
16652 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16653 .adc_nids = alc272_adc_nids,
16654 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16655 .capsrc_nids = alc272_capsrc_nids,
16656 .channel_mode = alc662_3ST_2ch_modes,
16657 .input_mux = &alc663_m51va_capture_source,
16658 .unsol_event = alc663_m51va_unsol_event,
16659 .init_hook = alc663_m51va_inithook,
16660 },
16661 [ALC272_DELL_ZM1] = {
16662 .mixers = { alc663_m51va_mixer },
16663 .cap_mixer = alc662_auto_capture_mixer,
16664 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16665 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16666 .dac_nids = alc662_dac_nids,
16667 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16668 .adc_nids = alc662_adc_nids,
16669 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16670 .capsrc_nids = alc662_capsrc_nids,
16671 .channel_mode = alc662_3ST_2ch_modes,
16672 .input_mux = &alc663_m51va_capture_source,
16673 .unsol_event = alc663_m51va_unsol_event,
16674 .init_hook = alc663_m51va_inithook,
16675 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016676 [ALC272_SAMSUNG_NC10] = {
16677 .mixers = { alc272_nc10_mixer },
16678 .init_verbs = { alc662_init_verbs,
16679 alc663_21jd_amic_init_verbs },
16680 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16681 .dac_nids = alc272_dac_nids,
16682 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16683 .channel_mode = alc662_3ST_2ch_modes,
16684 .input_mux = &alc272_nc10_capture_source,
16685 .unsol_event = alc663_mode4_unsol_event,
16686 .init_hook = alc663_mode4_inithook,
16687 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016688};
16689
16690
16691/*
16692 * BIOS auto configuration
16693 */
16694
16695/* add playback controls from the parsed DAC table */
16696static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16697 const struct auto_pin_cfg *cfg)
16698{
16699 char name[32];
16700 static const char *chname[4] = {
16701 "Front", "Surround", NULL /*CLFE*/, "Side"
16702 };
16703 hda_nid_t nid;
16704 int i, err;
16705
16706 for (i = 0; i < cfg->line_outs; i++) {
16707 if (!spec->multiout.dac_nids[i])
16708 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016709 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016710 if (i == 2) {
16711 /* Center/LFE */
16712 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16713 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016714 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16715 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716 if (err < 0)
16717 return err;
16718 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16719 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016720 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16721 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722 if (err < 0)
16723 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016724 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016725 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016726 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016727 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728 if (err < 0)
16729 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016730 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016731 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016732 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016733 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016734 if (err < 0)
16735 return err;
16736 } else {
16737 sprintf(name, "%s Playback Volume", chname[i]);
16738 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016739 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16740 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016741 if (err < 0)
16742 return err;
16743 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016744 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16745 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16746 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016747 if (err < 0)
16748 return err;
16749 }
16750 }
16751 return 0;
16752}
16753
16754/* add playback controls for speaker and HP outputs */
16755static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16756 const char *pfx)
16757{
16758 hda_nid_t nid;
16759 int err;
16760 char name[32];
16761
16762 if (!pin)
16763 return 0;
16764
Takashi Iwai24fb9172008-09-02 14:48:20 +020016765 if (pin == 0x17) {
16766 /* ALC663 has a mono output pin on 0x17 */
16767 sprintf(name, "%s Playback Switch", pfx);
16768 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16769 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16770 return err;
16771 }
16772
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016773 if (alc880_is_fixed_pin(pin)) {
16774 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016775 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016776 /* specify the DAC as the extra output */
16777 if (!spec->multiout.hp_nid)
16778 spec->multiout.hp_nid = nid;
16779 else
16780 spec->multiout.extra_out_nid[0] = nid;
16781 /* control HP volume/switch on the output mixer amp */
16782 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16783 sprintf(name, "%s Playback Volume", pfx);
16784 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16785 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16786 if (err < 0)
16787 return err;
16788 sprintf(name, "%s Playback Switch", pfx);
16789 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16790 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16791 if (err < 0)
16792 return err;
16793 } else if (alc880_is_multi_pin(pin)) {
16794 /* set manual connection */
16795 /* we have only a switch on HP-out PIN */
16796 sprintf(name, "%s Playback Switch", pfx);
16797 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16798 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16799 if (err < 0)
16800 return err;
16801 }
16802 return 0;
16803}
16804
Takashi Iwai2d864c42009-03-20 12:52:47 +010016805/* return the index of the src widget from the connection list of the nid.
16806 * return -1 if not found
16807 */
16808static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16809 hda_nid_t src)
16810{
16811 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16812 int i, conns;
16813
16814 conns = snd_hda_get_connections(codec, nid, conn_list,
16815 ARRAY_SIZE(conn_list));
16816 if (conns < 0)
16817 return -1;
16818 for (i = 0; i < conns; i++)
16819 if (conn_list[i] == src)
16820 return i;
16821 return -1;
16822}
16823
16824static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16825{
Takashi Iwai1327a322009-03-23 13:07:47 +010016826 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016827 return (pincap & AC_PINCAP_IN) != 0;
16828}
16829
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016830/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016831static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016832 const struct auto_pin_cfg *cfg)
16833{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016834 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016835 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016836 int i, err, idx;
16837
16838 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016839 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16840 idx = alc662_input_pin_idx(codec, 0x0b,
16841 cfg->input_pins[i]);
16842 if (idx >= 0) {
16843 err = new_analog_input(spec, cfg->input_pins[i],
16844 auto_pin_cfg_labels[i],
16845 idx, 0x0b);
16846 if (err < 0)
16847 return err;
16848 }
16849 idx = alc662_input_pin_idx(codec, 0x22,
16850 cfg->input_pins[i]);
16851 if (idx >= 0) {
16852 imux->items[imux->num_items].label =
16853 auto_pin_cfg_labels[i];
16854 imux->items[imux->num_items].index = idx;
16855 imux->num_items++;
16856 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016857 }
16858 }
16859 return 0;
16860}
16861
16862static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16863 hda_nid_t nid, int pin_type,
16864 int dac_idx)
16865{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016866 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016867 /* need the manual connection? */
16868 if (alc880_is_multi_pin(nid)) {
16869 struct alc_spec *spec = codec->spec;
16870 int idx = alc880_multi_pin_idx(nid);
16871 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16872 AC_VERB_SET_CONNECT_SEL,
16873 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16874 }
16875}
16876
16877static void alc662_auto_init_multi_out(struct hda_codec *codec)
16878{
16879 struct alc_spec *spec = codec->spec;
16880 int i;
16881
16882 for (i = 0; i <= HDA_SIDE; i++) {
16883 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016884 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016885 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016886 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016887 i);
16888 }
16889}
16890
16891static void alc662_auto_init_hp_out(struct hda_codec *codec)
16892{
16893 struct alc_spec *spec = codec->spec;
16894 hda_nid_t pin;
16895
16896 pin = spec->autocfg.hp_pins[0];
16897 if (pin) /* connect to front */
16898 /* use dac 0 */
16899 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016900 pin = spec->autocfg.speaker_pins[0];
16901 if (pin)
16902 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016903}
16904
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016905#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16906
16907static void alc662_auto_init_analog_input(struct hda_codec *codec)
16908{
16909 struct alc_spec *spec = codec->spec;
16910 int i;
16911
16912 for (i = 0; i < AUTO_PIN_LAST; i++) {
16913 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016914 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016915 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016916 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016917 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016918 snd_hda_codec_write(codec, nid, 0,
16919 AC_VERB_SET_AMP_GAIN_MUTE,
16920 AMP_OUT_MUTE);
16921 }
16922 }
16923}
16924
Takashi Iwaif511b012008-08-15 16:46:42 +020016925#define alc662_auto_init_input_src alc882_auto_init_input_src
16926
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016927static int alc662_parse_auto_config(struct hda_codec *codec)
16928{
16929 struct alc_spec *spec = codec->spec;
16930 int err;
16931 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16932
16933 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16934 alc662_ignore);
16935 if (err < 0)
16936 return err;
16937 if (!spec->autocfg.line_outs)
16938 return 0; /* can't find valid BIOS pin config */
16939
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016940 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16941 if (err < 0)
16942 return err;
16943 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16944 if (err < 0)
16945 return err;
16946 err = alc662_auto_create_extra_out(spec,
16947 spec->autocfg.speaker_pins[0],
16948 "Speaker");
16949 if (err < 0)
16950 return err;
16951 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16952 "Headphone");
16953 if (err < 0)
16954 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016955 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016956 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016957 return err;
16958
16959 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16960
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016961 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016962 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16963
Takashi Iwai603c4012008-07-30 15:01:44 +020016964 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016965 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016966
16967 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016968 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016969
Takashi Iwaid88897e2008-10-31 15:01:37 +010016970 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016971 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016972 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016973
16974 err = alc_auto_add_mic_boost(codec);
16975 if (err < 0)
16976 return err;
16977
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016978 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
16979
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016980 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016981}
16982
16983/* additional initialization for auto-configuration model */
16984static void alc662_auto_init(struct hda_codec *codec)
16985{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016986 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987 alc662_auto_init_multi_out(codec);
16988 alc662_auto_init_hp_out(codec);
16989 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016990 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016991 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016992 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016993}
16994
16995static int patch_alc662(struct hda_codec *codec)
16996{
16997 struct alc_spec *spec;
16998 int err, board_config;
16999
17000 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17001 if (!spec)
17002 return -ENOMEM;
17003
17004 codec->spec = spec;
17005
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017006 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17007
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017008 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17009 alc662_models,
17010 alc662_cfg_tbl);
17011 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017012 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17013 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017014 board_config = ALC662_AUTO;
17015 }
17016
17017 if (board_config == ALC662_AUTO) {
17018 /* automatic parse from the BIOS config */
17019 err = alc662_parse_auto_config(codec);
17020 if (err < 0) {
17021 alc_free(codec);
17022 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017023 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017024 printk(KERN_INFO
17025 "hda_codec: Cannot set up configuration "
17026 "from BIOS. Using base mode...\n");
17027 board_config = ALC662_3ST_2ch_DIG;
17028 }
17029 }
17030
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017031 err = snd_hda_attach_beep_device(codec, 0x1);
17032 if (err < 0) {
17033 alc_free(codec);
17034 return err;
17035 }
17036
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017037 if (board_config != ALC662_AUTO)
17038 setup_preset(spec, &alc662_presets[board_config]);
17039
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017040 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17041 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17042
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017043 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17044 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17045
Takashi Iwaie1406342008-02-11 18:32:32 +010017046 spec->adc_nids = alc662_adc_nids;
17047 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17048 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017049
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017050 if (!spec->cap_mixer)
17051 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017052 if (codec->vendor_id == 0x10ec0662)
17053 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17054 else
17055 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017056
Takashi Iwai2134ea42008-01-10 16:53:55 +010017057 spec->vmaster_nid = 0x02;
17058
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017059 codec->patch_ops = alc_patch_ops;
17060 if (board_config == ALC662_AUTO)
17061 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017062#ifdef CONFIG_SND_HDA_POWER_SAVE
17063 if (!spec->loopback.amplist)
17064 spec->loopback.amplist = alc662_loopbacks;
17065#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017066 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067
17068 return 0;
17069}
17070
17071/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017072 * patch entries
17073 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017074static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017075 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017076 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017077 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017078 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017079 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017080 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017081 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017082 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017083 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17084 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17085 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017086 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017087 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17089 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017090 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017091 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017092 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017093 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017094 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017095 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017096 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017097 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017098 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017099 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017100 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017101 .patch = patch_alc882 },
17102 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17103 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017104 {} /* terminator */
17105};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017106
17107MODULE_ALIAS("snd-hda-codec-id:10ec*");
17108
17109MODULE_LICENSE("GPL");
17110MODULE_DESCRIPTION("Realtek HD-audio codec");
17111
17112static struct hda_codec_preset_list realtek_list = {
17113 .preset = snd_hda_preset_realtek,
17114 .owner = THIS_MODULE,
17115};
17116
17117static int __init patch_realtek_init(void)
17118{
17119 return snd_hda_add_codec_preset(&realtek_list);
17120}
17121
17122static void __exit patch_realtek_exit(void)
17123{
17124 snd_hda_delete_codec_preset(&realtek_list);
17125}
17126
17127module_init(patch_realtek_init)
17128module_exit(patch_realtek_exit)