blob: 8c5d342bd4eb331ce6236228a13f2ee98be69d79 [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,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200252/* extra amp-initialization sequence types */
253enum {
254 ALC_INIT_NONE,
255 ALC_INIT_DEFAULT,
256 ALC_INIT_GPIO1,
257 ALC_INIT_GPIO2,
258 ALC_INIT_GPIO3,
259};
260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261struct alc_spec {
262 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100263 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100265 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100266 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Kailang Yangdf694da2005-12-05 19:42:22 +0100268 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200269 * don't forget NULL
270 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200271 */
272 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200274 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 struct hda_pcm_stream *stream_analog_playback;
276 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100277 struct hda_pcm_stream *stream_analog_alt_playback;
278 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200280 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 struct hda_pcm_stream *stream_digital_playback;
282 struct hda_pcm_stream *stream_digital_capture;
283
284 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200285 struct hda_multi_out multiout; /* playback set-up
286 * max_channels, dacs must be set
287 * dig_out_nid and hp_nid are optional
288 */
Takashi Iwai63300792008-01-24 15:31:36 +0100289 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100290 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100291 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293 /* capture */
294 unsigned int num_adc_nids;
295 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100296 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200297 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
299 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200300 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 const struct hda_input_mux *input_mux;
302 unsigned int cur_mux[3];
303
304 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100305 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200307 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200308 int const_channel_count;
309 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
311 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100312 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200313
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200314 /* dynamic controls, init_verbs and input_mux */
315 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200316 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200317 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200318 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200319 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
320 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100321
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100322 /* hooks */
323 void (*init_hook)(struct hda_codec *codec);
324 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
325
Takashi Iwai834be882006-03-01 14:16:17 +0100326 /* for pin sensing */
327 unsigned int sense_updated: 1;
328 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100329 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200330
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100331 /* other flags */
332 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200333 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100334
Takashi Iwai2134ea42008-01-10 16:53:55 +0100335 /* for virtual master */
336 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200337#ifdef CONFIG_SND_HDA_POWER_SAVE
338 struct hda_loopback_check loopback;
339#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200340
341 /* for PLL fix */
342 hda_nid_t pll_nid;
343 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100344};
345
346/*
347 * configuration template - to be copied to the spec instance
348 */
349struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200350 struct snd_kcontrol_new *mixers[5]; /* should be identical size
351 * with spec
352 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100353 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100354 const struct hda_verb *init_verbs[5];
355 unsigned int num_dacs;
356 hda_nid_t *dac_nids;
357 hda_nid_t dig_out_nid; /* optional */
358 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800359 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100360 unsigned int num_adc_nids;
361 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100362 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363 hda_nid_t dig_in_nid;
364 unsigned int num_channel_mode;
365 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200366 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200367 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200368 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100369 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100370 void (*unsol_event)(struct hda_codec *, unsigned int);
371 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200372#ifdef CONFIG_SND_HDA_POWER_SAVE
373 struct hda_amp_list *loopbacks;
374#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375};
376
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378/*
379 * input MUX handling
380 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200381static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200386 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
387 if (mux_idx >= spec->num_mux_defs)
388 mux_idx = 0;
389 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200392static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
398
399 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
400 return 0;
401}
402
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100408 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100410 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100411 hda_nid_t nid = spec->capsrc_nids ?
412 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200413 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Takashi Iwaicd896c32008-11-18 12:36:33 +0100415 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
416 imux = &spec->input_mux[mux_idx];
417
Takashi Iwaia22d5432009-07-27 12:54:26 +0200418 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200419 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100420 /* Matrix-mixer style (e.g. ALC882) */
421 unsigned int *cur_val = &spec->cur_mux[adc_idx];
422 unsigned int i, idx;
423
424 idx = ucontrol->value.enumerated.item[0];
425 if (idx >= imux->num_items)
426 idx = imux->num_items - 1;
427 if (*cur_val == idx)
428 return 0;
429 for (i = 0; i < imux->num_items; i++) {
430 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
431 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
432 imux->items[i].index,
433 HDA_AMP_MUTE, v);
434 }
435 *cur_val = idx;
436 return 1;
437 } else {
438 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100439 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100440 &spec->cur_mux[adc_idx]);
441 }
442}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444/*
445 * channel mode setting
446 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449{
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100452 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
453 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200456static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
457 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458{
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100461 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200462 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200463 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468{
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200471 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
472 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200473 &spec->ext_channel_count);
474 if (err >= 0 && !spec->const_channel_count) {
475 spec->multiout.max_channels = spec->ext_channel_count;
476 if (spec->need_dac_fix)
477 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
478 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200479 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480}
481
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200484 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 * being part of a format specifier. Maximum allowed length of a value is
486 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100487 *
488 * Note: some retasking pin complexes seem to ignore requests for input
489 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
490 * are requested. Therefore order this list so that this behaviour will not
491 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200492 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
493 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200494 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100496 "Mic 50pc bias", "Mic 80pc bias",
497 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498};
499static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100500 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501};
502/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200503 * in the pin being assumed to be exclusively an input or an output pin. In
504 * addition, "input" pins may or may not process the mic bias option
505 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
506 * accept requests for bias as of chip versions up to March 2006) and/or
507 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200509#define ALC_PIN_DIR_IN 0x00
510#define ALC_PIN_DIR_OUT 0x01
511#define ALC_PIN_DIR_INOUT 0x02
512#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
513#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514
Kailang Yangea1fb292008-08-26 12:58:38 +0200515/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516 * For each direction the minimum and maximum values are given.
517 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200518static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 { 0, 2 }, /* ALC_PIN_DIR_IN */
520 { 3, 4 }, /* ALC_PIN_DIR_OUT */
521 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200522 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
523 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524};
525#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
526#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
527#define alc_pin_mode_n_items(_dir) \
528 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
529
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 unsigned int item_num = uinfo->value.enumerated.item;
534 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
535
536 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
539
540 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
541 item_num = alc_pin_mode_min(dir);
542 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543 return 0;
544}
545
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200546static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200553 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200554 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
555 AC_VERB_GET_PIN_WIDGET_CONTROL,
556 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200557
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 /* Find enumerated value for current pinctl setting */
559 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 return 0;
564}
565
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568{
569 signed int change;
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 hda_nid_t nid = kcontrol->private_value & 0xffff;
572 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
573 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
575 AC_VERB_GET_PIN_WIDGET_CONTROL,
576 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200578 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 val = alc_pin_mode_min(dir);
580
581 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100582 if (change) {
583 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200584 snd_hda_codec_write_cache(codec, nid, 0,
585 AC_VERB_SET_PIN_WIDGET_CONTROL,
586 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587
Kailang Yangea1fb292008-08-26 12:58:38 +0200588 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100589 * for the requested pin mode. Enum values of 2 or less are
590 * input modes.
591 *
592 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200593 * reduces noise slightly (particularly on input) so we'll
594 * do it. However, having both input and output buffers
595 * enabled simultaneously doesn't seem to be problematic if
596 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100597 */
598 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200599 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
600 HDA_AMP_MUTE, HDA_AMP_MUTE);
601 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
602 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200604 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
605 HDA_AMP_MUTE, HDA_AMP_MUTE);
606 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
607 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608 }
609 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200610 return change;
611}
612
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100613#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200614 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100615 .info = alc_pin_mode_info, \
616 .get = alc_pin_mode_get, \
617 .put = alc_pin_mode_put, \
618 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100619
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100620/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
621 * together using a mask with more than one bit set. This control is
622 * currently used only by the ALC260 test model. At this stage they are not
623 * needed for any "production" models.
624 */
625#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200626#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200627
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200628static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100630{
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 hda_nid_t nid = kcontrol->private_value & 0xffff;
633 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
634 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635 unsigned int val = snd_hda_codec_read(codec, nid, 0,
636 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100637
638 *valp = (val & mask) != 0;
639 return 0;
640}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100643{
644 signed int change;
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_GPIO_DATA,
651 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100652
653 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200654 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
655 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100656 gpio_data &= ~mask;
657 else
658 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200659 snd_hda_codec_write_cache(codec, nid, 0,
660 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100661
662 return change;
663}
664#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
665 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
666 .info = alc_gpio_data_info, \
667 .get = alc_gpio_data_get, \
668 .put = alc_gpio_data_put, \
669 .private_value = nid | (mask<<16) }
670#endif /* CONFIG_SND_DEBUG */
671
Jonathan Woithe92621f12006-02-28 11:47:47 +0100672/* A switch control to allow the enabling of the digital IO pins on the
673 * ALC260. This is incredibly simplistic; the intention of this control is
674 * to provide something in the test model allowing digital outputs to be
675 * identified if present. If models are found which can utilise these
676 * outputs a more complete mixer control can be devised for those models if
677 * necessary.
678 */
679#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200680#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200681
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200682static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
683 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100684{
685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
686 hda_nid_t nid = kcontrol->private_value & 0xffff;
687 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
688 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200689 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100690 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100691
692 *valp = (val & mask) != 0;
693 return 0;
694}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200695static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100697{
698 signed int change;
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100704 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100706
707 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100709 if (val==0)
710 ctrl_data &= ~mask;
711 else
712 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200713 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
714 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715
716 return change;
717}
718#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
719 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
720 .info = alc_spdif_ctrl_info, \
721 .get = alc_spdif_ctrl_get, \
722 .put = alc_spdif_ctrl_put, \
723 .private_value = nid | (mask<<16) }
724#endif /* CONFIG_SND_DEBUG */
725
Jonathan Woithef8225f62008-01-08 12:16:54 +0100726/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
727 * Again, this is only used in the ALC26x test models to help identify when
728 * the EAPD line must be asserted for features to work.
729 */
730#ifdef CONFIG_SND_DEBUG
731#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
732
733static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
734 struct snd_ctl_elem_value *ucontrol)
735{
736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
737 hda_nid_t nid = kcontrol->private_value & 0xffff;
738 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
739 long *valp = ucontrol->value.integer.value;
740 unsigned int val = snd_hda_codec_read(codec, nid, 0,
741 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
742
743 *valp = (val & mask) != 0;
744 return 0;
745}
746
747static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
749{
750 int change;
751 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
752 hda_nid_t nid = kcontrol->private_value & 0xffff;
753 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
754 long val = *ucontrol->value.integer.value;
755 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
756 AC_VERB_GET_EAPD_BTLENABLE,
757 0x00);
758
759 /* Set/unset the masked control bit(s) as needed */
760 change = (!val ? 0 : mask) != (ctrl_data & mask);
761 if (!val)
762 ctrl_data &= ~mask;
763 else
764 ctrl_data |= mask;
765 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
766 ctrl_data);
767
768 return change;
769}
770
771#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
772 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
773 .info = alc_eapd_ctrl_info, \
774 .get = alc_eapd_ctrl_get, \
775 .put = alc_eapd_ctrl_put, \
776 .private_value = nid | (mask<<16) }
777#endif /* CONFIG_SND_DEBUG */
778
Kailang Yangdf694da2005-12-05 19:42:22 +0100779/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100780 * set up the input pin config (depending on the given auto-pin type)
781 */
782static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
783 int auto_pin_type)
784{
785 unsigned int val = PIN_IN;
786
787 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
788 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100789 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100790 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
791 if (pincap & AC_PINCAP_VREF_80)
792 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200793 else if (pincap & AC_PINCAP_VREF_50)
794 val = PIN_VREF50;
795 else if (pincap & AC_PINCAP_VREF_100)
796 val = PIN_VREF100;
797 else if (pincap & AC_PINCAP_VREF_GRD)
798 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100799 }
800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
801}
802
803/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100804 */
805static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
806{
807 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
808 return;
809 spec->mixers[spec->num_mixers++] = mix;
810}
811
812static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
813{
814 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
815 return;
816 spec->init_verbs[spec->num_init_verbs++] = verb;
817}
818
Takashi Iwaidaead532008-11-28 12:55:36 +0100819#ifdef CONFIG_PROC_FS
820/*
821 * hook for proc
822 */
823static void print_realtek_coef(struct snd_info_buffer *buffer,
824 struct hda_codec *codec, hda_nid_t nid)
825{
826 int coeff;
827
828 if (nid != 0x20)
829 return;
830 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
831 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
832 coeff = snd_hda_codec_read(codec, nid, 0,
833 AC_VERB_GET_COEF_INDEX, 0);
834 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
835}
836#else
837#define print_realtek_coef NULL
838#endif
839
Takashi Iwaid88897e2008-10-31 15:01:37 +0100840/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100841 * set up from the preset table
842 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200843static void setup_preset(struct alc_spec *spec,
844 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100845{
846 int i;
847
848 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100849 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100850 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200851 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
852 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100853 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200854
Kailang Yangdf694da2005-12-05 19:42:22 +0100855 spec->channel_mode = preset->channel_mode;
856 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200857 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200858 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859
Hector Martin3b315d72009-06-02 10:54:19 +0200860 if (preset->const_channel_count)
861 spec->multiout.max_channels = preset->const_channel_count;
862 else
863 spec->multiout.max_channels = spec->channel_mode[0].channels;
864 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100865
866 spec->multiout.num_dacs = preset->num_dacs;
867 spec->multiout.dac_nids = preset->dac_nids;
868 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800869 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100870 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200871
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200872 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200873 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200874 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100875 spec->input_mux = preset->input_mux;
876
877 spec->num_adc_nids = preset->num_adc_nids;
878 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100879 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100880 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100881
882 spec->unsol_event = preset->unsol_event;
883 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200884#ifdef CONFIG_SND_HDA_POWER_SAVE
885 spec->loopback.amplist = preset->loopbacks;
886#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100887}
888
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200889/* Enable GPIO mask and set output */
890static struct hda_verb alc_gpio1_init_verbs[] = {
891 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
892 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
893 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
894 { }
895};
896
897static struct hda_verb alc_gpio2_init_verbs[] = {
898 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
900 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
901 { }
902};
903
Kailang Yangbdd148a2007-05-08 15:19:08 +0200904static struct hda_verb alc_gpio3_init_verbs[] = {
905 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
906 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
907 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
908 { }
909};
910
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200911/*
912 * Fix hardware PLL issue
913 * On some codecs, the analog PLL gating control must be off while
914 * the default value is 1.
915 */
916static void alc_fix_pll(struct hda_codec *codec)
917{
918 struct alc_spec *spec = codec->spec;
919 unsigned int val;
920
921 if (!spec->pll_nid)
922 return;
923 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
924 spec->pll_coef_idx);
925 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
926 AC_VERB_GET_PROC_COEF, 0);
927 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
928 spec->pll_coef_idx);
929 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
930 val & ~(1 << spec->pll_coef_bit));
931}
932
933static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
934 unsigned int coef_idx, unsigned int coef_bit)
935{
936 struct alc_spec *spec = codec->spec;
937 spec->pll_nid = nid;
938 spec->pll_coef_idx = coef_idx;
939 spec->pll_coef_bit = coef_bit;
940 alc_fix_pll(codec);
941}
942
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200943static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200944{
945 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200946 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200947 unsigned int nid = spec->autocfg.hp_pins[0];
948 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200949
Takashi Iwai261c2402009-06-25 08:13:40 +0200950 pincap = snd_hda_query_pin_caps(codec, nid);
951 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
952 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200953 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200954 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200955 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
956 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
957 nid = spec->autocfg.speaker_pins[i];
958 if (!nid)
959 break;
960 snd_hda_codec_write(codec, nid, 0,
961 AC_VERB_SET_PIN_WIDGET_CONTROL,
962 spec->jack_present ? 0 : PIN_OUT);
963 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200964}
965
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400966#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200967static void alc_mic_automute(struct hda_codec *codec)
968{
969 struct alc_spec *spec = codec->spec;
970 unsigned int present;
971 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
972 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
973 unsigned int mix_nid = spec->capsrc_nids[0];
974 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
975
976 capsrc_idx_mic = mic_nid - 0x18;
977 capsrc_idx_fmic = fmic_nid - 0x18;
978 present = snd_hda_codec_read(codec, mic_nid, 0,
979 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
980 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
981 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
982 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
983 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
984 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
985 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
986}
Takashi Iwai4605b712008-10-31 14:18:24 +0100987#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100988#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100989#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200990
Kailang Yangc9b58002007-10-16 14:30:01 +0200991/* unsolicited event for HP jack sensing */
992static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
993{
994 if (codec->vendor_id == 0x10ec0880)
995 res >>= 28;
996 else
997 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200998 switch (res) {
999 case ALC880_HP_EVENT:
1000 alc_automute_pin(codec);
1001 break;
1002 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001003 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001004 break;
1005 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001006}
1007
1008static void alc_inithook(struct hda_codec *codec)
1009{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001010 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001011 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001012}
1013
Kailang Yangf9423e72008-05-27 12:32:25 +02001014/* additional initialization for ALC888 variants */
1015static void alc888_coef_init(struct hda_codec *codec)
1016{
1017 unsigned int tmp;
1018
1019 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1020 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1021 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001022 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001023 /* alc888S-VC */
1024 snd_hda_codec_read(codec, 0x20, 0,
1025 AC_VERB_SET_PROC_COEF, 0x830);
1026 else
1027 /* alc888-VB */
1028 snd_hda_codec_read(codec, 0x20, 0,
1029 AC_VERB_SET_PROC_COEF, 0x3030);
1030}
1031
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001032static void alc889_coef_init(struct hda_codec *codec)
1033{
1034 unsigned int tmp;
1035
1036 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1037 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1038 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1039 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1040}
1041
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001042static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001043{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001044 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001045
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001046 switch (type) {
1047 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001048 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1049 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001050 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001051 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1052 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001053 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1055 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001056 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001057 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001058 case 0x10ec0260:
1059 snd_hda_codec_write(codec, 0x0f, 0,
1060 AC_VERB_SET_EAPD_BTLENABLE, 2);
1061 snd_hda_codec_write(codec, 0x10, 0,
1062 AC_VERB_SET_EAPD_BTLENABLE, 2);
1063 break;
1064 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001065 case 0x10ec0267:
1066 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001067 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001068 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001069 case 0x10ec0660:
1070 case 0x10ec0662:
1071 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001072 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001073 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001074 snd_hda_codec_write(codec, 0x14, 0,
1075 AC_VERB_SET_EAPD_BTLENABLE, 2);
1076 snd_hda_codec_write(codec, 0x15, 0,
1077 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001078 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001079 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001080 switch (codec->vendor_id) {
1081 case 0x10ec0260:
1082 snd_hda_codec_write(codec, 0x1a, 0,
1083 AC_VERB_SET_COEF_INDEX, 7);
1084 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1085 AC_VERB_GET_PROC_COEF, 0);
1086 snd_hda_codec_write(codec, 0x1a, 0,
1087 AC_VERB_SET_COEF_INDEX, 7);
1088 snd_hda_codec_write(codec, 0x1a, 0,
1089 AC_VERB_SET_PROC_COEF,
1090 tmp | 0x2010);
1091 break;
1092 case 0x10ec0262:
1093 case 0x10ec0880:
1094 case 0x10ec0882:
1095 case 0x10ec0883:
1096 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001097 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001098 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001099 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001100 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001101 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001103 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 case 0x10ec0267:
1105 case 0x10ec0268:
1106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_COEF_INDEX, 7);
1108 tmp = snd_hda_codec_read(codec, 0x20, 0,
1109 AC_VERB_GET_PROC_COEF, 0);
1110 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001111 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 snd_hda_codec_write(codec, 0x20, 0,
1113 AC_VERB_SET_PROC_COEF,
1114 tmp | 0x3000);
1115 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117 break;
1118 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001119}
Kailang Yangea1fb292008-08-26 12:58:38 +02001120
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001121static void alc_init_auto_hp(struct hda_codec *codec)
1122{
1123 struct alc_spec *spec = codec->spec;
1124
1125 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001127
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001129 if (spec->autocfg.line_out_pins[0] &&
1130 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001132 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 else
1134 return;
1135 }
1136
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001137 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1138 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001139 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1140 AC_VERB_SET_UNSOLICITED_ENABLE,
1141 AC_USRSP_EN | ALC880_HP_EVENT);
1142 spec->unsol_event = alc_sku_unsol_event;
1143}
1144
1145/* check subsystem ID and set up device-specific initialization;
1146 * return 1 if initialized, 0 if invalid SSID
1147 */
1148/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1149 * 31 ~ 16 : Manufacture ID
1150 * 15 ~ 8 : SKU ID
1151 * 7 ~ 0 : Assembly ID
1152 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1153 */
1154static int alc_subsystem_id(struct hda_codec *codec,
1155 hda_nid_t porta, hda_nid_t porte,
1156 hda_nid_t portd)
1157{
1158 unsigned int ass, tmp, i;
1159 unsigned nid;
1160 struct alc_spec *spec = codec->spec;
1161
1162 ass = codec->subsystem_id & 0xffff;
1163 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1164 goto do_sku;
1165
1166 /* invalid SSID, check the special NID pin defcfg instead */
1167 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001168 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169 * 29~21 : reserve
1170 * 20 : PCBEEP input
1171 * 19~16 : Check sum (15:1)
1172 * 15~1 : Custom
1173 * 0 : override
1174 */
1175 nid = 0x1d;
1176 if (codec->vendor_id == 0x10ec0260)
1177 nid = 0x17;
1178 ass = snd_hda_codec_get_pincfg(codec, nid);
1179 snd_printd("realtek: No valid SSID, "
1180 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001181 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001182 if (!(ass & 1) && !(ass & 0x100000))
1183 return 0;
1184 if ((ass >> 30) != 1) /* no physical connection */
1185 return 0;
1186
1187 /* check sum */
1188 tmp = 0;
1189 for (i = 1; i < 16; i++) {
1190 if ((ass >> i) & 1)
1191 tmp++;
1192 }
1193 if (((ass >> 16) & 0xf) != tmp)
1194 return 0;
1195do_sku:
1196 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1197 ass & 0xffff, codec->vendor_id);
1198 /*
1199 * 0 : override
1200 * 1 : Swap Jack
1201 * 2 : 0 --> Desktop, 1 --> Laptop
1202 * 3~5 : External Amplifier control
1203 * 7~6 : Reserved
1204 */
1205 tmp = (ass & 0x38) >> 3; /* external Amp control */
1206 switch (tmp) {
1207 case 1:
1208 spec->init_amp = ALC_INIT_GPIO1;
1209 break;
1210 case 3:
1211 spec->init_amp = ALC_INIT_GPIO2;
1212 break;
1213 case 7:
1214 spec->init_amp = ALC_INIT_GPIO3;
1215 break;
1216 case 5:
1217 spec->init_amp = ALC_INIT_DEFAULT;
1218 break;
1219 }
1220
1221 /* is laptop or Desktop and enable the function "Mute internal speaker
1222 * when the external headphone out jack is plugged"
1223 */
1224 if (!(ass & 0x8000))
1225 return 1;
1226 /*
1227 * 10~8 : Jack location
1228 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1229 * 14~13: Resvered
1230 * 15 : 1 --> enable the function "Mute internal speaker
1231 * when the external headphone out jack is plugged"
1232 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001233 if (!spec->autocfg.hp_pins[0]) {
1234 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1235 if (tmp == 0)
1236 spec->autocfg.hp_pins[0] = porta;
1237 else if (tmp == 1)
1238 spec->autocfg.hp_pins[0] = porte;
1239 else if (tmp == 2)
1240 spec->autocfg.hp_pins[0] = portd;
1241 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001243 }
1244
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245 alc_init_auto_hp(codec);
1246 return 1;
1247}
Kailang Yangea1fb292008-08-26 12:58:38 +02001248
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001249static void alc_ssid_check(struct hda_codec *codec,
1250 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1251{
1252 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1253 struct alc_spec *spec = codec->spec;
1254 snd_printd("realtek: "
1255 "Enable default setup for auto mode as fallback\n");
1256 spec->init_amp = ALC_INIT_DEFAULT;
1257 alc_init_auto_hp(codec);
1258 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001259}
1260
Takashi Iwai41e41f12005-06-08 14:48:49 +02001261/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001262 * Fix-up pin default configurations
1263 */
1264
1265struct alc_pincfg {
1266 hda_nid_t nid;
1267 u32 val;
1268};
1269
1270static void alc_fix_pincfg(struct hda_codec *codec,
1271 const struct snd_pci_quirk *quirk,
1272 const struct alc_pincfg **pinfix)
1273{
1274 const struct alc_pincfg *cfg;
1275
1276 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1277 if (!quirk)
1278 return;
1279
1280 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001281 for (; cfg->nid; cfg++)
1282 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001283}
1284
1285/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001286 * ALC888
1287 */
1288
1289/*
1290 * 2ch mode
1291 */
1292static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1293/* Mic-in jack as mic in */
1294 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1295 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1296/* Line-in jack as Line in */
1297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1299/* Line-Out as Front */
1300 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1301 { } /* end */
1302};
1303
1304/*
1305 * 4ch mode
1306 */
1307static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1308/* Mic-in jack as mic in */
1309 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1310 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1311/* Line-in jack as Surround */
1312 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1313 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1314/* Line-Out as Front */
1315 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1316 { } /* end */
1317};
1318
1319/*
1320 * 6ch mode
1321 */
1322static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1323/* Mic-in jack as CLFE */
1324 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1325 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1326/* Line-in jack as Surround */
1327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1329/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1330 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1331 { } /* end */
1332};
1333
1334/*
1335 * 8ch mode
1336 */
1337static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1338/* Mic-in jack as CLFE */
1339 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1340 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1341/* Line-in jack as Surround */
1342 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1343 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1344/* Line-Out as Side */
1345 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1346 { } /* end */
1347};
1348
1349static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1350 { 2, alc888_4ST_ch2_intel_init },
1351 { 4, alc888_4ST_ch4_intel_init },
1352 { 6, alc888_4ST_ch6_intel_init },
1353 { 8, alc888_4ST_ch8_intel_init },
1354};
1355
1356/*
1357 * ALC888 Fujitsu Siemens Amillo xa3530
1358 */
1359
1360static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1361/* Front Mic: set to PIN_IN (empty by default) */
1362 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1363/* Connect Internal HP to Front */
1364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1366 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1367/* Connect Bass HP to Front */
1368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1371/* Connect Line-Out side jack (SPDIF) to Side */
1372 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1373 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1374 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1375/* Connect Mic jack to CLFE */
1376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1378 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1379/* Connect Line-in jack to Surround */
1380 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1383/* Connect HP out jack to Front */
1384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1386 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1387/* Enable unsolicited event for HP jack and Line-out jack */
1388 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1389 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1390 {}
1391};
1392
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001393static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001394{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001395 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001396 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001397 hda_nid_t nid;
1398 int i;
1399
1400 spec->jack_present = 0;
1401 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1402 nid = spec->autocfg.hp_pins[i];
1403 if (!nid)
1404 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001405 pincap = snd_hda_query_pin_caps(codec, nid);
1406 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1407 snd_hda_codec_read(codec, nid, 0,
1408 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001409 val = snd_hda_codec_read(codec, nid, 0,
1410 AC_VERB_GET_PIN_SENSE, 0);
1411 if (val & AC_PINSENSE_PRESENCE) {
1412 spec->jack_present = 1;
1413 break;
1414 }
1415 }
1416
1417 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001418 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001419 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1420 nid = spec->autocfg.speaker_pins[i];
1421 if (!nid)
1422 break;
1423 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1424 HDA_AMP_MUTE, mute);
1425 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001426}
1427
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001428static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1429 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001430{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001431 if (codec->vendor_id == 0x10ec0880)
1432 res >>= 28;
1433 else
1434 res >>= 26;
1435 if (res == ALC880_HP_EVENT)
1436 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001437}
1438
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001439static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1440{
1441 struct alc_spec *spec = codec->spec;
1442
1443 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1444 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1445 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1446 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1447 alc_automute_amp(codec);
1448}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001449
1450/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001451 * ALC888 Acer Aspire 4930G model
1452 */
1453
1454static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1455/* Front Mic: set to PIN_IN (empty by default) */
1456 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457/* Unselect Front Mic by default in input mixer 3 */
1458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001459/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001460 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1461/* Connect Internal HP to front */
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1465/* Connect HP out to front */
1466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1469 { }
1470};
1471
Hector Martin3b315d72009-06-02 10:54:19 +02001472/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001473 * ALC888 Acer Aspire 6530G model
1474 */
1475
1476static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1477/* Bias voltage on for external mic port */
1478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001479/* Front Mic: set to PIN_IN (empty by default) */
1480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481/* Unselect Front Mic by default in input mixer 3 */
1482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001483/* Enable unsolicited event for HP jack */
1484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1485/* Enable speaker output */
1486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488/* Enable headphone output */
1489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1492 { }
1493};
1494
1495/*
Hector Martin018df412009-06-04 00:13:40 +02001496 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001497 */
1498
Hector Martin018df412009-06-04 00:13:40 +02001499static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001500/* Front Mic: set to PIN_IN (empty by default) */
1501 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1502/* Unselect Front Mic by default in input mixer 3 */
1503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1504/* Enable unsolicited event for HP jack */
1505 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1506/* Connect Internal Front to Front */
1507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1510/* Connect Internal Rear to Rear */
1511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1514/* Connect Internal CLFE to CLFE */
1515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1517 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1518/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1522/* Enable all DACs */
1523/* DAC DISABLE/MUTE 1? */
1524/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1525 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1526 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1527/* DAC DISABLE/MUTE 2? */
1528/* some bit here disables the other DACs. Init=0x4900 */
1529 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1530 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1531/* Enable amplifiers */
1532 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1533 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001534/* DMIC fix
1535 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1536 * which makes the stereo useless. However, either the mic or the ALC889
1537 * makes the signal become a difference/sum signal instead of standard
1538 * stereo, which is annoying. So instead we flip this bit which makes the
1539 * codec replicate the sum signal to both channels, turning it into a
1540 * normal mono mic.
1541 */
1542/* DMIC_CONTROL? Init value = 0x0001 */
1543 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1544 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001545 { }
1546};
1547
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001549 /* Front mic only available on one ADC */
1550 {
1551 .num_items = 4,
1552 .items = {
1553 { "Mic", 0x0 },
1554 { "Line", 0x2 },
1555 { "CD", 0x4 },
1556 { "Front Mic", 0xb },
1557 },
1558 },
1559 {
1560 .num_items = 3,
1561 .items = {
1562 { "Mic", 0x0 },
1563 { "Line", 0x2 },
1564 { "CD", 0x4 },
1565 },
1566 }
1567};
1568
Tony Vroond2fd4b02009-06-21 00:40:10 +01001569static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1570 /* Interal mic only available on one ADC */
1571 {
Tony Vroon684a8842009-06-26 09:27:50 +01001572 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001573 .items = {
1574 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001575 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001576 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001577 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001578 { "Int Mic", 0xb },
1579 },
1580 },
1581 {
Tony Vroon684a8842009-06-26 09:27:50 +01001582 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001583 .items = {
1584 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001585 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001586 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001587 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001588 },
1589 }
1590};
1591
Hector Martin018df412009-06-04 00:13:40 +02001592static struct hda_input_mux alc889_capture_sources[3] = {
1593 /* Digital mic only available on first "ADC" */
1594 {
1595 .num_items = 5,
1596 .items = {
1597 { "Mic", 0x0 },
1598 { "Line", 0x2 },
1599 { "CD", 0x4 },
1600 { "Front Mic", 0xb },
1601 { "Input Mix", 0xa },
1602 },
1603 },
1604 {
1605 .num_items = 4,
1606 .items = {
1607 { "Mic", 0x0 },
1608 { "Line", 0x2 },
1609 { "CD", 0x4 },
1610 { "Input Mix", 0xa },
1611 },
1612 },
1613 {
1614 .num_items = 4,
1615 .items = {
1616 { "Mic", 0x0 },
1617 { "Line", 0x2 },
1618 { "CD", 0x4 },
1619 { "Input Mix", 0xa },
1620 },
1621 }
1622};
1623
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001624static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001625 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1626 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1627 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1628 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1629 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1630 HDA_OUTPUT),
1631 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1632 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1633 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1634 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1635 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1641 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001643 { } /* end */
1644};
1645
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001646static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001648 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001650 spec->autocfg.hp_pins[0] = 0x15;
1651 spec->autocfg.speaker_pins[0] = 0x14;
1652 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001653}
1654
Emilio López320d5922009-06-25 08:18:44 +02001655static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1656{
1657 struct alc_spec *spec = codec->spec;
1658
1659 spec->autocfg.hp_pins[0] = 0x15;
1660 spec->autocfg.speaker_pins[0] = 0x14;
1661 spec->autocfg.speaker_pins[1] = 0x16;
1662 spec->autocfg.speaker_pins[2] = 0x17;
1663 alc_automute_amp(codec);
1664}
1665
Hector Martin018df412009-06-04 00:13:40 +02001666static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001667{
1668 struct alc_spec *spec = codec->spec;
1669
1670 spec->autocfg.hp_pins[0] = 0x15;
1671 spec->autocfg.speaker_pins[0] = 0x14;
1672 spec->autocfg.speaker_pins[1] = 0x16;
1673 spec->autocfg.speaker_pins[2] = 0x1b;
1674 alc_automute_amp(codec);
1675}
1676
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001677/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 * ALC880 3-stack model
1679 *
1680 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001681 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1682 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 */
1684
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685static hda_nid_t alc880_dac_nids[4] = {
1686 /* front, rear, clfe, rear_surr */
1687 0x02, 0x05, 0x04, 0x03
1688};
1689
1690static hda_nid_t alc880_adc_nids[3] = {
1691 /* ADC0-2 */
1692 0x07, 0x08, 0x09,
1693};
1694
1695/* The datasheet says the node 0x07 is connected from inputs,
1696 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001697 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001699static hda_nid_t alc880_adc_nids_alt[2] = {
1700 /* ADC1-2 */
1701 0x08, 0x09,
1702};
1703
1704#define ALC880_DIGOUT_NID 0x06
1705#define ALC880_DIGIN_NID 0x0a
1706
1707static struct hda_input_mux alc880_capture_source = {
1708 .num_items = 4,
1709 .items = {
1710 { "Mic", 0x0 },
1711 { "Front Mic", 0x3 },
1712 { "Line", 0x2 },
1713 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001715};
1716
1717/* channel source setting (2/6 channel selection for 3-stack) */
1718/* 2ch mode */
1719static struct hda_verb alc880_threestack_ch2_init[] = {
1720 /* set line-in to input, mute it */
1721 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1722 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1723 /* set mic-in to input vref 80%, mute it */
1724 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1725 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 { } /* end */
1727};
1728
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001729/* 6ch mode */
1730static struct hda_verb alc880_threestack_ch6_init[] = {
1731 /* set line-in to output, unmute it */
1732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1733 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1734 /* set mic-in to output, unmute it */
1735 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1736 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1737 { } /* end */
1738};
1739
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001740static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 { 2, alc880_threestack_ch2_init },
1742 { 6, alc880_threestack_ch6_init },
1743};
1744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001745static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001746 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001747 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001748 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001749 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001750 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 {
1764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1765 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001766 .info = alc_ch_mode_info,
1767 .get = alc_ch_mode_get,
1768 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001769 },
1770 { } /* end */
1771};
1772
1773/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001774static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1775 struct snd_ctl_elem_info *uinfo)
1776{
1777 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1778 struct alc_spec *spec = codec->spec;
1779 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001780
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001781 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001782 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1783 HDA_INPUT);
1784 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001785 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001786 return err;
1787}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001789static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1790 unsigned int size, unsigned int __user *tlv)
1791{
1792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1793 struct alc_spec *spec = codec->spec;
1794 int err;
1795
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001796 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001797 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1798 HDA_INPUT);
1799 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001800 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001801 return err;
1802}
1803
1804typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1805 struct snd_ctl_elem_value *ucontrol);
1806
1807static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol,
1809 getput_call_t func)
1810{
1811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1812 struct alc_spec *spec = codec->spec;
1813 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1814 int err;
1815
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001816 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001817 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1818 3, 0, HDA_INPUT);
1819 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001820 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001821 return err;
1822}
1823
1824static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1826{
1827 return alc_cap_getput_caller(kcontrol, ucontrol,
1828 snd_hda_mixer_amp_volume_get);
1829}
1830
1831static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1832 struct snd_ctl_elem_value *ucontrol)
1833{
1834 return alc_cap_getput_caller(kcontrol, ucontrol,
1835 snd_hda_mixer_amp_volume_put);
1836}
1837
1838/* capture mixer elements */
1839#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1840
1841static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1842 struct snd_ctl_elem_value *ucontrol)
1843{
1844 return alc_cap_getput_caller(kcontrol, ucontrol,
1845 snd_hda_mixer_amp_switch_get);
1846}
1847
1848static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1849 struct snd_ctl_elem_value *ucontrol)
1850{
1851 return alc_cap_getput_caller(kcontrol, ucontrol,
1852 snd_hda_mixer_amp_switch_put);
1853}
1854
Takashi Iwaia23b6882009-03-23 15:21:36 +01001855#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001856 { \
1857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1858 .name = "Capture Switch", \
1859 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1860 .count = num, \
1861 .info = alc_cap_sw_info, \
1862 .get = alc_cap_sw_get, \
1863 .put = alc_cap_sw_put, \
1864 }, \
1865 { \
1866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1867 .name = "Capture Volume", \
1868 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1869 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1870 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1871 .count = num, \
1872 .info = alc_cap_vol_info, \
1873 .get = alc_cap_vol_get, \
1874 .put = alc_cap_vol_put, \
1875 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001876 }
1877
1878#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001879 { \
1880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1881 /* .name = "Capture Source", */ \
1882 .name = "Input Source", \
1883 .count = num, \
1884 .info = alc_mux_enum_info, \
1885 .get = alc_mux_enum_get, \
1886 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001887 }
1888
1889#define DEFINE_CAPMIX(num) \
1890static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1891 _DEFINE_CAPMIX(num), \
1892 _DEFINE_CAPSRC(num), \
1893 { } /* end */ \
1894}
1895
1896#define DEFINE_CAPMIX_NOSRC(num) \
1897static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1898 _DEFINE_CAPMIX(num), \
1899 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001900}
1901
1902/* up to three ADCs */
1903DEFINE_CAPMIX(1);
1904DEFINE_CAPMIX(2);
1905DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001906DEFINE_CAPMIX_NOSRC(1);
1907DEFINE_CAPMIX_NOSRC(2);
1908DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909
1910/*
1911 * ALC880 5-stack model
1912 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001913 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1914 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1916 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1917 */
1918
1919/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001920static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001922 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 { } /* end */
1924};
1925
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001926/* channel source setting (6/8 channel selection for 5-stack) */
1927/* 6ch mode */
1928static struct hda_verb alc880_fivestack_ch6_init[] = {
1929 /* set line-in to input, mute it */
1930 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1931 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001932 { } /* end */
1933};
1934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935/* 8ch mode */
1936static struct hda_verb alc880_fivestack_ch8_init[] = {
1937 /* set line-in to output, unmute it */
1938 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1939 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1940 { } /* end */
1941};
1942
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001943static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001944 { 6, alc880_fivestack_ch6_init },
1945 { 8, alc880_fivestack_ch8_init },
1946};
1947
1948
1949/*
1950 * ALC880 6-stack model
1951 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001952 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1953 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001954 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1955 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1956 */
1957
1958static hda_nid_t alc880_6st_dac_nids[4] = {
1959 /* front, rear, clfe, rear_surr */
1960 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001961};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001962
1963static struct hda_input_mux alc880_6stack_capture_source = {
1964 .num_items = 4,
1965 .items = {
1966 { "Mic", 0x0 },
1967 { "Front Mic", 0x1 },
1968 { "Line", 0x2 },
1969 { "CD", 0x4 },
1970 },
1971};
1972
1973/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001974static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001975 { 8, NULL },
1976};
1977
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001978static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001982 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001987 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001988 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001989 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1990 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001997 {
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1999 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002000 .info = alc_ch_mode_info,
2001 .get = alc_ch_mode_get,
2002 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002003 },
2004 { } /* end */
2005};
2006
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002007
2008/*
2009 * ALC880 W810 model
2010 *
2011 * W810 has rear IO for:
2012 * Front (DAC 02)
2013 * Surround (DAC 03)
2014 * Center/LFE (DAC 04)
2015 * Digital out (06)
2016 *
2017 * The system also has a pair of internal speakers, and a headphone jack.
2018 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002019 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020 * There is a variable resistor to control the speaker or headphone
2021 * volume. This is a hardware-only device without a software API.
2022 *
2023 * Plugging headphones in will disable the internal speakers. This is
2024 * implemented in hardware, not via the driver using jack sense. In
2025 * a similar fashion, plugging into the rear socket marked "front" will
2026 * disable both the speakers and headphones.
2027 *
2028 * For input, there's a microphone jack, and an "audio in" jack.
2029 * These may not do anything useful with this driver yet, because I
2030 * haven't setup any initialization verbs for these yet...
2031 */
2032
2033static hda_nid_t alc880_w810_dac_nids[3] = {
2034 /* front, rear/surround, clfe */
2035 0x02, 0x03, 0x04
2036};
2037
2038/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002039static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 { 6, NULL }
2041};
2042
2043/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002044static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002048 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2054 { } /* end */
2055};
2056
2057
2058/*
2059 * Z710V model
2060 *
2061 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002062 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2063 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064 */
2065
2066static hda_nid_t alc880_z71v_dac_nids[1] = {
2067 0x02
2068};
2069#define ALC880_Z71V_HP_DAC 0x03
2070
2071/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002072static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 { 2, NULL }
2074};
2075
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002076static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002080 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2085 { } /* end */
2086};
2087
2088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089/*
2090 * ALC880 F1734 model
2091 *
2092 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2093 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2094 */
2095
2096static hda_nid_t alc880_f1734_dac_nids[1] = {
2097 0x03
2098};
2099#define ALC880_F1734_HP_DAC 0x02
2100
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002101static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002104 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002110 { } /* end */
2111};
2112
Takashi Iwai937b4162008-02-11 14:52:36 +01002113static struct hda_input_mux alc880_f1734_capture_source = {
2114 .num_items = 2,
2115 .items = {
2116 { "Mic", 0x1 },
2117 { "CD", 0x4 },
2118 },
2119};
2120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122/*
2123 * ALC880 ASUS model
2124 *
2125 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2126 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2127 * Mic = 0x18, Line = 0x1a
2128 */
2129
2130#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2131#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2132
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002133static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002137 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2139 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002140 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2141 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002148 {
2149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2150 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002151 .info = alc_ch_mode_info,
2152 .get = alc_ch_mode_get,
2153 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 },
2155 { } /* end */
2156};
2157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158/*
2159 * ALC880 ASUS W1V model
2160 *
2161 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2162 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2163 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2164 */
2165
2166/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002167static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002168 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2169 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002170 { } /* end */
2171};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172
Kailang Yangdf694da2005-12-05 19:42:22 +01002173/* TCL S700 */
2174static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2176 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2178 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2179 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2182 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2183 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002184 { } /* end */
2185};
2186
Kailang Yangccc656c2006-10-17 12:32:26 +02002187/* Uniwill */
2188static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002189 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2190 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2191 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2196 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002205 {
2206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2207 .name = "Channel Mode",
2208 .info = alc_ch_mode_info,
2209 .get = alc_ch_mode_get,
2210 .put = alc_ch_mode_put,
2211 },
2212 { } /* end */
2213};
2214
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002215static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2217 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2219 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2223 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2225 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2226 { } /* end */
2227};
2228
Kailang Yangccc656c2006-10-17 12:32:26 +02002229static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2231 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2232 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2233 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2236 { } /* end */
2237};
2238
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002240 * virtual master controls
2241 */
2242
2243/*
2244 * slave controls for virtual master
2245 */
2246static const char *alc_slave_vols[] = {
2247 "Front Playback Volume",
2248 "Surround Playback Volume",
2249 "Center Playback Volume",
2250 "LFE Playback Volume",
2251 "Side Playback Volume",
2252 "Headphone Playback Volume",
2253 "Speaker Playback Volume",
2254 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002255 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002256 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002257 NULL,
2258};
2259
2260static const char *alc_slave_sws[] = {
2261 "Front Playback Switch",
2262 "Surround Playback Switch",
2263 "Center Playback Switch",
2264 "LFE Playback Switch",
2265 "Side Playback Switch",
2266 "Headphone Playback Switch",
2267 "Speaker Playback Switch",
2268 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002269 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002270 NULL,
2271};
2272
2273/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002276
2277static void alc_free_kctls(struct hda_codec *codec);
2278
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002279/* additional beep mixers; the actual parameters are overwritten at build */
2280static struct snd_kcontrol_new alc_beep_mixer[] = {
2281 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2282 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2283 { } /* end */
2284};
2285
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286static int alc_build_controls(struct hda_codec *codec)
2287{
2288 struct alc_spec *spec = codec->spec;
2289 int err;
2290 int i;
2291
2292 for (i = 0; i < spec->num_mixers; i++) {
2293 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2294 if (err < 0)
2295 return err;
2296 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002297 if (spec->cap_mixer) {
2298 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2299 if (err < 0)
2300 return err;
2301 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002303 err = snd_hda_create_spdif_out_ctls(codec,
2304 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 if (err < 0)
2306 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002307 if (!spec->no_analog) {
2308 err = snd_hda_create_spdif_share_sw(codec,
2309 &spec->multiout);
2310 if (err < 0)
2311 return err;
2312 spec->multiout.share_spdif = 1;
2313 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 }
2315 if (spec->dig_in_nid) {
2316 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2317 if (err < 0)
2318 return err;
2319 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002320
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002321 /* create beep controls if needed */
2322 if (spec->beep_amp) {
2323 struct snd_kcontrol_new *knew;
2324 for (knew = alc_beep_mixer; knew->name; knew++) {
2325 struct snd_kcontrol *kctl;
2326 kctl = snd_ctl_new1(knew, codec);
2327 if (!kctl)
2328 return -ENOMEM;
2329 kctl->private_value = spec->beep_amp;
2330 err = snd_hda_ctl_add(codec, kctl);
2331 if (err < 0)
2332 return err;
2333 }
2334 }
2335
Takashi Iwai2134ea42008-01-10 16:53:55 +01002336 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002337 if (!spec->no_analog &&
2338 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002339 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002340 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002341 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002342 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002343 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002344 if (err < 0)
2345 return err;
2346 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002347 if (!spec->no_analog &&
2348 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002349 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2350 NULL, alc_slave_sws);
2351 if (err < 0)
2352 return err;
2353 }
2354
Takashi Iwai603c4012008-07-30 15:01:44 +02002355 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 return 0;
2357}
2358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360/*
2361 * initialize the codec volumes, etc
2362 */
2363
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364/*
2365 * generic initialization of ADC, input mixers and output mixers
2366 */
2367static struct hda_verb alc880_volume_init_verbs[] = {
2368 /*
2369 * Unmute ADC0-2 and set the default input to mic-in
2370 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002371 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002373 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002375 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2379 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002380 * Note: PASD motherboards uses the Line In 2 as the input for front
2381 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002383 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 /*
2393 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002395 /* set vol=0 to output mixers */
2396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2400 /* set up input amps for analog loopback */
2401 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
2411 { }
2412};
2413
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002414/*
2415 * 3-stack pin configuration:
2416 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2417 */
2418static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2419 /*
2420 * preset connection lists of input pins
2421 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2422 */
2423 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2424 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2425 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2426
2427 /*
2428 * Set pin mode and muting
2429 */
2430 /* set front pin widgets 0x14 for output */
2431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2433 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2434 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2436 /* Mic2 (as headphone out) for HP output */
2437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2439 /* Line In pin widget for input */
2440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2442 /* Line2 (as front mic) pin widget for input and vref at 80% */
2443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2445 /* CD pin widget for input */
2446 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2447
2448 { }
2449};
2450
2451/*
2452 * 5-stack pin configuration:
2453 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2454 * line-in/side = 0x1a, f-mic = 0x1b
2455 */
2456static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2457 /*
2458 * preset connection lists of input pins
2459 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2460 */
2461 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2462 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2463
2464 /*
2465 * Set pin mode and muting
2466 */
2467 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472 /* unmute pins for output (no gain on this amp) */
2473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2475 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2477
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2481 /* Mic2 (as headphone out) for HP output */
2482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484 /* Line In pin widget for input */
2485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2487 /* Line2 (as front mic) pin widget for input and vref at 80% */
2488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2490 /* CD pin widget for input */
2491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492
2493 { }
2494};
2495
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002496/*
2497 * W810 pin configuration:
2498 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2499 */
2500static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 /* hphone/speaker input selector: front DAC */
2502 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2508 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2510
2511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 { }
2515};
2516
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517/*
2518 * Z71V pin configuration:
2519 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2520 */
2521static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002526
Takashi Iwai16ded522005-06-10 19:58:24 +02002527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002531
2532 { }
2533};
2534
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535/*
2536 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002537 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2538 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 */
2540static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2541 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2542
Takashi Iwai16ded522005-06-10 19:58:24 +02002543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002547 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002549 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551
Takashi Iwai16ded522005-06-10 19:58:24 +02002552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002560 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002562 { }
2563};
Takashi Iwai16ded522005-06-10 19:58:24 +02002564
Kailang Yangccc656c2006-10-17 12:32:26 +02002565/*
2566 * Uniwill pin configuration:
2567 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2568 * line = 0x1a
2569 */
2570static struct hda_verb alc880_uniwill_init_verbs[] = {
2571 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2572
2573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2579 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2580 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2585 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2587
2588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2592 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2594 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2595 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2596 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2597
2598 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2600
2601 { }
2602};
2603
2604/*
2605* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002606* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002607 */
2608static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2609 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2610
2611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2623
2624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2627 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2630
2631 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2632 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2633
2634 { }
2635};
2636
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002637static struct hda_verb alc880_beep_init_verbs[] = {
2638 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2639 { }
2640};
2641
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002642/* auto-toggle front mic */
2643static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2644{
2645 unsigned int present;
2646 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002647
2648 present = snd_hda_codec_read(codec, 0x18, 0,
2649 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002650 bits = present ? HDA_AMP_MUTE : 0;
2651 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002652}
2653
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002654static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002655{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002656 struct alc_spec *spec = codec->spec;
2657
2658 spec->autocfg.hp_pins[0] = 0x14;
2659 spec->autocfg.speaker_pins[0] = 0x15;
2660 spec->autocfg.speaker_pins[0] = 0x16;
2661 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002662 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002663}
2664
2665static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2666 unsigned int res)
2667{
2668 /* Looks like the unsol event is incompatible with the standard
2669 * definition. 4bit tag is placed at 28 bit!
2670 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002671 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002672 case ALC880_MIC_EVENT:
2673 alc880_uniwill_mic_automute(codec);
2674 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002675 default:
2676 alc_automute_amp_unsol_event(codec, res);
2677 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002678 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002679}
2680
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002681static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002683 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002684
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002685 spec->autocfg.hp_pins[0] = 0x14;
2686 spec->autocfg.speaker_pins[0] = 0x15;
2687 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002688}
2689
2690static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2691{
2692 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002693
Kailang Yangccc656c2006-10-17 12:32:26 +02002694 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002695 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2696 present &= HDA_AMP_VOLMASK;
2697 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2698 HDA_AMP_VOLMASK, present);
2699 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2700 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002701}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002702
Kailang Yangccc656c2006-10-17 12:32:26 +02002703static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2704 unsigned int res)
2705{
2706 /* Looks like the unsol event is incompatible with the standard
2707 * definition. 4bit tag is placed at 28 bit!
2708 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002709 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002710 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002711 else
2712 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002713}
2714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002715/*
2716 * F1734 pin configuration:
2717 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2718 */
2719static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002720 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2722 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2723 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2725
2726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730
2731 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002740
Takashi Iwai937b4162008-02-11 14:52:36 +01002741 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2742 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2743
Takashi Iwai16ded522005-06-10 19:58:24 +02002744 { }
2745};
2746
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747/*
2748 * ASUS pin configuration:
2749 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2750 */
2751static struct hda_verb alc880_pin_asus_init_verbs[] = {
2752 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2753 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2754 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2755 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2756
2757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2761 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2762 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2765
2766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2774 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 { }
2777};
2778
2779/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002780#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2781#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002782#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783
Kailang Yangdf694da2005-12-05 19:42:22 +01002784/* Clevo m520g init */
2785static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2786 /* headphone output */
2787 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2788 /* line-out */
2789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 /* Line-in */
2792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 /* CD */
2795 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2796 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2797 /* Mic1 (rear panel) */
2798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2800 /* Mic2 (front panel) */
2801 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2803 /* headphone */
2804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2806 /* change to EAPD mode */
2807 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2808 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2809
2810 { }
2811};
2812
2813static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002814 /* change to EAPD mode */
2815 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2816 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2817
Kailang Yangdf694da2005-12-05 19:42:22 +01002818 /* Headphone output */
2819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2820 /* Front output*/
2821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2823
2824 /* Line In pin widget for input */
2825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2826 /* CD pin widget for input */
2827 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2828 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2830
2831 /* change to EAPD mode */
2832 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2833 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2834
2835 { }
2836};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837
2838/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002839 * LG m1 express dual
2840 *
2841 * Pin assignment:
2842 * Rear Line-In/Out (blue): 0x14
2843 * Build-in Mic-In: 0x15
2844 * Speaker-out: 0x17
2845 * HP-Out (green): 0x1b
2846 * Mic-In/Out (red): 0x19
2847 * SPDIF-Out: 0x1e
2848 */
2849
2850/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2851static hda_nid_t alc880_lg_dac_nids[3] = {
2852 0x05, 0x02, 0x03
2853};
2854
2855/* seems analog CD is not working */
2856static struct hda_input_mux alc880_lg_capture_source = {
2857 .num_items = 3,
2858 .items = {
2859 { "Mic", 0x1 },
2860 { "Line", 0x5 },
2861 { "Internal Mic", 0x6 },
2862 },
2863};
2864
2865/* 2,4,6 channel modes */
2866static struct hda_verb alc880_lg_ch2_init[] = {
2867 /* set line-in and mic-in to input */
2868 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2869 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2870 { }
2871};
2872
2873static struct hda_verb alc880_lg_ch4_init[] = {
2874 /* set line-in to out and mic-in to input */
2875 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2876 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2877 { }
2878};
2879
2880static struct hda_verb alc880_lg_ch6_init[] = {
2881 /* set line-in and mic-in to output */
2882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2883 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2884 { }
2885};
2886
2887static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2888 { 2, alc880_lg_ch2_init },
2889 { 4, alc880_lg_ch4_init },
2890 { 6, alc880_lg_ch6_init },
2891};
2892
2893static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2895 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002896 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2897 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2898 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2899 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2900 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2901 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2904 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2905 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2906 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2907 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2908 {
2909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2910 .name = "Channel Mode",
2911 .info = alc_ch_mode_info,
2912 .get = alc_ch_mode_get,
2913 .put = alc_ch_mode_put,
2914 },
2915 { } /* end */
2916};
2917
2918static struct hda_verb alc880_lg_init_verbs[] = {
2919 /* set capture source to mic-in */
2920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2921 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2923 /* mute all amp mixer inputs */
2924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002927 /* line-in to input */
2928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 /* built-in mic */
2931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2933 /* speaker-out */
2934 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* mic-in to input */
2937 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2938 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* HP-out */
2941 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2944 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002945 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002946 { }
2947};
2948
2949/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002950static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002951{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002952 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002953
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002954 spec->autocfg.hp_pins[0] = 0x1b;
2955 spec->autocfg.speaker_pins[0] = 0x17;
2956 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002957}
2958
2959/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002960 * LG LW20
2961 *
2962 * Pin assignment:
2963 * Speaker-out: 0x14
2964 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002965 * Built-in Mic-In: 0x19
2966 * Line-In: 0x1b
2967 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002968 * SPDIF-Out: 0x1e
2969 */
2970
Takashi Iwaid6815182006-03-23 16:06:23 +01002971static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002972 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002973 .items = {
2974 { "Mic", 0x0 },
2975 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002976 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002977 },
2978};
2979
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002980#define alc880_lg_lw_modes alc880_threestack_modes
2981
Takashi Iwaid6815182006-03-23 16:06:23 +01002982static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2986 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2995 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2996 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002997 {
2998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2999 .name = "Channel Mode",
3000 .info = alc_ch_mode_info,
3001 .get = alc_ch_mode_get,
3002 .put = alc_ch_mode_put,
3003 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003004 { } /* end */
3005};
3006
3007static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3009 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3010 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3011
Takashi Iwaid6815182006-03-23 16:06:23 +01003012 /* set capture source to mic-in */
3013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003017 /* speaker-out */
3018 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3019 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3020 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003021 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3023 /* mic-in to input */
3024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3025 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3026 /* built-in mic */
3027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003030 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003031 { }
3032};
3033
3034/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003035static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003036{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003037 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003038
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003039 spec->autocfg.hp_pins[0] = 0x1b;
3040 spec->autocfg.speaker_pins[0] = 0x14;
3041 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003042}
3043
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003044static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3045 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3046 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3049 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3050 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3051 { } /* end */
3052};
3053
3054static struct hda_input_mux alc880_medion_rim_capture_source = {
3055 .num_items = 2,
3056 .items = {
3057 { "Mic", 0x0 },
3058 { "Internal Mic", 0x1 },
3059 },
3060};
3061
3062static struct hda_verb alc880_medion_rim_init_verbs[] = {
3063 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3064
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067
3068 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* Mic2 (as headphone out) for HP output */
3072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3074 /* Internal Speaker */
3075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077
3078 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3079 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3080
3081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3082 { }
3083};
3084
3085/* toggle speaker-output according to the hp-jack state */
3086static void alc880_medion_rim_automute(struct hda_codec *codec)
3087{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003088 struct alc_spec *spec = codec->spec;
3089 alc_automute_amp(codec);
3090 /* toggle EAPD */
3091 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003092 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3093 else
3094 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3095}
3096
3097static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3098 unsigned int res)
3099{
3100 /* Looks like the unsol event is incompatible with the standard
3101 * definition. 4bit tag is placed at 28 bit!
3102 */
3103 if ((res >> 28) == ALC880_HP_EVENT)
3104 alc880_medion_rim_automute(codec);
3105}
3106
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003107static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3108{
3109 struct alc_spec *spec = codec->spec;
3110
3111 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x1b;
3113 alc880_medion_rim_automute(codec);
3114}
3115
Takashi Iwaicb53c622007-08-10 17:21:45 +02003116#ifdef CONFIG_SND_HDA_POWER_SAVE
3117static struct hda_amp_list alc880_loopbacks[] = {
3118 { 0x0b, HDA_INPUT, 0 },
3119 { 0x0b, HDA_INPUT, 1 },
3120 { 0x0b, HDA_INPUT, 2 },
3121 { 0x0b, HDA_INPUT, 3 },
3122 { 0x0b, HDA_INPUT, 4 },
3123 { } /* end */
3124};
3125
3126static struct hda_amp_list alc880_lg_loopbacks[] = {
3127 { 0x0b, HDA_INPUT, 1 },
3128 { 0x0b, HDA_INPUT, 6 },
3129 { 0x0b, HDA_INPUT, 7 },
3130 { } /* end */
3131};
3132#endif
3133
Takashi Iwaid6815182006-03-23 16:06:23 +01003134/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003135 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003137
Linus Torvalds1da177e2005-04-16 15:20:36 -07003138static int alc_init(struct hda_codec *codec)
3139{
3140 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141 unsigned int i;
3142
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003143 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003144 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 for (i = 0; i < spec->num_init_verbs; i++)
3147 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003148
3149 if (spec->init_hook)
3150 spec->init_hook(codec);
3151
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152 return 0;
3153}
3154
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003155static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3156{
3157 struct alc_spec *spec = codec->spec;
3158
3159 if (spec->unsol_event)
3160 spec->unsol_event(codec, res);
3161}
3162
Takashi Iwaicb53c622007-08-10 17:21:45 +02003163#ifdef CONFIG_SND_HDA_POWER_SAVE
3164static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3165{
3166 struct alc_spec *spec = codec->spec;
3167 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3168}
3169#endif
3170
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171/*
3172 * Analog playback callbacks
3173 */
3174static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3175 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003176 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177{
3178 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003179 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3180 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003181}
3182
3183static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3184 struct hda_codec *codec,
3185 unsigned int stream_tag,
3186 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003187 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188{
3189 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003190 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3191 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192}
3193
3194static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3195 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003196 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197{
3198 struct alc_spec *spec = codec->spec;
3199 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3200}
3201
3202/*
3203 * Digital out
3204 */
3205static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3206 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003207 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208{
3209 struct alc_spec *spec = codec->spec;
3210 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3211}
3212
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003213static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3214 struct hda_codec *codec,
3215 unsigned int stream_tag,
3216 unsigned int format,
3217 struct snd_pcm_substream *substream)
3218{
3219 struct alc_spec *spec = codec->spec;
3220 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3221 stream_tag, format, substream);
3222}
3223
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003224static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3225 struct hda_codec *codec,
3226 struct snd_pcm_substream *substream)
3227{
3228 struct alc_spec *spec = codec->spec;
3229 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3230}
3231
Linus Torvalds1da177e2005-04-16 15:20:36 -07003232static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3233 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003234 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235{
3236 struct alc_spec *spec = codec->spec;
3237 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3238}
3239
3240/*
3241 * Analog capture
3242 */
Takashi Iwai63300792008-01-24 15:31:36 +01003243static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244 struct hda_codec *codec,
3245 unsigned int stream_tag,
3246 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003247 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248{
3249 struct alc_spec *spec = codec->spec;
3250
Takashi Iwai63300792008-01-24 15:31:36 +01003251 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003252 stream_tag, 0, format);
3253 return 0;
3254}
3255
Takashi Iwai63300792008-01-24 15:31:36 +01003256static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003257 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003258 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259{
3260 struct alc_spec *spec = codec->spec;
3261
Takashi Iwai888afa12008-03-18 09:57:50 +01003262 snd_hda_codec_cleanup_stream(codec,
3263 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003264 return 0;
3265}
3266
3267
3268/*
3269 */
3270static struct hda_pcm_stream alc880_pcm_analog_playback = {
3271 .substreams = 1,
3272 .channels_min = 2,
3273 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003275 .ops = {
3276 .open = alc880_playback_pcm_open,
3277 .prepare = alc880_playback_pcm_prepare,
3278 .cleanup = alc880_playback_pcm_cleanup
3279 },
3280};
3281
3282static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003283 .substreams = 1,
3284 .channels_min = 2,
3285 .channels_max = 2,
3286 /* NID is set in alc_build_pcms */
3287};
3288
3289static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3290 .substreams = 1,
3291 .channels_min = 2,
3292 .channels_max = 2,
3293 /* NID is set in alc_build_pcms */
3294};
3295
3296static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3297 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003298 .channels_min = 2,
3299 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003301 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003302 .prepare = alc880_alt_capture_pcm_prepare,
3303 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003304 },
3305};
3306
3307static struct hda_pcm_stream alc880_pcm_digital_playback = {
3308 .substreams = 1,
3309 .channels_min = 2,
3310 .channels_max = 2,
3311 /* NID is set in alc_build_pcms */
3312 .ops = {
3313 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003314 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003315 .prepare = alc880_dig_playback_pcm_prepare,
3316 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317 },
3318};
3319
3320static struct hda_pcm_stream alc880_pcm_digital_capture = {
3321 .substreams = 1,
3322 .channels_min = 2,
3323 .channels_max = 2,
3324 /* NID is set in alc_build_pcms */
3325};
3326
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003327/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003328static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003329 .substreams = 0,
3330 .channels_min = 0,
3331 .channels_max = 0,
3332};
3333
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334static int alc_build_pcms(struct hda_codec *codec)
3335{
3336 struct alc_spec *spec = codec->spec;
3337 struct hda_pcm *info = spec->pcm_rec;
3338 int i;
3339
3340 codec->num_pcms = 1;
3341 codec->pcm_info = info;
3342
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003343 if (spec->no_analog)
3344 goto skip_analog;
3345
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003346 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3347 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003349
Takashi Iwai4a471b72005-12-07 13:56:29 +01003350 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003351 if (snd_BUG_ON(!spec->multiout.dac_nids))
3352 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003353 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3354 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3355 }
3356 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003357 if (snd_BUG_ON(!spec->adc_nids))
3358 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003359 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3360 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3361 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362
Takashi Iwai4a471b72005-12-07 13:56:29 +01003363 if (spec->channel_mode) {
3364 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3365 for (i = 0; i < spec->num_channel_mode; i++) {
3366 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3367 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369 }
3370 }
3371
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003372 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003373 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003375 snprintf(spec->stream_name_digital,
3376 sizeof(spec->stream_name_digital),
3377 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003378 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003379 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003380 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003382 if (spec->dig_out_type)
3383 info->pcm_type = spec->dig_out_type;
3384 else
3385 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003386 if (spec->multiout.dig_out_nid &&
3387 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003388 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3389 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3390 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003391 if (spec->dig_in_nid &&
3392 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3394 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3395 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003396 /* FIXME: do we need this for all Realtek codec models? */
3397 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398 }
3399
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003400 if (spec->no_analog)
3401 return 0;
3402
Takashi Iwaie08a0072006-09-07 17:52:14 +02003403 /* If the use of more than one ADC is requested for the current
3404 * model, configure a second analog capture-only PCM.
3405 */
3406 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003407 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3408 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003409 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003410 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003411 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003412 if (spec->alt_dac_nid) {
3413 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3414 *spec->stream_analog_alt_playback;
3415 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3416 spec->alt_dac_nid;
3417 } else {
3418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3419 alc_pcm_null_stream;
3420 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3421 }
3422 if (spec->num_adc_nids > 1) {
3423 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3424 *spec->stream_analog_alt_capture;
3425 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3426 spec->adc_nids[1];
3427 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3428 spec->num_adc_nids - 1;
3429 } else {
3430 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3431 alc_pcm_null_stream;
3432 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003433 }
3434 }
3435
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436 return 0;
3437}
3438
Takashi Iwai603c4012008-07-30 15:01:44 +02003439static void alc_free_kctls(struct hda_codec *codec)
3440{
3441 struct alc_spec *spec = codec->spec;
3442
3443 if (spec->kctls.list) {
3444 struct snd_kcontrol_new *kctl = spec->kctls.list;
3445 int i;
3446 for (i = 0; i < spec->kctls.used; i++)
3447 kfree(kctl[i].name);
3448 }
3449 snd_array_free(&spec->kctls);
3450}
3451
Linus Torvalds1da177e2005-04-16 15:20:36 -07003452static void alc_free(struct hda_codec *codec)
3453{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003454 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003456 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003457 return;
3458
Takashi Iwai603c4012008-07-30 15:01:44 +02003459 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003461 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003462}
3463
Takashi Iwaie044c392008-10-27 16:56:24 +01003464#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003465static int alc_resume(struct hda_codec *codec)
3466{
Takashi Iwaie044c392008-10-27 16:56:24 +01003467 codec->patch_ops.init(codec);
3468 snd_hda_codec_resume_amp(codec);
3469 snd_hda_codec_resume_cache(codec);
3470 return 0;
3471}
Takashi Iwaie044c392008-10-27 16:56:24 +01003472#endif
3473
Linus Torvalds1da177e2005-04-16 15:20:36 -07003474/*
3475 */
3476static struct hda_codec_ops alc_patch_ops = {
3477 .build_controls = alc_build_controls,
3478 .build_pcms = alc_build_pcms,
3479 .init = alc_init,
3480 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003481 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003482#ifdef SND_HDA_NEEDS_RESUME
3483 .resume = alc_resume,
3484#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003485#ifdef CONFIG_SND_HDA_POWER_SAVE
3486 .check_power_status = alc_check_power_status,
3487#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003488};
3489
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003490
3491/*
3492 * Test configuration for debugging
3493 *
3494 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3495 * enum controls.
3496 */
3497#ifdef CONFIG_SND_DEBUG
3498static hda_nid_t alc880_test_dac_nids[4] = {
3499 0x02, 0x03, 0x04, 0x05
3500};
3501
3502static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003503 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003504 .items = {
3505 { "In-1", 0x0 },
3506 { "In-2", 0x1 },
3507 { "In-3", 0x2 },
3508 { "In-4", 0x3 },
3509 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003510 { "Front", 0x5 },
3511 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512 },
3513};
3514
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003515static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003517 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003518 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003519 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003520};
3521
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003522static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3523 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003524{
3525 static char *texts[] = {
3526 "N/A", "Line Out", "HP Out",
3527 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3528 };
3529 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3530 uinfo->count = 1;
3531 uinfo->value.enumerated.items = 8;
3532 if (uinfo->value.enumerated.item >= 8)
3533 uinfo->value.enumerated.item = 7;
3534 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3535 return 0;
3536}
3537
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003538static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3539 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003540{
3541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3542 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3543 unsigned int pin_ctl, item = 0;
3544
3545 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3546 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3547 if (pin_ctl & AC_PINCTL_OUT_EN) {
3548 if (pin_ctl & AC_PINCTL_HP_EN)
3549 item = 2;
3550 else
3551 item = 1;
3552 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3553 switch (pin_ctl & AC_PINCTL_VREFEN) {
3554 case AC_PINCTL_VREF_HIZ: item = 3; break;
3555 case AC_PINCTL_VREF_50: item = 4; break;
3556 case AC_PINCTL_VREF_GRD: item = 5; break;
3557 case AC_PINCTL_VREF_80: item = 6; break;
3558 case AC_PINCTL_VREF_100: item = 7; break;
3559 }
3560 }
3561 ucontrol->value.enumerated.item[0] = item;
3562 return 0;
3563}
3564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003565static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3566 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003567{
3568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3569 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3570 static unsigned int ctls[] = {
3571 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3572 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3573 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3574 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3575 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3576 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3577 };
3578 unsigned int old_ctl, new_ctl;
3579
3580 old_ctl = snd_hda_codec_read(codec, nid, 0,
3581 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3582 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3583 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003584 int val;
3585 snd_hda_codec_write_cache(codec, nid, 0,
3586 AC_VERB_SET_PIN_WIDGET_CONTROL,
3587 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003588 val = ucontrol->value.enumerated.item[0] >= 3 ?
3589 HDA_AMP_MUTE : 0;
3590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3591 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003592 return 1;
3593 }
3594 return 0;
3595}
3596
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003597static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3598 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003599{
3600 static char *texts[] = {
3601 "Front", "Surround", "CLFE", "Side"
3602 };
3603 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3604 uinfo->count = 1;
3605 uinfo->value.enumerated.items = 4;
3606 if (uinfo->value.enumerated.item >= 4)
3607 uinfo->value.enumerated.item = 3;
3608 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3609 return 0;
3610}
3611
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003612static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3613 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003614{
3615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3616 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3617 unsigned int sel;
3618
3619 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3620 ucontrol->value.enumerated.item[0] = sel & 3;
3621 return 0;
3622}
3623
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003624static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3625 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003626{
3627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3628 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3629 unsigned int sel;
3630
3631 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3632 if (ucontrol->value.enumerated.item[0] != sel) {
3633 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003634 snd_hda_codec_write_cache(codec, nid, 0,
3635 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003636 return 1;
3637 }
3638 return 0;
3639}
3640
3641#define PIN_CTL_TEST(xname,nid) { \
3642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3643 .name = xname, \
3644 .info = alc_test_pin_ctl_info, \
3645 .get = alc_test_pin_ctl_get, \
3646 .put = alc_test_pin_ctl_put, \
3647 .private_value = nid \
3648 }
3649
3650#define PIN_SRC_TEST(xname,nid) { \
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3652 .name = xname, \
3653 .info = alc_test_pin_src_info, \
3654 .get = alc_test_pin_src_get, \
3655 .put = alc_test_pin_src_put, \
3656 .private_value = nid \
3657 }
3658
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003659static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3662 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3663 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003664 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3665 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3666 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3667 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003668 PIN_CTL_TEST("Front Pin Mode", 0x14),
3669 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3670 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3671 PIN_CTL_TEST("Side Pin Mode", 0x17),
3672 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3673 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3674 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3675 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3676 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3677 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3678 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3679 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3680 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3682 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3683 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3684 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3685 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3686 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3687 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003690 {
3691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3692 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003693 .info = alc_ch_mode_info,
3694 .get = alc_ch_mode_get,
3695 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003696 },
3697 { } /* end */
3698};
3699
3700static struct hda_verb alc880_test_init_verbs[] = {
3701 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003710 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003715 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3718 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3719 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003720 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003725 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3727 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003736 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003738 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003739 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003740 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003742 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003743 /* Analog input/passthru */
3744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003749 { }
3750};
3751#endif
3752
Linus Torvalds1da177e2005-04-16 15:20:36 -07003753/*
3754 */
3755
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003756static const char *alc880_models[ALC880_MODEL_LAST] = {
3757 [ALC880_3ST] = "3stack",
3758 [ALC880_TCL_S700] = "tcl",
3759 [ALC880_3ST_DIG] = "3stack-digout",
3760 [ALC880_CLEVO] = "clevo",
3761 [ALC880_5ST] = "5stack",
3762 [ALC880_5ST_DIG] = "5stack-digout",
3763 [ALC880_W810] = "w810",
3764 [ALC880_Z71V] = "z71v",
3765 [ALC880_6ST] = "6stack",
3766 [ALC880_6ST_DIG] = "6stack-digout",
3767 [ALC880_ASUS] = "asus",
3768 [ALC880_ASUS_W1V] = "asus-w1v",
3769 [ALC880_ASUS_DIG] = "asus-dig",
3770 [ALC880_ASUS_DIG2] = "asus-dig2",
3771 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003772 [ALC880_UNIWILL_P53] = "uniwill-p53",
3773 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003774 [ALC880_F1734] = "F1734",
3775 [ALC880_LG] = "lg",
3776 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003777 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003778#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003779 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003780#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003781 [ALC880_AUTO] = "auto",
3782};
3783
3784static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003785 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003786 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3787 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3788 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3789 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3790 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3791 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3792 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3793 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003794 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3795 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003796 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3797 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3798 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3799 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3800 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3801 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3802 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3803 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3804 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3805 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003806 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3808 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3809 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003810 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003811 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003812 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3813 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003814 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3815 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003816 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3817 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3818 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3819 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003820 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3821 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003822 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003823 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003824 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003825 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003826 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3827 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003828 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003829 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003830 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003831 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003832 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003833 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003834 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003835 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003836 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003837 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3838 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003839 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003840 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3841 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3842 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3843 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003844 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3845 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003846 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003847 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003848 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3849 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003850 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3851 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3852 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003853 /* default Intel */
3854 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003855 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3856 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857 {}
3858};
3859
Takashi Iwai16ded522005-06-10 19:58:24 +02003860/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003861 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003862 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003863static struct alc_config_preset alc880_presets[] = {
3864 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003865 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003866 .init_verbs = { alc880_volume_init_verbs,
3867 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003868 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003869 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003870 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3871 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003872 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003873 .input_mux = &alc880_capture_source,
3874 },
3875 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003876 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003877 .init_verbs = { alc880_volume_init_verbs,
3878 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003879 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003880 .dac_nids = alc880_dac_nids,
3881 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003882 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3883 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003884 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003885 .input_mux = &alc880_capture_source,
3886 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003887 [ALC880_TCL_S700] = {
3888 .mixers = { alc880_tcl_s700_mixer },
3889 .init_verbs = { alc880_volume_init_verbs,
3890 alc880_pin_tcl_S700_init_verbs,
3891 alc880_gpio2_init_verbs },
3892 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3893 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003894 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3895 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003896 .hp_nid = 0x03,
3897 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3898 .channel_mode = alc880_2_jack_modes,
3899 .input_mux = &alc880_capture_source,
3900 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003901 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003902 .mixers = { alc880_three_stack_mixer,
3903 alc880_five_stack_mixer},
3904 .init_verbs = { alc880_volume_init_verbs,
3905 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003906 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3907 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003908 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3909 .channel_mode = alc880_fivestack_modes,
3910 .input_mux = &alc880_capture_source,
3911 },
3912 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003913 .mixers = { alc880_three_stack_mixer,
3914 alc880_five_stack_mixer },
3915 .init_verbs = { alc880_volume_init_verbs,
3916 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3918 .dac_nids = alc880_dac_nids,
3919 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003920 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3921 .channel_mode = alc880_fivestack_modes,
3922 .input_mux = &alc880_capture_source,
3923 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003924 [ALC880_6ST] = {
3925 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003926 .init_verbs = { alc880_volume_init_verbs,
3927 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003928 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3929 .dac_nids = alc880_6st_dac_nids,
3930 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3931 .channel_mode = alc880_sixstack_modes,
3932 .input_mux = &alc880_6stack_capture_source,
3933 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003934 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003936 .init_verbs = { alc880_volume_init_verbs,
3937 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003938 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3939 .dac_nids = alc880_6st_dac_nids,
3940 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003941 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3942 .channel_mode = alc880_sixstack_modes,
3943 .input_mux = &alc880_6stack_capture_source,
3944 },
3945 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 .init_verbs = { alc880_volume_init_verbs,
3948 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003949 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003950 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3951 .dac_nids = alc880_w810_dac_nids,
3952 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003953 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3954 .channel_mode = alc880_w810_modes,
3955 .input_mux = &alc880_capture_source,
3956 },
3957 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003959 .init_verbs = { alc880_volume_init_verbs,
3960 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003961 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3962 .dac_nids = alc880_z71v_dac_nids,
3963 .dig_out_nid = ALC880_DIGOUT_NID,
3964 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3966 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003967 .input_mux = &alc880_capture_source,
3968 },
3969 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003971 .init_verbs = { alc880_volume_init_verbs,
3972 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3974 .dac_nids = alc880_f1734_dac_nids,
3975 .hp_nid = 0x02,
3976 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3977 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003978 .input_mux = &alc880_f1734_capture_source,
3979 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003980 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003981 },
3982 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003983 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003984 .init_verbs = { alc880_volume_init_verbs,
3985 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986 alc880_gpio1_init_verbs },
3987 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3988 .dac_nids = alc880_asus_dac_nids,
3989 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3990 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003991 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003992 .input_mux = &alc880_capture_source,
3993 },
3994 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 .init_verbs = { alc880_volume_init_verbs,
3997 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998 alc880_gpio1_init_verbs },
3999 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4000 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4003 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004004 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004005 .input_mux = &alc880_capture_source,
4006 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 [ALC880_ASUS_DIG2] = {
4008 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004009 .init_verbs = { alc880_volume_init_verbs,
4010 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 alc880_gpio2_init_verbs }, /* use GPIO2 */
4012 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4013 .dac_nids = alc880_asus_dac_nids,
4014 .dig_out_nid = ALC880_DIGOUT_NID,
4015 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4016 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004017 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004018 .input_mux = &alc880_capture_source,
4019 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004022 .init_verbs = { alc880_volume_init_verbs,
4023 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 alc880_gpio1_init_verbs },
4025 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4026 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004027 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4029 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004030 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004031 .input_mux = &alc880_capture_source,
4032 },
4033 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004034 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004035 .init_verbs = { alc880_volume_init_verbs,
4036 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4038 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004040 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4041 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004042 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 .input_mux = &alc880_capture_source,
4044 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004045 [ALC880_UNIWILL] = {
4046 .mixers = { alc880_uniwill_mixer },
4047 .init_verbs = { alc880_volume_init_verbs,
4048 alc880_uniwill_init_verbs },
4049 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4050 .dac_nids = alc880_asus_dac_nids,
4051 .dig_out_nid = ALC880_DIGOUT_NID,
4052 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4053 .channel_mode = alc880_threestack_modes,
4054 .need_dac_fix = 1,
4055 .input_mux = &alc880_capture_source,
4056 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004057 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004058 },
4059 [ALC880_UNIWILL_P53] = {
4060 .mixers = { alc880_uniwill_p53_mixer },
4061 .init_verbs = { alc880_volume_init_verbs,
4062 alc880_uniwill_p53_init_verbs },
4063 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4064 .dac_nids = alc880_asus_dac_nids,
4065 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004066 .channel_mode = alc880_threestack_modes,
4067 .input_mux = &alc880_capture_source,
4068 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004069 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004070 },
4071 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004072 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004073 .init_verbs = { alc880_volume_init_verbs,
4074 alc880_uniwill_p53_init_verbs,
4075 alc880_beep_init_verbs },
4076 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4077 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004078 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004079 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4080 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004081 .input_mux = &alc880_capture_source,
4082 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004083 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004084 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004085 [ALC880_CLEVO] = {
4086 .mixers = { alc880_three_stack_mixer },
4087 .init_verbs = { alc880_volume_init_verbs,
4088 alc880_pin_clevo_init_verbs },
4089 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4090 .dac_nids = alc880_dac_nids,
4091 .hp_nid = 0x03,
4092 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4093 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004094 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004095 .input_mux = &alc880_capture_source,
4096 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004097 [ALC880_LG] = {
4098 .mixers = { alc880_lg_mixer },
4099 .init_verbs = { alc880_volume_init_verbs,
4100 alc880_lg_init_verbs },
4101 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4102 .dac_nids = alc880_lg_dac_nids,
4103 .dig_out_nid = ALC880_DIGOUT_NID,
4104 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4105 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004106 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004107 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004108 .unsol_event = alc_automute_amp_unsol_event,
4109 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004110#ifdef CONFIG_SND_HDA_POWER_SAVE
4111 .loopbacks = alc880_lg_loopbacks,
4112#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004113 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004114 [ALC880_LG_LW] = {
4115 .mixers = { alc880_lg_lw_mixer },
4116 .init_verbs = { alc880_volume_init_verbs,
4117 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004118 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004119 .dac_nids = alc880_dac_nids,
4120 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004121 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4122 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004123 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004124 .unsol_event = alc_automute_amp_unsol_event,
4125 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004126 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004127 [ALC880_MEDION_RIM] = {
4128 .mixers = { alc880_medion_rim_mixer },
4129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_medion_rim_init_verbs,
4131 alc_gpio2_init_verbs },
4132 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4133 .dac_nids = alc880_dac_nids,
4134 .dig_out_nid = ALC880_DIGOUT_NID,
4135 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4136 .channel_mode = alc880_2_jack_modes,
4137 .input_mux = &alc880_medion_rim_capture_source,
4138 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004139 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004140 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004141#ifdef CONFIG_SND_DEBUG
4142 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 .mixers = { alc880_test_mixer },
4144 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4146 .dac_nids = alc880_test_dac_nids,
4147 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4149 .channel_mode = alc880_test_modes,
4150 .input_mux = &alc880_test_capture_source,
4151 },
4152#endif
4153};
4154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155/*
4156 * Automatic parse of I/O pins from the BIOS configuration
4157 */
4158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159enum {
4160 ALC_CTL_WIDGET_VOL,
4161 ALC_CTL_WIDGET_MUTE,
4162 ALC_CTL_BIND_MUTE,
4163};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004164static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004165 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4166 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004167 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168};
4169
4170/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171static int add_control(struct alc_spec *spec, int type, const char *name,
4172 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004174 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175
Takashi Iwai603c4012008-07-30 15:01:44 +02004176 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4177 knew = snd_array_new(&spec->kctls);
4178 if (!knew)
4179 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004181 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004182 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 return -ENOMEM;
4184 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185 return 0;
4186}
4187
4188#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4189#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4190#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4191#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4192#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4193#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4194#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4195#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4196#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4197#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4198#define ALC880_PIN_CD_NID 0x1c
4199
4200/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004201static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4202 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004203{
4204 hda_nid_t nid;
4205 int assigned[4];
4206 int i, j;
4207
4208 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004209 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210
4211 /* check the pins hardwired to audio widget */
4212 for (i = 0; i < cfg->line_outs; i++) {
4213 nid = cfg->line_out_pins[i];
4214 if (alc880_is_fixed_pin(nid)) {
4215 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004216 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 assigned[idx] = 1;
4218 }
4219 }
4220 /* left pins can be connect to any audio widget */
4221 for (i = 0; i < cfg->line_outs; i++) {
4222 nid = cfg->line_out_pins[i];
4223 if (alc880_is_fixed_pin(nid))
4224 continue;
4225 /* search for an empty channel */
4226 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 if (!assigned[j]) {
4228 spec->multiout.dac_nids[i] =
4229 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 assigned[j] = 1;
4231 break;
4232 }
4233 }
4234 }
4235 spec->multiout.num_dacs = cfg->line_outs;
4236 return 0;
4237}
4238
4239/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004240static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4241 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242{
4243 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 static const char *chname[4] = {
4245 "Front", "Surround", NULL /*CLFE*/, "Side"
4246 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004247 hda_nid_t nid;
4248 int i, err;
4249
4250 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004251 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 continue;
4253 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4254 if (i == 2) {
4255 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4257 "Center Playback Volume",
4258 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4259 HDA_OUTPUT));
4260 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004261 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4263 "LFE Playback Volume",
4264 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4265 HDA_OUTPUT));
4266 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268 err = add_control(spec, ALC_CTL_BIND_MUTE,
4269 "Center Playback Switch",
4270 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4271 HDA_INPUT));
4272 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004274 err = add_control(spec, ALC_CTL_BIND_MUTE,
4275 "LFE Playback Switch",
4276 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4277 HDA_INPUT));
4278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 return err;
4280 } else {
4281 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4283 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4284 HDA_OUTPUT));
4285 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004286 return err;
4287 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4289 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4290 HDA_INPUT));
4291 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 return err;
4293 }
4294 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 return 0;
4296}
4297
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004298/* add playback controls for speaker and HP outputs */
4299static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4300 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301{
4302 hda_nid_t nid;
4303 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004304 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return 0;
4308
4309 if (alc880_is_fixed_pin(pin)) {
4310 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004311 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004314 else
4315 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 /* control HP volume/switch on the output mixer amp */
4317 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004318 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004319 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4320 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4321 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004323 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004324 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4325 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4326 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327 return err;
4328 } else if (alc880_is_multi_pin(pin)) {
4329 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004331 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004332 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4333 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4334 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 return err;
4336 }
4337 return 0;
4338}
4339
4340/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004341static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4342 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004343 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344{
4345 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347
4348 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4350 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4351 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 return err;
4353 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004354 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4355 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4356 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 return err;
4358 return 0;
4359}
4360
4361/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004362static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004365 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004366 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367
4368 for (i = 0; i < AUTO_PIN_LAST; i++) {
4369 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004370 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004371 err = new_analog_input(spec, cfg->input_pins[i],
4372 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 if (err < 0)
4375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004376 imux->items[imux->num_items].label =
4377 auto_pin_cfg_labels[i];
4378 imux->items[imux->num_items].index =
4379 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380 imux->num_items++;
4381 }
4382 }
4383 return 0;
4384}
4385
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004386static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4387 unsigned int pin_type)
4388{
4389 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4390 pin_type);
4391 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004392 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4393 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004394}
4395
Kailang Yangdf694da2005-12-05 19:42:22 +01004396static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4397 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 int dac_idx)
4399{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004400 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 /* need the manual connection? */
4402 if (alc880_is_multi_pin(nid)) {
4403 struct alc_spec *spec = codec->spec;
4404 int idx = alc880_multi_pin_idx(nid);
4405 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4406 AC_VERB_SET_CONNECT_SEL,
4407 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4408 }
4409}
4410
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004411static int get_pin_type(int line_out_type)
4412{
4413 if (line_out_type == AUTO_PIN_HP_OUT)
4414 return PIN_HP;
4415 else
4416 return PIN_OUT;
4417}
4418
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419static void alc880_auto_init_multi_out(struct hda_codec *codec)
4420{
4421 struct alc_spec *spec = codec->spec;
4422 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 for (i = 0; i < spec->autocfg.line_outs; i++) {
4425 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004426 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4427 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 }
4429}
4430
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004431static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004432{
4433 struct alc_spec *spec = codec->spec;
4434 hda_nid_t pin;
4435
Takashi Iwai82bc9552006-03-21 11:24:42 +01004436 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004437 if (pin) /* connect to front */
4438 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004439 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 if (pin) /* connect to front */
4441 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4442}
4443
4444static void alc880_auto_init_analog_input(struct hda_codec *codec)
4445{
4446 struct alc_spec *spec = codec->spec;
4447 int i;
4448
4449 for (i = 0; i < AUTO_PIN_LAST; i++) {
4450 hda_nid_t nid = spec->autocfg.input_pins[i];
4451 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004452 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004453 if (nid != ALC880_PIN_CD_NID &&
4454 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 snd_hda_codec_write(codec, nid, 0,
4456 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 AMP_OUT_MUTE);
4458 }
4459 }
4460}
4461
4462/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004463/* return 1 if successful, 0 if the proper config is not found,
4464 * or a negative error code
4465 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466static int alc880_parse_auto_config(struct hda_codec *codec)
4467{
4468 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004469 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004471
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4473 alc880_ignore);
4474 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004478
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4480 if (err < 0)
4481 return err;
4482 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4483 if (err < 0)
4484 return err;
4485 err = alc880_auto_create_extra_out(spec,
4486 spec->autocfg.speaker_pins[0],
4487 "Speaker");
4488 if (err < 0)
4489 return err;
4490 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4491 "Headphone");
4492 if (err < 0)
4493 return err;
4494 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4495 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 return err;
4497
4498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4499
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004500 /* check multiple SPDIF-out (for recent codecs) */
4501 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4502 hda_nid_t dig_nid;
4503 err = snd_hda_get_connections(codec,
4504 spec->autocfg.dig_out_pins[i],
4505 &dig_nid, 1);
4506 if (err < 0)
4507 continue;
4508 if (!i)
4509 spec->multiout.dig_out_nid = dig_nid;
4510 else {
4511 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4512 spec->slave_dig_outs[i - 1] = dig_nid;
4513 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4514 break;
4515 }
4516 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004517 if (spec->autocfg.dig_in_pin)
4518 spec->dig_in_nid = ALC880_DIGIN_NID;
4519
Takashi Iwai603c4012008-07-30 15:01:44 +02004520 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004521 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004522
Takashi Iwaid88897e2008-10-31 15:01:37 +01004523 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004524
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004526 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004528 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4529
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 return 1;
4531}
4532
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004533/* additional initialization for auto-configuration model */
4534static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004535{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004536 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004538 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004540 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004541 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004542}
4543
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004544static void set_capture_mixer(struct alc_spec *spec)
4545{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004546 static struct snd_kcontrol_new *caps[2][3] = {
4547 { alc_capture_mixer_nosrc1,
4548 alc_capture_mixer_nosrc2,
4549 alc_capture_mixer_nosrc3 },
4550 { alc_capture_mixer1,
4551 alc_capture_mixer2,
4552 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004553 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004554 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4555 int mux;
4556 if (spec->input_mux && spec->input_mux->num_items > 1)
4557 mux = 1;
4558 else
4559 mux = 0;
4560 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4561 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004562}
4563
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004564#define set_beep_amp(spec, nid, idx, dir) \
4565 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4566
4567/*
4568 * OK, here we have finally the patch for ALC880
4569 */
4570
Linus Torvalds1da177e2005-04-16 15:20:36 -07004571static int patch_alc880(struct hda_codec *codec)
4572{
4573 struct alc_spec *spec;
4574 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004575 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004578 if (spec == NULL)
4579 return -ENOMEM;
4580
4581 codec->spec = spec;
4582
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4584 alc880_models,
4585 alc880_cfg_tbl);
4586 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004587 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4588 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004589 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004590 }
4591
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004592 if (board_config == ALC880_AUTO) {
4593 /* automatic parse from the BIOS config */
4594 err = alc880_parse_auto_config(codec);
4595 if (err < 0) {
4596 alc_free(codec);
4597 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004598 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004599 printk(KERN_INFO
4600 "hda_codec: Cannot set up configuration "
4601 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004602 board_config = ALC880_3ST;
4603 }
4604 }
4605
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004606 err = snd_hda_attach_beep_device(codec, 0x1);
4607 if (err < 0) {
4608 alc_free(codec);
4609 return err;
4610 }
4611
Kailang Yangdf694da2005-12-05 19:42:22 +01004612 if (board_config != ALC880_AUTO)
4613 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004614
Linus Torvalds1da177e2005-04-16 15:20:36 -07004615 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4616 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004617 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004618
Linus Torvalds1da177e2005-04-16 15:20:36 -07004619 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4620 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004622 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004624 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004626 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004627 if (wcap != AC_WID_AUD_IN) {
4628 spec->adc_nids = alc880_adc_nids_alt;
4629 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 } else {
4631 spec->adc_nids = alc880_adc_nids;
4632 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 }
4634 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004635 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004636 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004637
Takashi Iwai2134ea42008-01-10 16:53:55 +01004638 spec->vmaster_nid = 0x0c;
4639
Linus Torvalds1da177e2005-04-16 15:20:36 -07004640 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004642 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004643#ifdef CONFIG_SND_HDA_POWER_SAVE
4644 if (!spec->loopback.amplist)
4645 spec->loopback.amplist = alc880_loopbacks;
4646#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004647 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004648
4649 return 0;
4650}
4651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652
Linus Torvalds1da177e2005-04-16 15:20:36 -07004653/*
4654 * ALC260 support
4655 */
4656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657static hda_nid_t alc260_dac_nids[1] = {
4658 /* front */
4659 0x02,
4660};
4661
4662static hda_nid_t alc260_adc_nids[1] = {
4663 /* ADC0 */
4664 0x04,
4665};
4666
Kailang Yangdf694da2005-12-05 19:42:22 +01004667static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004668 /* ADC1 */
4669 0x05,
4670};
4671
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004672/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4673 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4674 */
4675static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004676 /* ADC0, ADC1 */
4677 0x04, 0x05
4678};
4679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680#define ALC260_DIGOUT_NID 0x03
4681#define ALC260_DIGIN_NID 0x06
4682
4683static struct hda_input_mux alc260_capture_source = {
4684 .num_items = 4,
4685 .items = {
4686 { "Mic", 0x0 },
4687 { "Front Mic", 0x1 },
4688 { "Line", 0x2 },
4689 { "CD", 0x4 },
4690 },
4691};
4692
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004693/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004694 * headphone jack and the internal CD lines since these are the only pins at
4695 * which audio can appear. For flexibility, also allow the option of
4696 * recording the mixer output on the second ADC (ADC0 doesn't have a
4697 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004698 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004699static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4700 {
4701 .num_items = 3,
4702 .items = {
4703 { "Mic/Line", 0x0 },
4704 { "CD", 0x4 },
4705 { "Headphone", 0x2 },
4706 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004707 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004708 {
4709 .num_items = 4,
4710 .items = {
4711 { "Mic/Line", 0x0 },
4712 { "CD", 0x4 },
4713 { "Headphone", 0x2 },
4714 { "Mixer", 0x5 },
4715 },
4716 },
4717
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004718};
4719
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004720/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4721 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004722 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004723static struct hda_input_mux alc260_acer_capture_sources[2] = {
4724 {
4725 .num_items = 4,
4726 .items = {
4727 { "Mic", 0x0 },
4728 { "Line", 0x2 },
4729 { "CD", 0x4 },
4730 { "Headphone", 0x5 },
4731 },
4732 },
4733 {
4734 .num_items = 5,
4735 .items = {
4736 { "Mic", 0x0 },
4737 { "Line", 0x2 },
4738 { "CD", 0x4 },
4739 { "Headphone", 0x6 },
4740 { "Mixer", 0x5 },
4741 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004742 },
4743};
Michael Schwingencc959482009-02-22 18:58:45 +01004744
4745/* Maxdata Favorit 100XS */
4746static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4747 {
4748 .num_items = 2,
4749 .items = {
4750 { "Line/Mic", 0x0 },
4751 { "CD", 0x4 },
4752 },
4753 },
4754 {
4755 .num_items = 3,
4756 .items = {
4757 { "Line/Mic", 0x0 },
4758 { "CD", 0x4 },
4759 { "Mixer", 0x5 },
4760 },
4761 },
4762};
4763
Linus Torvalds1da177e2005-04-16 15:20:36 -07004764/*
4765 * This is just place-holder, so there's something for alc_build_pcms to look
4766 * at when it calculates the maximum number of channels. ALC260 has no mixer
4767 * element which allows changing the channel mode, so the verb list is
4768 * never used.
4769 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004770static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 { 2, NULL },
4772};
4773
Kailang Yangdf694da2005-12-05 19:42:22 +01004774
4775/* Mixer combinations
4776 *
4777 * basic: base_output + input + pc_beep + capture
4778 * HP: base_output + input + capture_alt
4779 * HP_3013: hp_3013 + input + capture
4780 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004781 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004782 */
4783
4784static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004785 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004786 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4788 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4789 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4790 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4791 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792};
Kailang Yangdf694da2005-12-05 19:42:22 +01004793
4794static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004795 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4796 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4798 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4800 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004803 { } /* end */
4804};
4805
Takashi Iwaibec15c32008-01-28 18:16:30 +01004806/* update HP, line and mono out pins according to the master switch */
4807static void alc260_hp_master_update(struct hda_codec *codec,
4808 hda_nid_t hp, hda_nid_t line,
4809 hda_nid_t mono)
4810{
4811 struct alc_spec *spec = codec->spec;
4812 unsigned int val = spec->master_sw ? PIN_HP : 0;
4813 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004814 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004815 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004816 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004817 val);
4818 /* mono (speaker) depending on the HP jack sense */
4819 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004820 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004821 val);
4822}
4823
4824static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4825 struct snd_ctl_elem_value *ucontrol)
4826{
4827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4828 struct alc_spec *spec = codec->spec;
4829 *ucontrol->value.integer.value = spec->master_sw;
4830 return 0;
4831}
4832
4833static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4834 struct snd_ctl_elem_value *ucontrol)
4835{
4836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4837 struct alc_spec *spec = codec->spec;
4838 int val = !!*ucontrol->value.integer.value;
4839 hda_nid_t hp, line, mono;
4840
4841 if (val == spec->master_sw)
4842 return 0;
4843 spec->master_sw = val;
4844 hp = (kcontrol->private_value >> 16) & 0xff;
4845 line = (kcontrol->private_value >> 8) & 0xff;
4846 mono = kcontrol->private_value & 0xff;
4847 alc260_hp_master_update(codec, hp, line, mono);
4848 return 1;
4849}
4850
4851static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4852 {
4853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4854 .name = "Master Playback Switch",
4855 .info = snd_ctl_boolean_mono_info,
4856 .get = alc260_hp_master_sw_get,
4857 .put = alc260_hp_master_sw_put,
4858 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4859 },
4860 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4861 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4863 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4864 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4865 HDA_OUTPUT),
4866 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4867 { } /* end */
4868};
4869
4870static struct hda_verb alc260_hp_unsol_verbs[] = {
4871 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4872 {},
4873};
4874
4875static void alc260_hp_automute(struct hda_codec *codec)
4876{
4877 struct alc_spec *spec = codec->spec;
4878 unsigned int present;
4879
4880 present = snd_hda_codec_read(codec, 0x10, 0,
4881 AC_VERB_GET_PIN_SENSE, 0);
4882 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4883 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4884}
4885
4886static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4887{
4888 if ((res >> 26) == ALC880_HP_EVENT)
4889 alc260_hp_automute(codec);
4890}
4891
Kailang Yangdf694da2005-12-05 19:42:22 +01004892static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004893 {
4894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4895 .name = "Master Playback Switch",
4896 .info = snd_ctl_boolean_mono_info,
4897 .get = alc260_hp_master_sw_get,
4898 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004899 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004900 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004901 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4902 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4903 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4904 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004907 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4908 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004909 { } /* end */
4910};
4911
Kailang Yang3f878302008-08-26 13:02:23 +02004912static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4913 .ops = &snd_hda_bind_vol,
4914 .values = {
4915 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4916 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4917 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4918 0
4919 },
4920};
4921
4922static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4923 .ops = &snd_hda_bind_sw,
4924 .values = {
4925 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4926 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4927 0
4928 },
4929};
4930
4931static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4932 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4933 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4934 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4936 { } /* end */
4937};
4938
Takashi Iwaibec15c32008-01-28 18:16:30 +01004939static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4941 {},
4942};
4943
4944static void alc260_hp_3013_automute(struct hda_codec *codec)
4945{
4946 struct alc_spec *spec = codec->spec;
4947 unsigned int present;
4948
4949 present = snd_hda_codec_read(codec, 0x15, 0,
4950 AC_VERB_GET_PIN_SENSE, 0);
4951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004952 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004953}
4954
4955static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4956 unsigned int res)
4957{
4958 if ((res >> 26) == ALC880_HP_EVENT)
4959 alc260_hp_3013_automute(codec);
4960}
4961
Kailang Yang3f878302008-08-26 13:02:23 +02004962static void alc260_hp_3012_automute(struct hda_codec *codec)
4963{
4964 unsigned int present, bits;
4965
4966 present = snd_hda_codec_read(codec, 0x10, 0,
4967 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4968
4969 bits = present ? 0 : PIN_OUT;
4970 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4971 bits);
4972 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4973 bits);
4974 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4975 bits);
4976}
4977
4978static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4979 unsigned int res)
4980{
4981 if ((res >> 26) == ALC880_HP_EVENT)
4982 alc260_hp_3012_automute(codec);
4983}
4984
4985/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004986 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4987 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004988static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004990 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004991 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004992 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4993 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004996 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4998 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004999 { } /* end */
5000};
5001
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005002/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5003 * versions of the ALC260 don't act on requests to enable mic bias from NID
5004 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5005 * datasheet doesn't mention this restriction. At this stage it's not clear
5006 * whether this behaviour is intentional or is a hardware bug in chip
5007 * revisions available in early 2006. Therefore for now allow the
5008 * "Headphone Jack Mode" control to span all choices, but if it turns out
5009 * that the lack of mic bias for this NID is intentional we could change the
5010 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5011 *
5012 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5013 * don't appear to make the mic bias available from the "line" jack, even
5014 * though the NID used for this jack (0x14) can supply it. The theory is
5015 * that perhaps Acer have included blocking capacitors between the ALC260
5016 * and the output jack. If this turns out to be the case for all such
5017 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5018 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005019 *
5020 * The C20x Tablet series have a mono internal speaker which is controlled
5021 * via the chip's Mono sum widget and pin complex, so include the necessary
5022 * controls for such models. On models without a "mono speaker" the control
5023 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005024 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005025static struct snd_kcontrol_new alc260_acer_mixer[] = {
5026 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5027 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005028 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005029 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005030 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005031 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005032 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005033 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5034 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5036 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5037 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5038 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5039 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5040 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005041 { } /* end */
5042};
5043
Michael Schwingencc959482009-02-22 18:58:45 +01005044/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5045 */
5046static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5047 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5048 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5049 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5050 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5051 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5052 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5053 { } /* end */
5054};
5055
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005056/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5057 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5058 */
5059static struct snd_kcontrol_new alc260_will_mixer[] = {
5060 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5061 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5063 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5064 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5065 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5066 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5067 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5068 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5069 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005070 { } /* end */
5071};
5072
5073/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5074 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5075 */
5076static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5077 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5078 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5080 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5081 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5082 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5083 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5084 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5085 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5086 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5087 { } /* end */
5088};
5089
Kailang Yangdf694da2005-12-05 19:42:22 +01005090/*
5091 * initialization verbs
5092 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005093static struct hda_verb alc260_init_verbs[] = {
5094 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005097 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005098 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005100 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005102 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005105 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005107 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005108 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005109 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005110 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005111 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5112 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005114 /* set connection select to line in (default select for this ADC) */
5115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005116 /* mute capture amp left and right */
5117 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5118 /* set connection select to line in (default select for this ADC) */
5119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005120 /* set vol=0 Line-Out mixer amp left and right */
5121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 /* unmute pin widget amp left and right (no gain on this amp) */
5123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5124 /* set vol=0 HP mixer amp left and right */
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5126 /* unmute pin widget amp left and right (no gain on this amp) */
5127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* set vol=0 Mono mixer amp left and right */
5129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5130 /* unmute pin widget amp left and right (no gain on this amp) */
5131 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5132 /* unmute LINE-2 out pin */
5133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5135 * Line In 2 = 0x03
5136 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005137 /* mute analog inputs */
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005143 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005144 /* mute Front out path */
5145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5147 /* mute Headphone out path */
5148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5150 /* mute Mono out path */
5151 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005153 { }
5154};
5155
Takashi Iwai474167d2006-05-17 17:17:43 +02005156#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005157static struct hda_verb alc260_hp_init_verbs[] = {
5158 /* Headphone and output */
5159 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5160 /* mono output */
5161 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5163 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5164 /* Mic2 (front panel) pin widget for input and vref at 80% */
5165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5166 /* Line In pin widget for input */
5167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5168 /* Line-2 pin widget for output */
5169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5170 /* CD pin widget for input */
5171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5172 /* unmute amp left and right */
5173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5174 /* set connection select to line in (default select for this ADC) */
5175 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5176 /* unmute Line-Out mixer amp left and right (volume = 0) */
5177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5178 /* mute pin widget amp left and right (no gain on this amp) */
5179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5180 /* unmute HP mixer amp left and right (volume = 0) */
5181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5182 /* mute pin widget amp left and right (no gain on this amp) */
5183 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005184 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5185 * Line In 2 = 0x03
5186 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005187 /* mute analog inputs */
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5194 /* Unmute Front out path */
5195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5197 /* Unmute Headphone out path */
5198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5200 /* Unmute Mono out path */
5201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5203 { }
5204};
Takashi Iwai474167d2006-05-17 17:17:43 +02005205#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005206
5207static struct hda_verb alc260_hp_3013_init_verbs[] = {
5208 /* Line out and output */
5209 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5210 /* mono output */
5211 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5212 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5213 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5214 /* Mic2 (front panel) pin widget for input and vref at 80% */
5215 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5216 /* Line In pin widget for input */
5217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5218 /* Headphone pin widget for output */
5219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5220 /* CD pin widget for input */
5221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5222 /* unmute amp left and right */
5223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5224 /* set connection select to line in (default select for this ADC) */
5225 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5226 /* unmute Line-Out mixer amp left and right (volume = 0) */
5227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5228 /* mute pin widget amp left and right (no gain on this amp) */
5229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5230 /* unmute HP mixer amp left and right (volume = 0) */
5231 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5232 /* mute pin widget amp left and right (no gain on this amp) */
5233 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5235 * Line In 2 = 0x03
5236 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005237 /* mute analog inputs */
5238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005243 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5244 /* Unmute Front out path */
5245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5247 /* Unmute Headphone out path */
5248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5250 /* Unmute Mono out path */
5251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5253 { }
5254};
5255
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005256/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005257 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5258 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005259 */
5260static struct hda_verb alc260_fujitsu_init_verbs[] = {
5261 /* Disable all GPIOs */
5262 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5263 /* Internal speaker is connected to headphone pin */
5264 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5265 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005267 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5268 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5269 /* Ensure all other unused pins are disabled and muted. */
5270 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005272 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005273 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005274 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005275 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005278
Jonathan Woithef7ace402006-02-28 11:46:14 +01005279 /* Disable digital (SPDIF) pins */
5280 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5281 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005282
Kailang Yangea1fb292008-08-26 12:58:38 +02005283 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005284 * when acting as an output.
5285 */
5286 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5287
5288 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005298
Jonathan Woithef7ace402006-02-28 11:46:14 +01005299 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5301 /* Unmute Line1 pin widget output buffer since it starts as an output.
5302 * If the pin mode is changed by the user the pin mode control will
5303 * take care of enabling the pin's input/output buffers as needed.
5304 * Therefore there's no need to enable the input buffer at this
5305 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005306 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005308 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005309 * mixer ctrl)
5310 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005311 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005312
Jonathan Woithef7ace402006-02-28 11:46:14 +01005313 /* Mute capture amp left and right */
5314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005315 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005316 * in (on mic1 pin)
5317 */
5318 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005319
Jonathan Woithef7ace402006-02-28 11:46:14 +01005320 /* Do the same for the second ADC: mute capture input amp and
5321 * set ADC connection to line in (on mic1 pin)
5322 */
5323 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5324 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005325
Jonathan Woithef7ace402006-02-28 11:46:14 +01005326 /* Mute all inputs to mixer widget (even unconnected ones) */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005335
5336 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005337};
5338
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005339/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5340 * similar laptops (adapted from Fujitsu init verbs).
5341 */
5342static struct hda_verb alc260_acer_init_verbs[] = {
5343 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5344 * the headphone jack. Turn this on and rely on the standard mute
5345 * methods whenever the user wants to turn these outputs off.
5346 */
5347 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5348 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5349 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5350 /* Internal speaker/Headphone jack is connected to Line-out pin */
5351 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5352 /* Internal microphone/Mic jack is connected to Mic1 pin */
5353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5354 /* Line In jack is connected to Line1 pin */
5355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005356 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5357 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005358 /* Ensure all other unused pins are disabled and muted. */
5359 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005361 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5362 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5365 /* Disable digital (SPDIF) pins */
5366 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5367 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5368
Kailang Yangea1fb292008-08-26 12:58:38 +02005369 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005370 * bus when acting as outputs.
5371 */
5372 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5373 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5374
5375 /* Start with output sum widgets muted and their output gains at min */
5376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5382 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5385
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005386 /* Unmute Line-out pin widget amp left and right
5387 * (no equiv mixer ctrl)
5388 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005390 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5391 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005392 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5393 * inputs. If the pin mode is changed by the user the pin mode control
5394 * will take care of enabling the pin's input/output buffers as needed.
5395 * Therefore there's no need to enable the input buffer at this
5396 * stage.
5397 */
5398 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5400
5401 /* Mute capture amp left and right */
5402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5403 /* Set ADC connection select to match default mixer setting - mic
5404 * (on mic1 pin)
5405 */
5406 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5407
5408 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005409 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005410 */
5411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005412 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005413
5414 /* Mute all inputs to mixer widget (even unconnected ones) */
5415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5423
5424 { }
5425};
5426
Michael Schwingencc959482009-02-22 18:58:45 +01005427/* Initialisation sequence for Maxdata Favorit 100XS
5428 * (adapted from Acer init verbs).
5429 */
5430static struct hda_verb alc260_favorit100_init_verbs[] = {
5431 /* GPIO 0 enables the output jack.
5432 * Turn this on and rely on the standard mute
5433 * methods whenever the user wants to turn these outputs off.
5434 */
5435 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5436 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5437 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5438 /* Line/Mic input jack is connected to Mic1 pin */
5439 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5440 /* Ensure all other unused pins are disabled and muted. */
5441 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5442 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5443 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5444 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5446 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 /* Disable digital (SPDIF) pins */
5452 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5453 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5454
5455 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5456 * bus when acting as outputs.
5457 */
5458 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5459 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5460
5461 /* Start with output sum widgets muted and their output gains at min */
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5471
5472 /* Unmute Line-out pin widget amp left and right
5473 * (no equiv mixer ctrl)
5474 */
5475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5476 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5477 * inputs. If the pin mode is changed by the user the pin mode control
5478 * will take care of enabling the pin's input/output buffers as needed.
5479 * Therefore there's no need to enable the input buffer at this
5480 * stage.
5481 */
5482 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5483
5484 /* Mute capture amp left and right */
5485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 /* Set ADC connection select to match default mixer setting - mic
5487 * (on mic1 pin)
5488 */
5489 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5490
5491 /* Do similar with the second ADC: mute capture input amp and
5492 * set ADC connection to mic to match ALSA's default state.
5493 */
5494 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5496
5497 /* Mute all inputs to mixer widget (even unconnected ones) */
5498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5506
5507 { }
5508};
5509
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005510static struct hda_verb alc260_will_verbs[] = {
5511 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5512 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5513 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5514 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5515 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5516 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5517 {}
5518};
5519
5520static struct hda_verb alc260_replacer_672v_verbs[] = {
5521 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5522 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5523 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5524
5525 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5526 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5527 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5528
5529 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5530 {}
5531};
5532
5533/* toggle speaker-output according to the hp-jack state */
5534static void alc260_replacer_672v_automute(struct hda_codec *codec)
5535{
5536 unsigned int present;
5537
5538 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5539 present = snd_hda_codec_read(codec, 0x0f, 0,
5540 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5541 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005542 snd_hda_codec_write_cache(codec, 0x01, 0,
5543 AC_VERB_SET_GPIO_DATA, 1);
5544 snd_hda_codec_write_cache(codec, 0x0f, 0,
5545 AC_VERB_SET_PIN_WIDGET_CONTROL,
5546 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005547 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005548 snd_hda_codec_write_cache(codec, 0x01, 0,
5549 AC_VERB_SET_GPIO_DATA, 0);
5550 snd_hda_codec_write_cache(codec, 0x0f, 0,
5551 AC_VERB_SET_PIN_WIDGET_CONTROL,
5552 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005553 }
5554}
5555
5556static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5557 unsigned int res)
5558{
5559 if ((res >> 26) == ALC880_HP_EVENT)
5560 alc260_replacer_672v_automute(codec);
5561}
5562
Kailang Yang3f878302008-08-26 13:02:23 +02005563static struct hda_verb alc260_hp_dc7600_verbs[] = {
5564 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5565 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5566 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5567 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5568 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5570 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5571 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5572 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5573 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5574 {}
5575};
5576
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005577/* Test configuration for debugging, modelled after the ALC880 test
5578 * configuration.
5579 */
5580#ifdef CONFIG_SND_DEBUG
5581static hda_nid_t alc260_test_dac_nids[1] = {
5582 0x02,
5583};
5584static hda_nid_t alc260_test_adc_nids[2] = {
5585 0x04, 0x05,
5586};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005587/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005588 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005589 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005590 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005591static struct hda_input_mux alc260_test_capture_sources[2] = {
5592 {
5593 .num_items = 7,
5594 .items = {
5595 { "MIC1 pin", 0x0 },
5596 { "MIC2 pin", 0x1 },
5597 { "LINE1 pin", 0x2 },
5598 { "LINE2 pin", 0x3 },
5599 { "CD pin", 0x4 },
5600 { "LINE-OUT pin", 0x5 },
5601 { "HP-OUT pin", 0x6 },
5602 },
5603 },
5604 {
5605 .num_items = 8,
5606 .items = {
5607 { "MIC1 pin", 0x0 },
5608 { "MIC2 pin", 0x1 },
5609 { "LINE1 pin", 0x2 },
5610 { "LINE2 pin", 0x3 },
5611 { "CD pin", 0x4 },
5612 { "Mixer", 0x5 },
5613 { "LINE-OUT pin", 0x6 },
5614 { "HP-OUT pin", 0x7 },
5615 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005616 },
5617};
5618static struct snd_kcontrol_new alc260_test_mixer[] = {
5619 /* Output driver widgets */
5620 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5621 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5622 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5623 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5624 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5625 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5626
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005627 /* Modes for retasking pin widgets
5628 * Note: the ALC260 doesn't seem to act on requests to enable mic
5629 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5630 * mention this restriction. At this stage it's not clear whether
5631 * this behaviour is intentional or is a hardware bug in chip
5632 * revisions available at least up until early 2006. Therefore for
5633 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5634 * choices, but if it turns out that the lack of mic bias for these
5635 * NIDs is intentional we could change their modes from
5636 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5637 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005638 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5639 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5640 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5641 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5642 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5643 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5644
5645 /* Loopback mixer controls */
5646 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5647 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5648 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5649 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5650 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5651 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5652 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5653 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5654 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5655 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005656 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5657 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5658 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5659 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005660
5661 /* Controls for GPIO pins, assuming they are configured as outputs */
5662 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5663 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5664 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5665 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5666
Jonathan Woithe92621f12006-02-28 11:47:47 +01005667 /* Switches to allow the digital IO pins to be enabled. The datasheet
5668 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005669 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005670 */
5671 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5672 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5673
Jonathan Woithef8225f62008-01-08 12:16:54 +01005674 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5675 * this output to turn on an external amplifier.
5676 */
5677 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5678 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5679
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005680 { } /* end */
5681};
5682static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005683 /* Enable all GPIOs as outputs with an initial value of 0 */
5684 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5685 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5686 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5687
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005688 /* Enable retasking pins as output, initially without power amp */
5689 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5690 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5693 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5694 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5695
Jonathan Woithe92621f12006-02-28 11:47:47 +01005696 /* Disable digital (SPDIF) pins initially, but users can enable
5697 * them via a mixer switch. In the case of SPDIF-out, this initverb
5698 * payload also sets the generation to 0, output to be in "consumer"
5699 * PCM format, copyright asserted, no pre-emphasis and no validity
5700 * control.
5701 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005702 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5703 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5704
Kailang Yangea1fb292008-08-26 12:58:38 +02005705 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005706 * OUT1 sum bus when acting as an output.
5707 */
5708 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5709 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5710 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5711 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5712
5713 /* Start with output sum widgets muted and their output gains at min */
5714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5720 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5722 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5723
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005724 /* Unmute retasking pin widget output buffers since the default
5725 * state appears to be output. As the pin mode is changed by the
5726 * user the pin mode control will take care of enabling the pin's
5727 * input/output buffers as needed.
5728 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005729 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5733 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5734 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5735 /* Also unmute the mono-out pin widget */
5736 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5737
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005738 /* Mute capture amp left and right */
5739 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005740 /* Set ADC connection select to match default mixer setting (mic1
5741 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005742 */
5743 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5744
5745 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005746 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005747 */
5748 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5749 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5750
5751 /* Mute all inputs to mixer widget (even unconnected ones) */
5752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5760
5761 { }
5762};
5763#endif
5764
Takashi Iwai63300792008-01-24 15:31:36 +01005765#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5766#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005767
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005768#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5769#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5770
Kailang Yangdf694da2005-12-05 19:42:22 +01005771/*
5772 * for BIOS auto-configuration
5773 */
5774
5775static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005776 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005777{
5778 hda_nid_t nid_vol;
5779 unsigned long vol_val, sw_val;
5780 char name[32];
5781 int err;
5782
5783 if (nid >= 0x0f && nid < 0x11) {
5784 nid_vol = nid - 0x7;
5785 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5786 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5787 } else if (nid == 0x11) {
5788 nid_vol = nid - 0x7;
5789 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5790 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5791 } else if (nid >= 0x12 && nid <= 0x15) {
5792 nid_vol = 0x08;
5793 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5794 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5795 } else
5796 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005797
Takashi Iwai863b4512008-10-21 17:01:47 +02005798 if (!(*vol_bits & (1 << nid_vol))) {
5799 /* first control for the volume widget */
5800 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5801 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5802 if (err < 0)
5803 return err;
5804 *vol_bits |= (1 << nid_vol);
5805 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005806 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005807 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5808 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 return err;
5810 return 1;
5811}
5812
5813/* add playback controls from the parsed DAC table */
5814static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5815 const struct auto_pin_cfg *cfg)
5816{
5817 hda_nid_t nid;
5818 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005819 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005820
5821 spec->multiout.num_dacs = 1;
5822 spec->multiout.dac_nids = spec->private_dac_nids;
5823 spec->multiout.dac_nids[0] = 0x02;
5824
5825 nid = cfg->line_out_pins[0];
5826 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005827 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005828 if (err < 0)
5829 return err;
5830 }
5831
Takashi Iwai82bc9552006-03-21 11:24:42 +01005832 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005833 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005834 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005835 if (err < 0)
5836 return err;
5837 }
5838
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005839 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005841 err = alc260_add_playback_controls(spec, nid, "Headphone",
5842 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 if (err < 0)
5844 return err;
5845 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005846 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005847}
5848
5849/* create playback/capture controls for input pins */
5850static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5851 const struct auto_pin_cfg *cfg)
5852{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005853 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 int i, err, idx;
5855
5856 for (i = 0; i < AUTO_PIN_LAST; i++) {
5857 if (cfg->input_pins[i] >= 0x12) {
5858 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005859 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005860 auto_pin_cfg_labels[i], idx,
5861 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 if (err < 0)
5863 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005864 imux->items[imux->num_items].label =
5865 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 imux->items[imux->num_items].index = idx;
5867 imux->num_items++;
5868 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005869 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005871 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005872 auto_pin_cfg_labels[i], idx,
5873 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005874 if (err < 0)
5875 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005876 imux->items[imux->num_items].label =
5877 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 imux->items[imux->num_items].index = idx;
5879 imux->num_items++;
5880 }
5881 }
5882 return 0;
5883}
5884
5885static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5886 hda_nid_t nid, int pin_type,
5887 int sel_idx)
5888{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005889 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 /* need the manual connection? */
5891 if (nid >= 0x12) {
5892 int idx = nid - 0x12;
5893 snd_hda_codec_write(codec, idx + 0x0b, 0,
5894 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005895 }
5896}
5897
5898static void alc260_auto_init_multi_out(struct hda_codec *codec)
5899{
5900 struct alc_spec *spec = codec->spec;
5901 hda_nid_t nid;
5902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005903 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005904 if (nid) {
5905 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5906 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5907 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005908
Takashi Iwai82bc9552006-03-21 11:24:42 +01005909 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 if (nid)
5911 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5912
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005913 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005914 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005915 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005916}
Kailang Yangdf694da2005-12-05 19:42:22 +01005917
5918#define ALC260_PIN_CD_NID 0x16
5919static void alc260_auto_init_analog_input(struct hda_codec *codec)
5920{
5921 struct alc_spec *spec = codec->spec;
5922 int i;
5923
5924 for (i = 0; i < AUTO_PIN_LAST; i++) {
5925 hda_nid_t nid = spec->autocfg.input_pins[i];
5926 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005927 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005928 if (nid != ALC260_PIN_CD_NID &&
5929 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005930 snd_hda_codec_write(codec, nid, 0,
5931 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005932 AMP_OUT_MUTE);
5933 }
5934 }
5935}
5936
5937/*
5938 * generic initialization of ADC, input mixers and output mixers
5939 */
5940static struct hda_verb alc260_volume_init_verbs[] = {
5941 /*
5942 * Unmute ADC0-1 and set the default input to mic-in
5943 */
5944 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5945 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5946 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5947 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005948
Kailang Yangdf694da2005-12-05 19:42:22 +01005949 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5950 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005951 * Note: PASD motherboards uses the Line In 2 as the input for
5952 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005953 */
5954 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005955 /* mute analog inputs */
5956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005961
5962 /*
5963 * Set up output mixers (0x08 - 0x0a)
5964 */
5965 /* set vol=0 to output mixers */
5966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5968 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5969 /* set up input amps for analog loopback */
5970 /* Amp Indices: DAC = 0, mixer = 1 */
5971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5974 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5975 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5976 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005977
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 { }
5979};
5980
5981static int alc260_parse_auto_config(struct hda_codec *codec)
5982{
5983 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005984 int err;
5985 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5986
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005987 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5988 alc260_ignore);
5989 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005991 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5992 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005993 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005994 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005995 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005996 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5997 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005998 return err;
5999
6000 spec->multiout.max_channels = 2;
6001
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006002 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006003 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006004 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006005 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006006
Takashi Iwaid88897e2008-10-31 15:01:37 +01006007 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006008
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006009 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006010 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006011
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006012 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6013
Kailang Yangdf694da2005-12-05 19:42:22 +01006014 return 1;
6015}
6016
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006017/* additional initialization for auto-configuration model */
6018static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006019{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006020 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 alc260_auto_init_multi_out(codec);
6022 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006023 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006024 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006025}
6026
Takashi Iwaicb53c622007-08-10 17:21:45 +02006027#ifdef CONFIG_SND_HDA_POWER_SAVE
6028static struct hda_amp_list alc260_loopbacks[] = {
6029 { 0x07, HDA_INPUT, 0 },
6030 { 0x07, HDA_INPUT, 1 },
6031 { 0x07, HDA_INPUT, 2 },
6032 { 0x07, HDA_INPUT, 3 },
6033 { 0x07, HDA_INPUT, 4 },
6034 { } /* end */
6035};
6036#endif
6037
Kailang Yangdf694da2005-12-05 19:42:22 +01006038/*
6039 * ALC260 configurations
6040 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006041static const char *alc260_models[ALC260_MODEL_LAST] = {
6042 [ALC260_BASIC] = "basic",
6043 [ALC260_HP] = "hp",
6044 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006045 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006046 [ALC260_FUJITSU_S702X] = "fujitsu",
6047 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006048 [ALC260_WILL] = "will",
6049 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006050 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006051#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006052 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006053#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006054 [ALC260_AUTO] = "auto",
6055};
6056
6057static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006058 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006059 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006060 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006061 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006062 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006063 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006064 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006065 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006066 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6067 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6068 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6069 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6070 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6071 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6072 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6073 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6074 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006075 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006076 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006077 {}
6078};
6079
Kailang Yangdf694da2005-12-05 19:42:22 +01006080static struct alc_config_preset alc260_presets[] = {
6081 [ALC260_BASIC] = {
6082 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006083 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 .init_verbs = { alc260_init_verbs },
6085 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6086 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006087 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006088 .adc_nids = alc260_adc_nids,
6089 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6090 .channel_mode = alc260_modes,
6091 .input_mux = &alc260_capture_source,
6092 },
6093 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006094 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006095 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006096 .init_verbs = { alc260_init_verbs,
6097 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006098 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6099 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006100 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6101 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006102 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6103 .channel_mode = alc260_modes,
6104 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006105 .unsol_event = alc260_hp_unsol_event,
6106 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006107 },
Kailang Yang3f878302008-08-26 13:02:23 +02006108 [ALC260_HP_DC7600] = {
6109 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006110 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006111 .init_verbs = { alc260_init_verbs,
6112 alc260_hp_dc7600_verbs },
6113 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6114 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006115 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6116 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006117 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6118 .channel_mode = alc260_modes,
6119 .input_mux = &alc260_capture_source,
6120 .unsol_event = alc260_hp_3012_unsol_event,
6121 .init_hook = alc260_hp_3012_automute,
6122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006123 [ALC260_HP_3013] = {
6124 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006125 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006126 .init_verbs = { alc260_hp_3013_init_verbs,
6127 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006128 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6129 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006130 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6131 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006132 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6133 .channel_mode = alc260_modes,
6134 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006135 .unsol_event = alc260_hp_3013_unsol_event,
6136 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 },
6138 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006139 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006140 .init_verbs = { alc260_fujitsu_init_verbs },
6141 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6142 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006143 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6144 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6146 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006147 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6148 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006150 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006151 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006152 .init_verbs = { alc260_acer_init_verbs },
6153 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6154 .dac_nids = alc260_dac_nids,
6155 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6156 .adc_nids = alc260_dual_adc_nids,
6157 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6158 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006159 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6160 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006161 },
Michael Schwingencc959482009-02-22 18:58:45 +01006162 [ALC260_FAVORIT100] = {
6163 .mixers = { alc260_favorit100_mixer },
6164 .init_verbs = { alc260_favorit100_init_verbs },
6165 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6166 .dac_nids = alc260_dac_nids,
6167 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6168 .adc_nids = alc260_dual_adc_nids,
6169 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6170 .channel_mode = alc260_modes,
6171 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6172 .input_mux = alc260_favorit100_capture_sources,
6173 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006174 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006175 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006176 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6177 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6178 .dac_nids = alc260_dac_nids,
6179 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6180 .adc_nids = alc260_adc_nids,
6181 .dig_out_nid = ALC260_DIGOUT_NID,
6182 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6183 .channel_mode = alc260_modes,
6184 .input_mux = &alc260_capture_source,
6185 },
6186 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006187 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006188 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6189 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6190 .dac_nids = alc260_dac_nids,
6191 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6192 .adc_nids = alc260_adc_nids,
6193 .dig_out_nid = ALC260_DIGOUT_NID,
6194 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6195 .channel_mode = alc260_modes,
6196 .input_mux = &alc260_capture_source,
6197 .unsol_event = alc260_replacer_672v_unsol_event,
6198 .init_hook = alc260_replacer_672v_automute,
6199 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006200#ifdef CONFIG_SND_DEBUG
6201 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006202 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006203 .init_verbs = { alc260_test_init_verbs },
6204 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6205 .dac_nids = alc260_test_dac_nids,
6206 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6207 .adc_nids = alc260_test_adc_nids,
6208 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6209 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006210 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6211 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006212 },
6213#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006214};
6215
Linus Torvalds1da177e2005-04-16 15:20:36 -07006216static int patch_alc260(struct hda_codec *codec)
6217{
6218 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006220
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006221 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006222 if (spec == NULL)
6223 return -ENOMEM;
6224
6225 codec->spec = spec;
6226
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006227 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6228 alc260_models,
6229 alc260_cfg_tbl);
6230 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006231 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006232 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006234 }
6235
Kailang Yangdf694da2005-12-05 19:42:22 +01006236 if (board_config == ALC260_AUTO) {
6237 /* automatic parse from the BIOS config */
6238 err = alc260_parse_auto_config(codec);
6239 if (err < 0) {
6240 alc_free(codec);
6241 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006242 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006243 printk(KERN_INFO
6244 "hda_codec: Cannot set up configuration "
6245 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006246 board_config = ALC260_BASIC;
6247 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006248 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006249
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006250 err = snd_hda_attach_beep_device(codec, 0x1);
6251 if (err < 0) {
6252 alc_free(codec);
6253 return err;
6254 }
6255
Kailang Yangdf694da2005-12-05 19:42:22 +01006256 if (board_config != ALC260_AUTO)
6257 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006258
Linus Torvalds1da177e2005-04-16 15:20:36 -07006259 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6260 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6261
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006262 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6263 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6264
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006265 if (!spec->adc_nids && spec->input_mux) {
6266 /* check whether NID 0x04 is valid */
6267 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006268 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006269 /* get type */
6270 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6271 spec->adc_nids = alc260_adc_nids_alt;
6272 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6273 } else {
6274 spec->adc_nids = alc260_adc_nids;
6275 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6276 }
6277 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006278 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006279 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006280
Takashi Iwai2134ea42008-01-10 16:53:55 +01006281 spec->vmaster_nid = 0x08;
6282
Linus Torvalds1da177e2005-04-16 15:20:36 -07006283 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006284 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006285 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006286#ifdef CONFIG_SND_HDA_POWER_SAVE
6287 if (!spec->loopback.amplist)
6288 spec->loopback.amplist = alc260_loopbacks;
6289#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006290 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006291
6292 return 0;
6293}
6294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006295
Linus Torvalds1da177e2005-04-16 15:20:36 -07006296/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006297 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006298 *
6299 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6300 * configuration. Each pin widget can choose any input DACs and a mixer.
6301 * Each ADC is connected from a mixer of all inputs. This makes possible
6302 * 6-channel independent captures.
6303 *
6304 * In addition, an independent DAC for the multi-playback (not used in this
6305 * driver yet).
6306 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006307#define ALC882_DIGOUT_NID 0x06
6308#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006309#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6310#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6311#define ALC1200_DIGOUT_NID 0x10
6312
Linus Torvalds1da177e2005-04-16 15:20:36 -07006313
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006314static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006315 { 8, NULL }
6316};
6317
Takashi Iwai4953550a2009-06-30 15:28:30 +02006318/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006319static hda_nid_t alc882_dac_nids[4] = {
6320 /* front, rear, clfe, rear_surr */
6321 0x02, 0x03, 0x04, 0x05
6322};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006323#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006324
Takashi Iwai4953550a2009-06-30 15:28:30 +02006325/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006326#define alc882_adc_nids alc880_adc_nids
6327#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006328#define alc883_adc_nids alc882_adc_nids_alt
6329static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6330static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6331#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006332
Takashi Iwaie1406342008-02-11 18:32:32 +01006333static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6334static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006335#define alc883_capsrc_nids alc882_capsrc_nids_alt
6336static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6337#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006338
Linus Torvalds1da177e2005-04-16 15:20:36 -07006339/* input MUX */
6340/* FIXME: should be a matrix-type input source selection */
6341
6342static struct hda_input_mux alc882_capture_source = {
6343 .num_items = 4,
6344 .items = {
6345 { "Mic", 0x0 },
6346 { "Front Mic", 0x1 },
6347 { "Line", 0x2 },
6348 { "CD", 0x4 },
6349 },
6350};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006351
Takashi Iwai4953550a2009-06-30 15:28:30 +02006352#define alc883_capture_source alc882_capture_source
6353
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006354static struct hda_input_mux alc889_capture_source = {
6355 .num_items = 3,
6356 .items = {
6357 { "Front Mic", 0x0 },
6358 { "Mic", 0x3 },
6359 { "Line", 0x2 },
6360 },
6361};
6362
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006363static struct hda_input_mux mb5_capture_source = {
6364 .num_items = 3,
6365 .items = {
6366 { "Mic", 0x1 },
6367 { "Line", 0x2 },
6368 { "CD", 0x4 },
6369 },
6370};
6371
Takashi Iwai4953550a2009-06-30 15:28:30 +02006372static struct hda_input_mux alc883_3stack_6ch_intel = {
6373 .num_items = 4,
6374 .items = {
6375 { "Mic", 0x1 },
6376 { "Front Mic", 0x0 },
6377 { "Line", 0x2 },
6378 { "CD", 0x4 },
6379 },
6380};
6381
6382static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6383 .num_items = 2,
6384 .items = {
6385 { "Mic", 0x1 },
6386 { "Line", 0x2 },
6387 },
6388};
6389
6390static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6391 .num_items = 4,
6392 .items = {
6393 { "Mic", 0x0 },
6394 { "iMic", 0x1 },
6395 { "Line", 0x2 },
6396 { "CD", 0x4 },
6397 },
6398};
6399
6400static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6401 .num_items = 2,
6402 .items = {
6403 { "Mic", 0x0 },
6404 { "Int Mic", 0x1 },
6405 },
6406};
6407
6408static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6409 .num_items = 3,
6410 .items = {
6411 { "Mic", 0x0 },
6412 { "Front Mic", 0x1 },
6413 { "Line", 0x4 },
6414 },
6415};
6416
6417static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6418 .num_items = 2,
6419 .items = {
6420 { "Mic", 0x0 },
6421 { "Line", 0x2 },
6422 },
6423};
6424
6425static struct hda_input_mux alc889A_mb31_capture_source = {
6426 .num_items = 2,
6427 .items = {
6428 { "Mic", 0x0 },
6429 /* Front Mic (0x01) unused */
6430 { "Line", 0x2 },
6431 /* Line 2 (0x03) unused */
6432 /* CD (0x04) unsused? */
6433 },
6434};
6435
6436/*
6437 * 2ch mode
6438 */
6439static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6440 { 2, NULL }
6441};
6442
Kailang Yangdf694da2005-12-05 19:42:22 +01006443/*
Kailang Yang272a5272007-05-14 11:00:38 +02006444 * 2ch mode
6445 */
6446static struct hda_verb alc882_3ST_ch2_init[] = {
6447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6449 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6450 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6451 { } /* end */
6452};
6453
6454/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006455 * 4ch mode
6456 */
6457static struct hda_verb alc882_3ST_ch4_init[] = {
6458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6462 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6463 { } /* end */
6464};
6465
6466/*
Kailang Yang272a5272007-05-14 11:00:38 +02006467 * 6ch mode
6468 */
6469static struct hda_verb alc882_3ST_ch6_init[] = {
6470 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6471 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6472 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6473 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6474 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6475 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6476 { } /* end */
6477};
6478
Takashi Iwai4953550a2009-06-30 15:28:30 +02006479static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006480 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006481 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006482 { 6, alc882_3ST_ch6_init },
6483};
6484
Takashi Iwai4953550a2009-06-30 15:28:30 +02006485#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6486
Kailang Yang272a5272007-05-14 11:00:38 +02006487/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006488 * 6ch mode
6489 */
6490static struct hda_verb alc882_sixstack_ch6_init[] = {
6491 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6492 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6493 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6494 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6495 { } /* end */
6496};
6497
6498/*
6499 * 8ch mode
6500 */
6501static struct hda_verb alc882_sixstack_ch8_init[] = {
6502 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6503 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6504 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6505 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6506 { } /* end */
6507};
6508
6509static struct hda_channel_mode alc882_sixstack_modes[2] = {
6510 { 6, alc882_sixstack_ch6_init },
6511 { 8, alc882_sixstack_ch8_init },
6512};
6513
Takashi Iwai87350ad2007-08-16 18:19:38 +02006514/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006515 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006516 */
6517
6518/*
6519 * 2ch mode
6520 */
6521static struct hda_verb alc885_mbp_ch2_init[] = {
6522 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6523 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6524 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6525 { } /* end */
6526};
6527
6528/*
6529 * 6ch mode
6530 */
6531static struct hda_verb alc885_mbp_ch6_init[] = {
6532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6534 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6535 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6536 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6537 { } /* end */
6538};
6539
6540static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6541 { 2, alc885_mbp_ch2_init },
6542 { 6, alc885_mbp_ch6_init },
6543};
6544
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006545/*
6546 * 2ch
6547 * Speakers/Woofer/HP = Front
6548 * LineIn = Input
6549 */
6550static struct hda_verb alc885_mb5_ch2_init[] = {
6551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6553 { } /* end */
6554};
6555
6556/*
6557 * 6ch mode
6558 * Speakers/HP = Front
6559 * Woofer = LFE
6560 * LineIn = Surround
6561 */
6562static struct hda_verb alc885_mb5_ch6_init[] = {
6563 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6565 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6566 { } /* end */
6567};
6568
6569static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6570 { 2, alc885_mb5_ch2_init },
6571 { 6, alc885_mb5_ch6_init },
6572};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006573
Takashi Iwai4953550a2009-06-30 15:28:30 +02006574
6575/*
6576 * 2ch mode
6577 */
6578static struct hda_verb alc883_4ST_ch2_init[] = {
6579 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6580 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6581 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6582 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6583 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6584 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6585 { } /* end */
6586};
6587
6588/*
6589 * 4ch mode
6590 */
6591static struct hda_verb alc883_4ST_ch4_init[] = {
6592 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6593 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6594 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6595 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6596 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6597 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6598 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6599 { } /* end */
6600};
6601
6602/*
6603 * 6ch mode
6604 */
6605static struct hda_verb alc883_4ST_ch6_init[] = {
6606 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6607 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6608 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6609 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6610 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6611 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6612 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6613 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6614 { } /* end */
6615};
6616
6617/*
6618 * 8ch mode
6619 */
6620static struct hda_verb alc883_4ST_ch8_init[] = {
6621 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6622 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6623 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6626 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6627 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6628 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6629 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6630 { } /* end */
6631};
6632
6633static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6634 { 2, alc883_4ST_ch2_init },
6635 { 4, alc883_4ST_ch4_init },
6636 { 6, alc883_4ST_ch6_init },
6637 { 8, alc883_4ST_ch8_init },
6638};
6639
6640
6641/*
6642 * 2ch mode
6643 */
6644static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6645 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6646 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6647 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6648 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6649 { } /* end */
6650};
6651
6652/*
6653 * 4ch mode
6654 */
6655static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6656 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6657 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6658 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6659 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6660 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6661 { } /* end */
6662};
6663
6664/*
6665 * 6ch mode
6666 */
6667static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6668 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6669 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6670 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6671 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6672 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6673 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6674 { } /* end */
6675};
6676
6677static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6678 { 2, alc883_3ST_ch2_intel_init },
6679 { 4, alc883_3ST_ch4_intel_init },
6680 { 6, alc883_3ST_ch6_intel_init },
6681};
6682
6683/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006684 * 2ch mode
6685 */
6686static struct hda_verb alc889_ch2_intel_init[] = {
6687 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6688 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6689 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6690 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6691 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6692 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6693 { } /* end */
6694};
6695
6696/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006697 * 6ch mode
6698 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006699static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006700 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6701 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6702 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6703 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6706 { } /* end */
6707};
6708
6709/*
6710 * 8ch mode
6711 */
6712static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006713 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6714 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6715 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6716 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6717 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006718 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6719 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006720 { } /* end */
6721};
6722
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006723static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6724 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006725 { 6, alc889_ch6_intel_init },
6726 { 8, alc889_ch8_intel_init },
6727};
6728
6729/*
6730 * 6ch mode
6731 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006732static struct hda_verb alc883_sixstack_ch6_init[] = {
6733 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6734 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6735 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6736 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6737 { } /* end */
6738};
6739
6740/*
6741 * 8ch mode
6742 */
6743static struct hda_verb alc883_sixstack_ch8_init[] = {
6744 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6746 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6747 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6748 { } /* end */
6749};
6750
6751static struct hda_channel_mode alc883_sixstack_modes[2] = {
6752 { 6, alc883_sixstack_ch6_init },
6753 { 8, alc883_sixstack_ch8_init },
6754};
6755
6756
Linus Torvalds1da177e2005-04-16 15:20:36 -07006757/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6758 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6759 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006760static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6766 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006769 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006770 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006777 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006780 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006782 { } /* end */
6783};
6784
Takashi Iwai87350ad2007-08-16 18:19:38 +02006785static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6787 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6788 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6789 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6791 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6793 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006794 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6796 { } /* end */
6797};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006798
6799static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006800 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6801 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6802 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6803 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6804 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6805 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6806 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6807 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006808 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6809 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6811 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6812 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6813 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6814 { } /* end */
6815};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006816
Kailang Yangbdd148a2007-05-08 15:19:08 +02006817static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006827 { } /* end */
6828};
6829
Kailang Yang272a5272007-05-14 11:00:38 +02006830static struct snd_kcontrol_new alc882_targa_mixer[] = {
6831 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6832 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006844 { } /* end */
6845};
6846
6847/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6848 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6849 */
6850static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6852 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6854 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6855 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6856 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6857 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6858 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6859 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6860 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006864 { } /* end */
6865};
6866
Takashi Iwai914759b2007-09-06 14:52:04 +02006867static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6868 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6869 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6870 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6876 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6877 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006878 { } /* end */
6879};
6880
Kailang Yangdf694da2005-12-05 19:42:22 +01006881static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6882 {
6883 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6884 .name = "Channel Mode",
6885 .info = alc_ch_mode_info,
6886 .get = alc_ch_mode_get,
6887 .put = alc_ch_mode_put,
6888 },
6889 { } /* end */
6890};
6891
Takashi Iwai4953550a2009-06-30 15:28:30 +02006892static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006893 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006897 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006901 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006905 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006909
Takashi Iwaicb638122009-07-03 10:56:10 +02006910 /* mute analog input loopbacks */
6911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6916
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006917 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006920 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006921 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006924 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006925 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006928 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006929 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006932 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006933 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006934 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006935 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6936 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006937 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006938 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6939 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006940 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6942 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6945 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006946 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006948
6949 /* FIXME: use matrix-type input source selection */
6950 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006951 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006956 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02006961 /* ADC2: mute amp left and right */
6962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006963 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006964 /* ADC3: mute amp left and right */
6965 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006966 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006967
6968 { }
6969};
6970
Takashi Iwai4953550a2009-06-30 15:28:30 +02006971static struct hda_verb alc882_adc1_init_verbs[] = {
6972 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6977 /* ADC1: mute amp left and right */
6978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6979 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6980 { }
6981};
6982
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006983static struct hda_verb alc882_eapd_verbs[] = {
6984 /* change to EAPD mode */
6985 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006986 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006987 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006988};
6989
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006990static struct hda_verb alc889_eapd_verbs[] = {
6991 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
6992 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
6993 { }
6994};
6995
6996
6997static struct hda_verb alc885_init_verbs[] = {
6998 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7000 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7002 /* Rear mixer */
7003 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7004 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7006 /* CLFE mixer */
7007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7010 /* Side mixer */
7011 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7014
7015 /* mute analog input loopbacks */
7016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7019
7020 /* Front HP Pin: output 0 (0x0c) */
7021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7023 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7024 /* Front Pin: output 0 (0x0c) */
7025 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7027 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7028 /* Rear Pin: output 1 (0x0d) */
7029 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7030 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7031 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7032 /* CLFE Pin: output 2 (0x0e) */
7033 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7034 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7035 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7036 /* Side Pin: output 3 (0x0f) */
7037 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7038 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7039 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7040 /* Mic (rear) pin: input vref at 80% */
7041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7042 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7043 /* Front Mic pin: input vref at 80% */
7044 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7045 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7046 /* Line In pin: input */
7047 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7049
7050 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7051 /* Input mixer1 */
7052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7055 /* Input mixer2 */
7056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7059 /* Input mixer3 */
7060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7063 /* ADC2: mute amp left and right */
7064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7065 /* ADC3: mute amp left and right */
7066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7067
7068 { }
7069};
7070
7071static struct hda_verb alc885_init_input_verbs[] = {
7072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7075 { }
7076};
7077
7078
7079/* Unmute Selector 24h and set the default input to front mic */
7080static struct hda_verb alc889_init_input_verbs[] = {
7081 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7083 { }
7084};
7085
7086
Takashi Iwai4953550a2009-06-30 15:28:30 +02007087#define alc883_init_verbs alc882_base_init_verbs
7088
Tobin Davis9102cd12006-12-15 10:02:12 +01007089/* Mac Pro test */
7090static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007096 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007097 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7098 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007099 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007100 { } /* end */
7101};
7102
7103static struct hda_verb alc882_macpro_init_verbs[] = {
7104 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7108 /* Front Pin: output 0 (0x0c) */
7109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7112 /* Front Mic pin: input vref at 80% */
7113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7115 /* Speaker: output */
7116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7119 /* Headphone output (output 0 - 0x0c) */
7120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7122 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7123
7124 /* FIXME: use matrix-type input source selection */
7125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7126 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7131 /* Input mixer2 */
7132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7134 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7135 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7136 /* Input mixer3 */
7137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7141 /* ADC1: mute amp left and right */
7142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7144 /* ADC2: mute amp left and right */
7145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7146 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7147 /* ADC3: mute amp left and right */
7148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7150
7151 { }
7152};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007153
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007154/* Macbook 5,1 */
7155static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007156 /* DACs */
7157 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7158 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7159 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007161 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007165 /* Surround mixer */
7166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7169 /* LFE mixer */
7170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7173 /* HP mixer */
7174 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7177 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007180 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7181 /* LFE Pin (0x0e) */
7182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7185 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007188 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007189 /* Front Mic pin: input vref at 80% */
7190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7192 /* Line In pin */
7193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7195
7196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7200 { }
7201};
7202
Takashi Iwai87350ad2007-08-16 18:19:38 +02007203/* Macbook Pro rev3 */
7204static struct hda_verb alc885_mbp3_init_verbs[] = {
7205 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7209 /* Rear mixer */
7210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7213 /* Front Pin: output 0 (0x0c) */
7214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7216 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7217 /* HP Pin: output 0 (0x0d) */
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7222 /* Mic (rear) pin: input vref at 80% */
7223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7225 /* Front Mic pin: input vref at 80% */
7226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7228 /* Line In pin: use output 1 when in LineOut mode */
7229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7232
7233 /* FIXME: use matrix-type input source selection */
7234 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7235 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7240 /* Input mixer2 */
7241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7245 /* Input mixer3 */
7246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7250 /* ADC1: mute amp left and right */
7251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7252 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7253 /* ADC2: mute amp left and right */
7254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7255 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7256 /* ADC3: mute amp left and right */
7257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7258 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7259
7260 { }
7261};
7262
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007263/* iMac 24 mixer. */
7264static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7265 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7266 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7267 { } /* end */
7268};
7269
7270/* iMac 24 init verbs. */
7271static struct hda_verb alc885_imac24_init_verbs[] = {
7272 /* Internal speakers: output 0 (0x0c) */
7273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7275 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7276 /* Internal speakers: output 0 (0x0c) */
7277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7278 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7279 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7280 /* Headphone: output 0 (0x0c) */
7281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7284 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7285 /* Front Mic: input vref at 80% */
7286 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7288 { }
7289};
7290
7291/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007292static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007293{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007294 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007296 spec->autocfg.hp_pins[0] = 0x14;
7297 spec->autocfg.speaker_pins[0] = 0x18;
7298 spec->autocfg.speaker_pins[1] = 0x1a;
7299 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007300}
7301
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007302static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007303{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007304 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007305
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007306 spec->autocfg.hp_pins[0] = 0x15;
7307 spec->autocfg.speaker_pins[0] = 0x14;
7308 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007309}
7310
7311
Kailang Yang272a5272007-05-14 11:00:38 +02007312static struct hda_verb alc882_targa_verbs[] = {
7313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7315
7316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007318
Kailang Yang272a5272007-05-14 11:00:38 +02007319 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7320 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7322
7323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007324 { } /* end */
7325};
7326
7327/* toggle speaker-output according to the hp-jack state */
7328static void alc882_targa_automute(struct hda_codec *codec)
7329{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007330 struct alc_spec *spec = codec->spec;
7331 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007332 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007333 spec->jack_present ? 1 : 3);
7334}
7335
7336static void alc882_targa_init_hook(struct hda_codec *codec)
7337{
7338 struct alc_spec *spec = codec->spec;
7339
7340 spec->autocfg.hp_pins[0] = 0x14;
7341 spec->autocfg.speaker_pins[0] = 0x1b;
7342 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007343}
7344
7345static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7346{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007347 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007348 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007349}
7350
7351static struct hda_verb alc882_asus_a7j_verbs[] = {
7352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7354
7355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007358
Kailang Yang272a5272007-05-14 11:00:38 +02007359 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7361 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7362
7363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7364 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7365 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7366 { } /* end */
7367};
7368
Takashi Iwai914759b2007-09-06 14:52:04 +02007369static struct hda_verb alc882_asus_a7m_verbs[] = {
7370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7372
7373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7375 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007376
Takashi Iwai914759b2007-09-06 14:52:04 +02007377 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7379 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7380
7381 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7383 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7384 { } /* end */
7385};
7386
Tobin Davis9102cd12006-12-15 10:02:12 +01007387static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7388{
7389 unsigned int gpiostate, gpiomask, gpiodir;
7390
7391 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7392 AC_VERB_GET_GPIO_DATA, 0);
7393
7394 if (!muted)
7395 gpiostate |= (1 << pin);
7396 else
7397 gpiostate &= ~(1 << pin);
7398
7399 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7400 AC_VERB_GET_GPIO_MASK, 0);
7401 gpiomask |= (1 << pin);
7402
7403 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7404 AC_VERB_GET_GPIO_DIRECTION, 0);
7405 gpiodir |= (1 << pin);
7406
7407
7408 snd_hda_codec_write(codec, codec->afg, 0,
7409 AC_VERB_SET_GPIO_MASK, gpiomask);
7410 snd_hda_codec_write(codec, codec->afg, 0,
7411 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7412
7413 msleep(1);
7414
7415 snd_hda_codec_write(codec, codec->afg, 0,
7416 AC_VERB_SET_GPIO_DATA, gpiostate);
7417}
7418
Takashi Iwai7debbe52007-08-16 15:01:03 +02007419/* set up GPIO at initialization */
7420static void alc885_macpro_init_hook(struct hda_codec *codec)
7421{
7422 alc882_gpio_mute(codec, 0, 0);
7423 alc882_gpio_mute(codec, 1, 0);
7424}
7425
7426/* set up GPIO and update auto-muting at initialization */
7427static void alc885_imac24_init_hook(struct hda_codec *codec)
7428{
7429 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007430 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007431}
7432
Kailang Yangdf694da2005-12-05 19:42:22 +01007433/*
7434 * generic initialization of ADC, input mixers and output mixers
7435 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007436static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007437 /*
7438 * Unmute ADC0-2 and set the default input to mic-in
7439 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007440 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7442 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7444
Takashi Iwaicb53c622007-08-10 17:21:45 +02007445 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007446 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007447 * Note: PASD motherboards uses the Line In 2 as the input for
7448 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007449 */
7450 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007456
7457 /*
7458 * Set up output mixers (0x0c - 0x0f)
7459 */
7460 /* set vol=0 to output mixers */
7461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7465 /* set up input amps for analog loopback */
7466 /* Amp Indices: DAC = 0, mixer = 1 */
7467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7474 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7475 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7477
7478 /* FIXME: use matrix-type input source selection */
7479 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007480 /* Input mixer2 */
7481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7485 /* Input mixer3 */
7486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7490
7491 { }
7492};
7493
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007494/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7495static struct hda_verb alc889A_mb31_ch2_init[] = {
7496 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7500 { } /* end */
7501};
7502
7503/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7504static struct hda_verb alc889A_mb31_ch4_init[] = {
7505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7509 { } /* end */
7510};
7511
7512/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7513static struct hda_verb alc889A_mb31_ch5_init[] = {
7514 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7518 { } /* end */
7519};
7520
7521/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7522static struct hda_verb alc889A_mb31_ch6_init[] = {
7523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7526 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7527 { } /* end */
7528};
7529
7530static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7531 { 2, alc889A_mb31_ch2_init },
7532 { 4, alc889A_mb31_ch4_init },
7533 { 5, alc889A_mb31_ch5_init },
7534 { 6, alc889A_mb31_ch6_init },
7535};
7536
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007537static struct hda_verb alc883_medion_eapd_verbs[] = {
7538 /* eanable EAPD on medion laptop */
7539 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7540 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7541 { }
7542};
7543
Takashi Iwai4953550a2009-06-30 15:28:30 +02007544#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007545
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007546static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7547 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7549 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7551 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7552 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7558 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7559 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007560 { } /* end */
7561};
7562
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007563static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007564 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7565 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7566 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7567 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7571 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7572 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7573 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007574 { } /* end */
7575};
7576
Jiang zhefb97dc62008-03-06 11:07:11 +01007577static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7578 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7579 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7580 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7581 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7583 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7585 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7586 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7587 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007588 { } /* end */
7589};
7590
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007591static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7592 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7593 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007600 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7602 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007603 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007605 { } /* end */
7606};
7607
7608static struct snd_kcontrol_new alc883_3ST_6ch_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7615 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7616 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7618 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7619 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7620 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7621 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007623 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7625 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007626 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007627 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007628 { } /* end */
7629};
7630
Jiang zhe17bba1b2008-06-04 12:11:07 +02007631static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7634 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7635 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7637 HDA_OUTPUT),
7638 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7639 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7640 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7647 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7650 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7651 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007652 { } /* end */
7653};
7654
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007655static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7656 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7657 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7658 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7659 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7660 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7661 HDA_OUTPUT),
7662 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7663 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7664 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7666 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7673 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7674 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7675 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7676 { } /* end */
7677};
7678
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007679static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007680 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007681 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007682 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007683 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007684 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7685 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007686 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7687 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7689 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7690 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7692 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007694 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007697 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007699 { } /* end */
7700};
7701
Sasha Alexandrc2592492009-06-16 14:52:54 -04007702static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7705 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7706 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7707 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7709 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7710 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7711 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007717 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007719 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007720};
Kailang Yangccc656c2006-10-17 12:32:26 +02007721
Sasha Alexandrc2592492009-06-16 14:52:54 -04007722static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007723 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7725 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7726 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7727 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007729 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007731 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7732 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7733 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007734 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007735};
Kailang Yangccc656c2006-10-17 12:32:26 +02007736
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007737static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007746 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007747};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007748
Kailang Yang272a5272007-05-14 11:00:38 +02007749static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7750 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7751 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7757 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7758 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007759 { } /* end */
7760};
7761
7762static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7763 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7765 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007772 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007773};
Kailang Yang272a5272007-05-14 11:00:38 +02007774
Tobin Davis2880a862007-08-07 11:50:26 +02007775static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7777 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007784 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007785};
Tobin Davis2880a862007-08-07 11:50:26 +02007786
Tony Vroond2fd4b02009-06-21 00:40:10 +01007787static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7790 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 { } /* end */
7800};
7801
Kailang Yange2757d52008-08-26 13:17:46 +02007802static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7805 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7806 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7807 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7808 0x0d, 1, 0x0, HDA_OUTPUT),
7809 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7810 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7811 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7813 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007824 { } /* end */
7825};
7826
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007827static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7828 /* Output mixers */
7829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7832 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7834 HDA_OUTPUT),
7835 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7836 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7837 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7838 /* Output switches */
7839 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7840 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7841 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7842 /* Boost mixers */
7843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7844 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7845 /* Input mixers */
7846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7850 { } /* end */
7851};
7852
Guido Günther3e1647c52009-06-05 00:47:26 +02007853static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
7854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7858 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7860 { } /* end */
7861};
7862
Kailang Yange2757d52008-08-26 13:17:46 +02007863static struct hda_bind_ctls alc883_bind_cap_vol = {
7864 .ops = &snd_hda_bind_vol,
7865 .values = {
7866 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7867 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7868 0
7869 },
7870};
7871
7872static struct hda_bind_ctls alc883_bind_cap_switch = {
7873 .ops = &snd_hda_bind_sw,
7874 .values = {
7875 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7876 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7877 0
7878 },
7879};
7880
7881static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007890 { } /* end */
7891};
7892
7893static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007894 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7895 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7896 {
7897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7898 /* .name = "Capture Source", */
7899 .name = "Input Source",
7900 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007901 .info = alc_mux_enum_info,
7902 .get = alc_mux_enum_get,
7903 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007904 },
7905 { } /* end */
7906};
7907
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007908static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7909 {
7910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7911 .name = "Channel Mode",
7912 .info = alc_ch_mode_info,
7913 .get = alc_ch_mode_get,
7914 .put = alc_ch_mode_put,
7915 },
7916 { } /* end */
7917};
7918
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007919/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007920static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007921{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007922 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007923
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007924 spec->autocfg.hp_pins[0] = 0x15;
7925 spec->autocfg.speaker_pins[0] = 0x14;
7926 spec->autocfg.speaker_pins[1] = 0x17;
7927 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007928}
7929
7930/* auto-toggle front mic */
7931/*
7932static void alc883_mitac_mic_automute(struct hda_codec *codec)
7933{
7934 unsigned int present;
7935 unsigned char bits;
7936
7937 present = snd_hda_codec_read(codec, 0x18, 0,
7938 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7939 bits = present ? HDA_AMP_MUTE : 0;
7940 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7941}
7942*/
7943
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007944static struct hda_verb alc883_mitac_verbs[] = {
7945 /* HP */
7946 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7947 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7948 /* Subwoofer */
7949 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7950 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7951
7952 /* enable unsolicited event */
7953 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7954 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7955
7956 { } /* end */
7957};
7958
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007959static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007960 /* HP */
7961 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7963 /* Int speaker */
7964 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7966
7967 /* enable unsolicited event */
7968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007969 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007970
7971 { } /* end */
7972};
7973
Jiang zhefb97dc62008-03-06 11:07:11 +01007974static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7975 /* HP */
7976 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7978 /* Subwoofer */
7979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7981
7982 /* enable unsolicited event */
7983 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7984
7985 { } /* end */
7986};
7987
Sasha Alexandrc2592492009-06-16 14:52:54 -04007988static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7991
7992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007994
David Heidelberger64a8be72009-06-08 16:15:18 +02007995/* Connect Line-Out side jack (SPDIF) to Side */
7996 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7998 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7999/* Connect Mic jack to CLFE */
8000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8002 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8003/* Connect Line-in jack to Surround */
8004 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8005 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8006 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8007/* Connect HP out jack to Front */
8008 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8009 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8010 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008011
8012 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008013
8014 { } /* end */
8015};
8016
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008017static struct hda_verb alc883_lenovo_101e_verbs[] = {
8018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8019 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8020 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8021 { } /* end */
8022};
8023
Kailang Yang272a5272007-05-14 11:00:38 +02008024static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8027 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8029 { } /* end */
8030};
8031
8032static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8035 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8036 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8037 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8038 { } /* end */
8039};
8040
Kailang Yang189609a2007-08-20 11:31:23 +02008041static struct hda_verb alc883_haier_w66_verbs[] = {
8042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8044
8045 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8046
8047 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8049 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8051 { } /* end */
8052};
8053
Kailang Yange2757d52008-08-26 13:17:46 +02008054static struct hda_verb alc888_lenovo_sky_verbs[] = {
8055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8059 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8061 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8062 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8063 { } /* end */
8064};
8065
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008066static struct hda_verb alc888_6st_dell_verbs[] = {
8067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8068 { }
8069};
8070
Guido Günther3e1647c52009-06-05 00:47:26 +02008071static struct hda_verb alc883_vaiott_verbs[] = {
8072 /* HP */
8073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8075
8076 /* enable unsolicited event */
8077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8078
8079 { } /* end */
8080};
8081
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008082static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008083{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008084 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008085
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008086 spec->autocfg.hp_pins[0] = 0x1b;
8087 spec->autocfg.speaker_pins[0] = 0x14;
8088 spec->autocfg.speaker_pins[1] = 0x16;
8089 spec->autocfg.speaker_pins[2] = 0x18;
8090 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008091}
8092
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008093static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008094 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008095 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8096 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008097 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008098 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008099};
8100
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008101/*
8102 * 2ch mode
8103 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008104static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008105 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8106 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8107 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8108 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008109 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008110};
8111
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008112/*
8113 * 4ch mode
8114 */
8115static struct hda_verb alc888_3st_hp_4ch_init[] = {
8116 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8117 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8118 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8119 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8120 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8121 { } /* end */
8122};
8123
8124/*
8125 * 6ch mode
8126 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008127static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008128 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8129 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008130 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008131 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8132 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008133 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8134 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008135};
8136
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008137static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008138 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008139 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008140 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008141};
8142
Kailang Yang272a5272007-05-14 11:00:38 +02008143/* toggle front-jack and RCA according to the hp-jack state */
8144static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8145{
8146 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008147
Kailang Yang272a5272007-05-14 11:00:38 +02008148 present = snd_hda_codec_read(codec, 0x1b, 0,
8149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008150 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8152 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8153 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008154}
8155
8156/* toggle RCA according to the front-jack state */
8157static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8158{
8159 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008160
Kailang Yang272a5272007-05-14 11:00:38 +02008161 present = snd_hda_codec_read(codec, 0x14, 0,
8162 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008163 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8164 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008165}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008166
Kailang Yang272a5272007-05-14 11:00:38 +02008167static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8168 unsigned int res)
8169{
8170 if ((res >> 26) == ALC880_HP_EVENT)
8171 alc888_lenovo_ms7195_front_automute(codec);
8172 if ((res >> 26) == ALC880_FRONT_EVENT)
8173 alc888_lenovo_ms7195_rca_automute(codec);
8174}
8175
8176static struct hda_verb alc883_medion_md2_verbs[] = {
8177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8179
8180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8181
8182 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8183 { } /* end */
8184};
8185
8186/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008187static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008188{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008189 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008190
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008191 spec->autocfg.hp_pins[0] = 0x14;
8192 spec->autocfg.speaker_pins[0] = 0x15;
8193 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008194}
8195
Kailang Yangccc656c2006-10-17 12:32:26 +02008196/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008197#define alc883_targa_init_hook alc882_targa_init_hook
8198#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008199
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008200static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8201{
8202 unsigned int present;
8203
8204 present = snd_hda_codec_read(codec, 0x18, 0,
8205 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8206 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8207 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8208}
8209
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008210static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008211{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008212 struct alc_spec *spec = codec->spec;
8213
8214 spec->autocfg.hp_pins[0] = 0x15;
8215 spec->autocfg.speaker_pins[0] = 0x14;
8216 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008217 alc883_clevo_m720_mic_automute(codec);
8218}
8219
8220static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008221 unsigned int res)
8222{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008223 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008224 case ALC880_MIC_EVENT:
8225 alc883_clevo_m720_mic_automute(codec);
8226 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008227 default:
8228 alc_automute_amp_unsol_event(codec, res);
8229 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008230 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008231}
8232
Jiang zhefb97dc62008-03-06 11:07:11 +01008233/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008234static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008235{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008236 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008237
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008238 spec->autocfg.hp_pins[0] = 0x14;
8239 spec->autocfg.speaker_pins[0] = 0x15;
8240 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008241}
8242
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008243static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008244{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008245 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008246
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008247 spec->autocfg.hp_pins[0] = 0x1b;
8248 spec->autocfg.speaker_pins[0] = 0x14;
8249 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008250}
8251
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008252static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8253{
8254 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008255 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008256
David Heidelberger64a8be72009-06-08 16:15:18 +02008257 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8258 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008259 bits = present ? HDA_AMP_MUTE : 0;
8260 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8261 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008262}
8263
8264static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8265{
8266 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008267 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008268
8269 present = snd_hda_codec_read(codec, 0x1b, 0,
8270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008271 bits = present ? HDA_AMP_MUTE : 0;
8272 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8273 HDA_AMP_MUTE, bits);
8274 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8275 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008276}
8277
8278static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8279 unsigned int res)
8280{
8281 if ((res >> 26) == ALC880_HP_EVENT)
8282 alc883_lenovo_101e_all_automute(codec);
8283 if ((res >> 26) == ALC880_FRONT_EVENT)
8284 alc883_lenovo_101e_ispeaker_automute(codec);
8285}
8286
Takashi Iwai676a9b52007-08-16 15:23:35 +02008287/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008288static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008289{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008290 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008291
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008292 spec->autocfg.hp_pins[0] = 0x14;
8293 spec->autocfg.speaker_pins[0] = 0x15;
8294 spec->autocfg.speaker_pins[1] = 0x16;
8295 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008296}
8297
Kailang Yangd1a991a2007-08-15 16:21:59 +02008298static struct hda_verb alc883_acer_eapd_verbs[] = {
8299 /* HP Pin: output 0 (0x0c) */
8300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8302 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008307 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8308 /* eanable EAPD on medion laptop */
8309 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8310 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008311 /* enable unsolicited event */
8312 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008313 { }
8314};
8315
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008316static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008317{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008318 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008319
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008320 spec->autocfg.hp_pins[0] = 0x1b;
8321 spec->autocfg.speaker_pins[0] = 0x14;
8322 spec->autocfg.speaker_pins[1] = 0x15;
8323 spec->autocfg.speaker_pins[2] = 0x16;
8324 spec->autocfg.speaker_pins[3] = 0x17;
8325 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008326}
8327
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008328static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008329{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008330 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008331
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008332 spec->autocfg.hp_pins[0] = 0x1b;
8333 spec->autocfg.speaker_pins[0] = 0x14;
8334 spec->autocfg.speaker_pins[1] = 0x15;
8335 spec->autocfg.speaker_pins[2] = 0x16;
8336 spec->autocfg.speaker_pins[3] = 0x17;
8337 spec->autocfg.speaker_pins[4] = 0x1a;
8338 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008339}
8340
Guido Günther3e1647c52009-06-05 00:47:26 +02008341static void alc883_vaiott_init_hook(struct hda_codec *codec)
8342{
8343 struct alc_spec *spec = codec->spec;
8344
8345 spec->autocfg.hp_pins[0] = 0x15;
8346 spec->autocfg.speaker_pins[0] = 0x14;
8347 spec->autocfg.speaker_pins[1] = 0x17;
8348 alc_automute_amp(codec);
8349}
8350
Kailang Yange2757d52008-08-26 13:17:46 +02008351static struct hda_verb alc888_asus_m90v_verbs[] = {
8352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8355 /* enable unsolicited event */
8356 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8357 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8358 { } /* end */
8359};
8360
8361static void alc883_nb_mic_automute(struct hda_codec *codec)
8362{
8363 unsigned int present;
8364
8365 present = snd_hda_codec_read(codec, 0x18, 0,
8366 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8367 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8368 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8369 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8370 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8371}
8372
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008373static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008374{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008375 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008376
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008377 spec->autocfg.hp_pins[0] = 0x1b;
8378 spec->autocfg.speaker_pins[0] = 0x14;
8379 spec->autocfg.speaker_pins[1] = 0x15;
8380 spec->autocfg.speaker_pins[2] = 0x16;
8381 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008382}
8383
8384static void alc883_mode2_unsol_event(struct hda_codec *codec,
8385 unsigned int res)
8386{
8387 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008388 case ALC880_MIC_EVENT:
8389 alc883_nb_mic_automute(codec);
8390 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008391 default:
8392 alc_sku_unsol_event(codec, res);
8393 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008394 }
8395}
8396
8397static void alc883_mode2_inithook(struct hda_codec *codec)
8398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008399 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008400 alc883_nb_mic_automute(codec);
8401}
8402
8403static struct hda_verb alc888_asus_eee1601_verbs[] = {
8404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8405 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8409 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8410 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8411 /* enable unsolicited event */
8412 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8413 { } /* end */
8414};
8415
Kailang Yange2757d52008-08-26 13:17:46 +02008416static void alc883_eee1601_inithook(struct hda_codec *codec)
8417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008418 struct alc_spec *spec = codec->spec;
8419
8420 spec->autocfg.hp_pins[0] = 0x14;
8421 spec->autocfg.speaker_pins[0] = 0x1b;
8422 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008423}
8424
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008425static struct hda_verb alc889A_mb31_verbs[] = {
8426 /* Init rear pin (used as headphone output) */
8427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8428 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8429 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8430 /* Init line pin (used as output in 4ch and 6ch mode) */
8431 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8432 /* Init line 2 pin (used as headphone out by default) */
8433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8435 { } /* end */
8436};
8437
8438/* Mute speakers according to the headphone jack state */
8439static void alc889A_mb31_automute(struct hda_codec *codec)
8440{
8441 unsigned int present;
8442
8443 /* Mute only in 2ch or 4ch mode */
8444 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8445 == 0x00) {
8446 present = snd_hda_codec_read(codec, 0x15, 0,
8447 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8448 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8449 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8450 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8451 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8452 }
8453}
8454
8455static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8456{
8457 if ((res >> 26) == ALC880_HP_EVENT)
8458 alc889A_mb31_automute(codec);
8459}
8460
Takashi Iwai4953550a2009-06-30 15:28:30 +02008461
Takashi Iwaicb53c622007-08-10 17:21:45 +02008462#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008463#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008464#endif
8465
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008466/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008467#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8468#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8469#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8470#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8471
8472static hda_nid_t alc883_slave_dig_outs[] = {
8473 ALC1200_DIGOUT_NID, 0,
8474};
8475
8476static hda_nid_t alc1200_slave_dig_outs[] = {
8477 ALC883_DIGOUT_NID, 0,
8478};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008479
8480/*
8481 * configuration and preset
8482 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008483static const char *alc882_models[ALC882_MODEL_LAST] = {
8484 [ALC882_3ST_DIG] = "3stack-dig",
8485 [ALC882_6ST_DIG] = "6stack-dig",
8486 [ALC882_ARIMA] = "arima",
8487 [ALC882_W2JC] = "w2jc",
8488 [ALC882_TARGA] = "targa",
8489 [ALC882_ASUS_A7J] = "asus-a7j",
8490 [ALC882_ASUS_A7M] = "asus-a7m",
8491 [ALC885_MACPRO] = "macpro",
8492 [ALC885_MB5] = "mb5",
8493 [ALC885_MBP3] = "mbp3",
8494 [ALC885_IMAC24] = "imac24",
8495 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008496 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8497 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008498 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008499 [ALC883_TARGA_DIG] = "targa-dig",
8500 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008501 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008502 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008503 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008504 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008505 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008506 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008507 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008508 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008509 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008510 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008511 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8512 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008513 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008514 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008515 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008516 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008517 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008518 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008519 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008520 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008521 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008522 [ALC889A_INTEL] = "intel-alc889a",
8523 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008524 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008525 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02008526 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008527 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008528};
8529
Takashi Iwai4953550a2009-06-30 15:28:30 +02008530static struct snd_pci_quirk alc882_cfg_tbl[] = {
8531 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8532
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008533 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008534 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008535 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008536 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8537 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008538 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008539 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8540 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008541 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8542 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008543 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8544 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008545 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8546 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008547 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8548 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008549 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008550 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008551 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008552 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008553 /* default Acer -- disabled as it causes more problems.
8554 * model=auto should work fine now
8555 */
8556 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008557
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008558 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008559
Tobin Davisfebe3372007-06-12 11:27:46 +02008560 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008561 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8562 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008563 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008564 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008565 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008566
8567 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8568 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8569 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008570 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008571 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8572 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8573 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008574 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008575 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008576 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008577 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008578
8579 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008580 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008581 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008582 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008583 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8584 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008585 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008586 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008587 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8588
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008589 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8590 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8591 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008592 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008593 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008594 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008595 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008596 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008597 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8598 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8599 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8600 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8601 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8602 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008603 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008604 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8605 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8606 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008607 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008608 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8609 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008610 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008611 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008612 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008613 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008614 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008615 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008616 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008617 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008618
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008619 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008620 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8621 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008622 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008623 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008624 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008625 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008626 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008627 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008628 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008629 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008630 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008631 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008632 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8633 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008634 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008635 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008636 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008637 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008638 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008639
Jiang zhe17bba1b2008-06-04 12:11:07 +02008640 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8641 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008642 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008643 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8644 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8645 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008646 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008647
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008648 {}
8649};
8650
Takashi Iwai4953550a2009-06-30 15:28:30 +02008651/* codec SSID table for Intel Mac */
8652static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8653 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8654 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8655 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8656 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8657 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8658 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8659 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8660 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8661 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8662 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8663 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8664 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8665 * no perfect solution yet
8666 */
8667 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8668 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008669};
8670
Takashi Iwai4953550a2009-06-30 15:28:30 +02008671static struct alc_config_preset alc882_presets[] = {
8672 [ALC882_3ST_DIG] = {
8673 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008674 .init_verbs = { alc882_base_init_verbs,
8675 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008676 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8677 .dac_nids = alc882_dac_nids,
8678 .dig_out_nid = ALC882_DIGOUT_NID,
8679 .dig_in_nid = ALC882_DIGIN_NID,
8680 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8681 .channel_mode = alc882_ch_modes,
8682 .need_dac_fix = 1,
8683 .input_mux = &alc882_capture_source,
8684 },
8685 [ALC882_6ST_DIG] = {
8686 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008687 .init_verbs = { alc882_base_init_verbs,
8688 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008689 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8690 .dac_nids = alc882_dac_nids,
8691 .dig_out_nid = ALC882_DIGOUT_NID,
8692 .dig_in_nid = ALC882_DIGIN_NID,
8693 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8694 .channel_mode = alc882_sixstack_modes,
8695 .input_mux = &alc882_capture_source,
8696 },
8697 [ALC882_ARIMA] = {
8698 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008699 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8700 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008701 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8702 .dac_nids = alc882_dac_nids,
8703 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8704 .channel_mode = alc882_sixstack_modes,
8705 .input_mux = &alc882_capture_source,
8706 },
8707 [ALC882_W2JC] = {
8708 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008709 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8710 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008711 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8712 .dac_nids = alc882_dac_nids,
8713 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8714 .channel_mode = alc880_threestack_modes,
8715 .need_dac_fix = 1,
8716 .input_mux = &alc882_capture_source,
8717 .dig_out_nid = ALC882_DIGOUT_NID,
8718 },
8719 [ALC885_MBP3] = {
8720 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8721 .init_verbs = { alc885_mbp3_init_verbs,
8722 alc880_gpio1_init_verbs },
8723 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8724 .dac_nids = alc882_dac_nids,
8725 .channel_mode = alc885_mbp_6ch_modes,
8726 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8727 .input_mux = &alc882_capture_source,
8728 .dig_out_nid = ALC882_DIGOUT_NID,
8729 .dig_in_nid = ALC882_DIGIN_NID,
8730 .unsol_event = alc_automute_amp_unsol_event,
8731 .init_hook = alc885_mbp3_init_hook,
8732 },
8733 [ALC885_MB5] = {
8734 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8735 .init_verbs = { alc885_mb5_init_verbs,
8736 alc880_gpio1_init_verbs },
8737 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8738 .dac_nids = alc882_dac_nids,
8739 .channel_mode = alc885_mb5_6ch_modes,
8740 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8741 .input_mux = &mb5_capture_source,
8742 .dig_out_nid = ALC882_DIGOUT_NID,
8743 .dig_in_nid = ALC882_DIGIN_NID,
8744 },
8745 [ALC885_MACPRO] = {
8746 .mixers = { alc882_macpro_mixer },
8747 .init_verbs = { alc882_macpro_init_verbs },
8748 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8749 .dac_nids = alc882_dac_nids,
8750 .dig_out_nid = ALC882_DIGOUT_NID,
8751 .dig_in_nid = ALC882_DIGIN_NID,
8752 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8753 .channel_mode = alc882_ch_modes,
8754 .input_mux = &alc882_capture_source,
8755 .init_hook = alc885_macpro_init_hook,
8756 },
8757 [ALC885_IMAC24] = {
8758 .mixers = { alc885_imac24_mixer },
8759 .init_verbs = { alc885_imac24_init_verbs },
8760 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8761 .dac_nids = alc882_dac_nids,
8762 .dig_out_nid = ALC882_DIGOUT_NID,
8763 .dig_in_nid = ALC882_DIGIN_NID,
8764 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8765 .channel_mode = alc882_ch_modes,
8766 .input_mux = &alc882_capture_source,
8767 .unsol_event = alc_automute_amp_unsol_event,
8768 .init_hook = alc885_imac24_init_hook,
8769 },
8770 [ALC882_TARGA] = {
8771 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008772 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008773 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008774 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8775 .dac_nids = alc882_dac_nids,
8776 .dig_out_nid = ALC882_DIGOUT_NID,
8777 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8778 .adc_nids = alc882_adc_nids,
8779 .capsrc_nids = alc882_capsrc_nids,
8780 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8781 .channel_mode = alc882_3ST_6ch_modes,
8782 .need_dac_fix = 1,
8783 .input_mux = &alc882_capture_source,
8784 .unsol_event = alc882_targa_unsol_event,
8785 .init_hook = alc882_targa_init_hook,
8786 },
8787 [ALC882_ASUS_A7J] = {
8788 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008789 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8790 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008791 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8792 .dac_nids = alc882_dac_nids,
8793 .dig_out_nid = ALC882_DIGOUT_NID,
8794 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8795 .adc_nids = alc882_adc_nids,
8796 .capsrc_nids = alc882_capsrc_nids,
8797 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8798 .channel_mode = alc882_3ST_6ch_modes,
8799 .need_dac_fix = 1,
8800 .input_mux = &alc882_capture_source,
8801 },
8802 [ALC882_ASUS_A7M] = {
8803 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008804 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8805 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008806 alc882_asus_a7m_verbs },
8807 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8808 .dac_nids = alc882_dac_nids,
8809 .dig_out_nid = ALC882_DIGOUT_NID,
8810 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8811 .channel_mode = alc880_threestack_modes,
8812 .need_dac_fix = 1,
8813 .input_mux = &alc882_capture_source,
8814 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008815 [ALC883_3ST_2ch_DIG] = {
8816 .mixers = { alc883_3ST_2ch_mixer },
8817 .init_verbs = { alc883_init_verbs },
8818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8819 .dac_nids = alc883_dac_nids,
8820 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008821 .dig_in_nid = ALC883_DIGIN_NID,
8822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8823 .channel_mode = alc883_3ST_2ch_modes,
8824 .input_mux = &alc883_capture_source,
8825 },
8826 [ALC883_3ST_6ch_DIG] = {
8827 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8828 .init_verbs = { alc883_init_verbs },
8829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8830 .dac_nids = alc883_dac_nids,
8831 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008832 .dig_in_nid = ALC883_DIGIN_NID,
8833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8834 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008835 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008836 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008837 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008838 [ALC883_3ST_6ch] = {
8839 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8840 .init_verbs = { alc883_init_verbs },
8841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8842 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008843 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8844 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008845 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008846 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008847 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008848 [ALC883_3ST_6ch_INTEL] = {
8849 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8850 .init_verbs = { alc883_init_verbs },
8851 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8852 .dac_nids = alc883_dac_nids,
8853 .dig_out_nid = ALC883_DIGOUT_NID,
8854 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008855 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008856 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8857 .channel_mode = alc883_3ST_6ch_intel_modes,
8858 .need_dac_fix = 1,
8859 .input_mux = &alc883_3stack_6ch_intel,
8860 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008861 [ALC889A_INTEL] = {
8862 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
8863 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs },
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
8866 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8867 .adc_nids = alc889_adc_nids,
8868 .dig_out_nid = ALC883_DIGOUT_NID,
8869 .dig_in_nid = ALC883_DIGIN_NID,
8870 .slave_dig_outs = alc883_slave_dig_outs,
8871 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
8872 .channel_mode = alc889_8ch_intel_modes,
8873 .capsrc_nids = alc889_capsrc_nids,
8874 .input_mux = &alc889_capture_source,
8875 .need_dac_fix = 1,
8876 },
8877 [ALC889_INTEL] = {
8878 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
8879 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
8880 alc889_eapd_verbs },
8881 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8882 .dac_nids = alc883_dac_nids,
8883 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8884 .adc_nids = alc889_adc_nids,
8885 .dig_out_nid = ALC883_DIGOUT_NID,
8886 .dig_in_nid = ALC883_DIGIN_NID,
8887 .slave_dig_outs = alc883_slave_dig_outs,
8888 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
8889 .channel_mode = alc889_8ch_intel_modes,
8890 .capsrc_nids = alc889_capsrc_nids,
8891 .input_mux = &alc889_capture_source,
8892 .init_hook = alc889_coef_init,
8893 .need_dac_fix = 1,
8894 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008895 [ALC883_6ST_DIG] = {
8896 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8897 .init_verbs = { alc883_init_verbs },
8898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8899 .dac_nids = alc883_dac_nids,
8900 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008901 .dig_in_nid = ALC883_DIGIN_NID,
8902 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8903 .channel_mode = alc883_sixstack_modes,
8904 .input_mux = &alc883_capture_source,
8905 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008906 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008907 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02008908 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8909 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008910 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8911 .dac_nids = alc883_dac_nids,
8912 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008913 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8914 .channel_mode = alc883_3ST_6ch_modes,
8915 .need_dac_fix = 1,
8916 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008917 .unsol_event = alc883_targa_unsol_event,
8918 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008919 },
8920 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008921 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02008922 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8923 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008924 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8925 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008926 .adc_nids = alc883_adc_nids_alt,
8927 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008928 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008929 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8930 .channel_mode = alc883_3ST_2ch_modes,
8931 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008932 .unsol_event = alc883_targa_unsol_event,
8933 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008934 },
David Heidelberger64a8be72009-06-08 16:15:18 +02008935 [ALC883_TARGA_8ch_DIG] = {
8936 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8937 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008938 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02008939 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8940 .dac_nids = alc883_dac_nids,
8941 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8942 .adc_nids = alc883_adc_nids_rev,
8943 .capsrc_nids = alc883_capsrc_nids_rev,
8944 .dig_out_nid = ALC883_DIGOUT_NID,
8945 .dig_in_nid = ALC883_DIGIN_NID,
8946 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
8947 .channel_mode = alc883_4ST_8ch_modes,
8948 .need_dac_fix = 1,
8949 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008950 .unsol_event = alc883_targa_unsol_event,
8951 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02008952 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008953 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008954 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008955 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8956 * and the headphone jack. Turn this on and rely on the
8957 * standard mute methods whenever the user wants to turn
8958 * these outputs off.
8959 */
8960 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8962 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008963 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8964 .channel_mode = alc883_3ST_2ch_modes,
8965 .input_mux = &alc883_capture_source,
8966 },
Tobin Davis2880a862007-08-07 11:50:26 +02008967 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008968 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008969 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8971 .dac_nids = alc883_dac_nids,
8972 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008973 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8974 .channel_mode = alc883_3ST_2ch_modes,
8975 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008976 .unsol_event = alc_automute_amp_unsol_event,
8977 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008978 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008979 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008980 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008981 alc883_chmode_mixer },
8982 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8983 alc888_acer_aspire_4930g_verbs },
8984 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8985 .dac_nids = alc883_dac_nids,
8986 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8987 .adc_nids = alc883_adc_nids_rev,
8988 .capsrc_nids = alc883_capsrc_nids_rev,
8989 .dig_out_nid = ALC883_DIGOUT_NID,
8990 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8991 .channel_mode = alc883_3ST_6ch_modes,
8992 .need_dac_fix = 1,
8993 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008994 ARRAY_SIZE(alc888_2_capture_sources),
8995 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008996 .unsol_event = alc_automute_amp_unsol_event,
8997 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008998 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01008999 [ALC888_ACER_ASPIRE_6530G] = {
9000 .mixers = { alc888_acer_aspire_6530_mixer },
9001 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9002 alc888_acer_aspire_6530g_verbs },
9003 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9004 .dac_nids = alc883_dac_nids,
9005 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9006 .adc_nids = alc883_adc_nids_rev,
9007 .capsrc_nids = alc883_capsrc_nids_rev,
9008 .dig_out_nid = ALC883_DIGOUT_NID,
9009 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9010 .channel_mode = alc883_3ST_2ch_modes,
9011 .num_mux_defs =
9012 ARRAY_SIZE(alc888_2_capture_sources),
9013 .input_mux = alc888_acer_aspire_6530_sources,
9014 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009015 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009016 },
Hector Martin3b315d72009-06-02 10:54:19 +02009017 [ALC888_ACER_ASPIRE_8930G] = {
9018 .mixers = { alc888_base_mixer,
9019 alc883_chmode_mixer },
9020 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009021 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009022 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9023 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009024 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9025 .adc_nids = alc889_adc_nids,
9026 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009027 .dig_out_nid = ALC883_DIGOUT_NID,
9028 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9029 .channel_mode = alc883_3ST_6ch_modes,
9030 .need_dac_fix = 1,
9031 .const_channel_count = 6,
9032 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009033 ARRAY_SIZE(alc889_capture_sources),
9034 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009035 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009036 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009037 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009038 [ALC883_MEDION] = {
9039 .mixers = { alc883_fivestack_mixer,
9040 alc883_chmode_mixer },
9041 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009042 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009043 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9044 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009045 .adc_nids = alc883_adc_nids_alt,
9046 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009047 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9048 .channel_mode = alc883_sixstack_modes,
9049 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009050 },
Kailang Yang272a5272007-05-14 11:00:38 +02009051 [ALC883_MEDION_MD2] = {
9052 .mixers = { alc883_medion_md2_mixer},
9053 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9054 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9055 .dac_nids = alc883_dac_nids,
9056 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009057 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9058 .channel_mode = alc883_3ST_2ch_modes,
9059 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009060 .unsol_event = alc_automute_amp_unsol_event,
9061 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009062 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009063 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009064 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009065 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9066 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9067 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009068 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9069 .channel_mode = alc883_3ST_2ch_modes,
9070 .input_mux = &alc883_capture_source,
9071 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009072 [ALC883_CLEVO_M720] = {
9073 .mixers = { alc883_clevo_m720_mixer },
9074 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9076 .dac_nids = alc883_dac_nids,
9077 .dig_out_nid = ALC883_DIGOUT_NID,
9078 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9079 .channel_mode = alc883_3ST_2ch_modes,
9080 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009081 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009082 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009083 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009084 [ALC883_LENOVO_101E_2ch] = {
9085 .mixers = { alc883_lenovo_101e_2ch_mixer},
9086 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9087 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9088 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009089 .adc_nids = alc883_adc_nids_alt,
9090 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009091 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9092 .channel_mode = alc883_3ST_2ch_modes,
9093 .input_mux = &alc883_lenovo_101e_capture_source,
9094 .unsol_event = alc883_lenovo_101e_unsol_event,
9095 .init_hook = alc883_lenovo_101e_all_automute,
9096 },
Kailang Yang272a5272007-05-14 11:00:38 +02009097 [ALC883_LENOVO_NB0763] = {
9098 .mixers = { alc883_lenovo_nb0763_mixer },
9099 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9101 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009102 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9103 .channel_mode = alc883_3ST_2ch_modes,
9104 .need_dac_fix = 1,
9105 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009106 .unsol_event = alc_automute_amp_unsol_event,
9107 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009108 },
9109 [ALC888_LENOVO_MS7195_DIG] = {
9110 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9111 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9112 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9113 .dac_nids = alc883_dac_nids,
9114 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009115 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9116 .channel_mode = alc883_3ST_6ch_modes,
9117 .need_dac_fix = 1,
9118 .input_mux = &alc883_capture_source,
9119 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9120 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009121 },
9122 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009123 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009124 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9126 .dac_nids = alc883_dac_nids,
9127 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009128 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9129 .channel_mode = alc883_3ST_2ch_modes,
9130 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009131 .unsol_event = alc_automute_amp_unsol_event,
9132 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009133 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009134 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009135 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009136 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9138 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009139 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9140 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009141 .need_dac_fix = 1,
9142 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009143 .unsol_event = alc_automute_amp_unsol_event,
9144 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009145 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009146 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009147 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009148 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9149 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9150 .dac_nids = alc883_dac_nids,
9151 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009152 .dig_in_nid = ALC883_DIGIN_NID,
9153 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9154 .channel_mode = alc883_sixstack_modes,
9155 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009156 .unsol_event = alc_automute_amp_unsol_event,
9157 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009158 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009159 [ALC883_MITAC] = {
9160 .mixers = { alc883_mitac_mixer },
9161 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9163 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009164 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9165 .channel_mode = alc883_3ST_2ch_modes,
9166 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009167 .unsol_event = alc_automute_amp_unsol_event,
9168 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009169 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009170 [ALC883_FUJITSU_PI2515] = {
9171 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9172 .init_verbs = { alc883_init_verbs,
9173 alc883_2ch_fujitsu_pi2515_verbs},
9174 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9175 .dac_nids = alc883_dac_nids,
9176 .dig_out_nid = ALC883_DIGOUT_NID,
9177 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9178 .channel_mode = alc883_3ST_2ch_modes,
9179 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009180 .unsol_event = alc_automute_amp_unsol_event,
9181 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009182 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009183 [ALC888_FUJITSU_XA3530] = {
9184 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9185 .init_verbs = { alc883_init_verbs,
9186 alc888_fujitsu_xa3530_verbs },
9187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9188 .dac_nids = alc883_dac_nids,
9189 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9190 .adc_nids = alc883_adc_nids_rev,
9191 .capsrc_nids = alc883_capsrc_nids_rev,
9192 .dig_out_nid = ALC883_DIGOUT_NID,
9193 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9194 .channel_mode = alc888_4ST_8ch_intel_modes,
9195 .num_mux_defs =
9196 ARRAY_SIZE(alc888_2_capture_sources),
9197 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009198 .unsol_event = alc_automute_amp_unsol_event,
9199 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009200 },
Kailang Yange2757d52008-08-26 13:17:46 +02009201 [ALC888_LENOVO_SKY] = {
9202 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9203 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9205 .dac_nids = alc883_dac_nids,
9206 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009207 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9208 .channel_mode = alc883_sixstack_modes,
9209 .need_dac_fix = 1,
9210 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009211 .unsol_event = alc_automute_amp_unsol_event,
9212 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009213 },
9214 [ALC888_ASUS_M90V] = {
9215 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9216 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9217 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9218 .dac_nids = alc883_dac_nids,
9219 .dig_out_nid = ALC883_DIGOUT_NID,
9220 .dig_in_nid = ALC883_DIGIN_NID,
9221 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9222 .channel_mode = alc883_3ST_6ch_modes,
9223 .need_dac_fix = 1,
9224 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9225 .unsol_event = alc883_mode2_unsol_event,
9226 .init_hook = alc883_mode2_inithook,
9227 },
9228 [ALC888_ASUS_EEE1601] = {
9229 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009230 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009231 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9232 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9233 .dac_nids = alc883_dac_nids,
9234 .dig_out_nid = ALC883_DIGOUT_NID,
9235 .dig_in_nid = ALC883_DIGIN_NID,
9236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9237 .channel_mode = alc883_3ST_2ch_modes,
9238 .need_dac_fix = 1,
9239 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009240 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009241 .init_hook = alc883_eee1601_inithook,
9242 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009243 [ALC1200_ASUS_P5Q] = {
9244 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9245 .init_verbs = { alc883_init_verbs },
9246 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9247 .dac_nids = alc883_dac_nids,
9248 .dig_out_nid = ALC1200_DIGOUT_NID,
9249 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009250 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009251 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9252 .channel_mode = alc883_sixstack_modes,
9253 .input_mux = &alc883_capture_source,
9254 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009255 [ALC889A_MB31] = {
9256 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9257 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9258 alc880_gpio1_init_verbs },
9259 .adc_nids = alc883_adc_nids,
9260 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9261 .dac_nids = alc883_dac_nids,
9262 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9263 .channel_mode = alc889A_mb31_6ch_modes,
9264 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9265 .input_mux = &alc889A_mb31_capture_source,
9266 .dig_out_nid = ALC883_DIGOUT_NID,
9267 .unsol_event = alc889A_mb31_unsol_event,
9268 .init_hook = alc889A_mb31_automute,
9269 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009270 [ALC883_SONY_VAIO_TT] = {
9271 .mixers = { alc883_vaiott_mixer },
9272 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9274 .dac_nids = alc883_dac_nids,
9275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9276 .channel_mode = alc883_3ST_2ch_modes,
9277 .input_mux = &alc883_capture_source,
9278 .unsol_event = alc_automute_amp_unsol_event,
9279 .init_hook = alc883_vaiott_init_hook,
9280 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009281};
9282
9283
9284/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009285 * Pin config fixes
9286 */
9287enum {
9288 PINFIX_ABIT_AW9D_MAX
9289};
9290
9291static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9292 { 0x15, 0x01080104 }, /* side */
9293 { 0x16, 0x01011012 }, /* rear */
9294 { 0x17, 0x01016011 }, /* clfe */
9295 { }
9296};
9297
9298static const struct alc_pincfg *alc882_pin_fixes[] = {
9299 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9300};
9301
9302static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9303 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9304 {}
9305};
9306
9307/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009308 * BIOS auto configuration
9309 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009310static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009311 hda_nid_t nid, int pin_type,
9312 int dac_idx)
9313{
9314 /* set as output */
9315 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009316 int idx;
9317
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009318 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009319 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9320 idx = 4;
9321 else
9322 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009323 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9324
9325}
9326
Takashi Iwai4953550a2009-06-30 15:28:30 +02009327static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009328{
9329 struct alc_spec *spec = codec->spec;
9330 int i;
9331
9332 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009333 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009334 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009335 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009336 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009337 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009338 }
9339}
9340
Takashi Iwai4953550a2009-06-30 15:28:30 +02009341static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009342{
9343 struct alc_spec *spec = codec->spec;
9344 hda_nid_t pin;
9345
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009346 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009347 if (pin) /* connect to front */
9348 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009349 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009350 pin = spec->autocfg.speaker_pins[0];
9351 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009352 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009353}
9354
Takashi Iwai4953550a2009-06-30 15:28:30 +02009355static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009356{
9357 struct alc_spec *spec = codec->spec;
9358 int i;
9359
9360 for (i = 0; i < AUTO_PIN_LAST; i++) {
9361 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009362 if (!nid)
9363 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009364 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009365 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9366 snd_hda_codec_write(codec, nid, 0,
9367 AC_VERB_SET_AMP_GAIN_MUTE,
9368 AMP_OUT_MUTE);
9369 }
9370}
9371
9372static void alc882_auto_init_input_src(struct hda_codec *codec)
9373{
9374 struct alc_spec *spec = codec->spec;
9375 int c;
9376
9377 for (c = 0; c < spec->num_adc_nids; c++) {
9378 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9379 hda_nid_t nid = spec->capsrc_nids[c];
9380 unsigned int mux_idx;
9381 const struct hda_input_mux *imux;
9382 int conns, mute, idx, item;
9383
9384 conns = snd_hda_get_connections(codec, nid, conn_list,
9385 ARRAY_SIZE(conn_list));
9386 if (conns < 0)
9387 continue;
9388 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9389 imux = &spec->input_mux[mux_idx];
9390 for (idx = 0; idx < conns; idx++) {
9391 /* if the current connection is the selected one,
9392 * unmute it as default - otherwise mute it
9393 */
9394 mute = AMP_IN_MUTE(idx);
9395 for (item = 0; item < imux->num_items; item++) {
9396 if (imux->items[item].index == idx) {
9397 if (spec->cur_mux[c] == item)
9398 mute = AMP_IN_UNMUTE(idx);
9399 break;
9400 }
9401 }
9402 /* check if we have a selector or mixer
9403 * we could check for the widget type instead, but
9404 * just check for Amp-In presence (in case of mixer
9405 * without amp-in there is something wrong, this
9406 * function shouldn't be used or capsrc nid is wrong)
9407 */
9408 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009409 snd_hda_codec_write(codec, nid, 0,
9410 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009411 mute);
9412 else if (mute != AMP_IN_MUTE(idx))
9413 snd_hda_codec_write(codec, nid, 0,
9414 AC_VERB_SET_CONNECT_SEL,
9415 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009416 }
9417 }
9418}
9419
Takashi Iwai4953550a2009-06-30 15:28:30 +02009420/* add mic boosts if needed */
9421static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009422{
9423 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009424 int err;
9425 hda_nid_t nid;
9426
9427 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9428 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9429 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9430 "Mic Boost",
9431 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9432 if (err < 0)
9433 return err;
9434 }
9435 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9436 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9437 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9438 "Front Mic Boost",
9439 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9440 if (err < 0)
9441 return err;
9442 }
9443 return 0;
9444}
9445
9446/* almost identical with ALC880 parser... */
9447static int alc882_parse_auto_config(struct hda_codec *codec)
9448{
9449 struct alc_spec *spec = codec->spec;
9450 struct auto_pin_cfg *autocfg = &spec->autocfg;
9451 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009452 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009453 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009454
9455 if (err < 0)
9456 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009457 else if (!err)
9458 return 0; /* no config found */
9459
9460 err = alc_auto_add_mic_boost(codec);
9461 if (err < 0)
9462 return err;
9463
9464 /* hack - override the init verbs */
9465 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009466 /* if ADC 0x07 is available, initialize it, too */
9467 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009468 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009469 if (wcap == AC_WID_AUD_IN)
9470 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009471
Takashi Iwai4953550a2009-06-30 15:28:30 +02009472 /* digital-mic input pin is excluded in alc880_auto_create..()
9473 * because it's under 0x18
9474 */
9475 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9476 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9477 struct hda_input_mux *imux = &spec->private_imux[0];
9478 for (i = 1; i < 3; i++)
9479 memcpy(&spec->private_imux[i],
9480 &spec->private_imux[0],
9481 sizeof(spec->private_imux[0]));
9482 imux->items[imux->num_items].label = "Int DMic";
9483 imux->items[imux->num_items].index = 0x0b;
9484 imux->num_items++;
9485 spec->num_mux_defs = 3;
9486 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009487 }
9488
Takashi Iwai776e1842007-08-29 15:07:11 +02009489 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009490}
9491
9492/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009493static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009494{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009495 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009496 alc882_auto_init_multi_out(codec);
9497 alc882_auto_init_hp_out(codec);
9498 alc882_auto_init_analog_input(codec);
9499 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009500 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009501 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009502}
9503
Takashi Iwai4953550a2009-06-30 15:28:30 +02009504static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009505{
9506 struct alc_spec *spec;
9507 int err, board_config;
9508
9509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9510 if (spec == NULL)
9511 return -ENOMEM;
9512
9513 codec->spec = spec;
9514
Takashi Iwai4953550a2009-06-30 15:28:30 +02009515 switch (codec->vendor_id) {
9516 case 0x10ec0882:
9517 case 0x10ec0885:
9518 break;
9519 default:
9520 /* ALC883 and variants */
9521 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9522 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009523 }
9524
Takashi Iwai4953550a2009-06-30 15:28:30 +02009525 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9526 alc882_models,
9527 alc882_cfg_tbl);
9528
9529 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9530 board_config = snd_hda_check_board_codec_sid_config(codec,
9531 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9532
9533 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009534 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009535 codec->chip_name);
9536 board_config = ALC882_AUTO;
9537 }
9538
9539 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9540
9541 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009543 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009544 if (err < 0) {
9545 alc_free(codec);
9546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009547 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009548 printk(KERN_INFO
9549 "hda_codec: Cannot set up configuration "
9550 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009551 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009552 }
9553 }
9554
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009555 err = snd_hda_attach_beep_device(codec, 0x1);
9556 if (err < 0) {
9557 alc_free(codec);
9558 return err;
9559 }
9560
Takashi Iwai4953550a2009-06-30 15:28:30 +02009561 if (board_config != ALC882_AUTO)
9562 setup_preset(spec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009563
Takashi Iwai4953550a2009-06-30 15:28:30 +02009564 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9565 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9566 /* FIXME: setup DAC5 */
9567 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9568 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9569
9570 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9571 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9572
9573 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009574 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009575
9576 if (!spec->adc_nids && spec->input_mux) {
9577 int i;
9578 spec->num_adc_nids = 0;
9579 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9580 hda_nid_t cap;
9581 hda_nid_t nid = alc882_adc_nids[i];
9582 unsigned int wcap = get_wcaps(codec, nid);
9583 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009584 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009585 if (wcap != AC_WID_AUD_IN)
9586 continue;
9587 spec->private_adc_nids[spec->num_adc_nids] = nid;
9588 err = snd_hda_get_connections(codec, nid, &cap, 1);
9589 if (err < 0)
9590 continue;
9591 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9592 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009593 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009594 spec->adc_nids = spec->private_adc_nids;
9595 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009596 }
9597
Takashi Iwai4953550a2009-06-30 15:28:30 +02009598 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009599 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009600
Takashi Iwai2134ea42008-01-10 16:53:55 +01009601 spec->vmaster_nid = 0x0c;
9602
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009603 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009604 if (board_config == ALC882_AUTO)
9605 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009606#ifdef CONFIG_SND_HDA_POWER_SAVE
9607 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009608 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009609#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009610 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009611
9612 return 0;
9613}
9614
Takashi Iwai4953550a2009-06-30 15:28:30 +02009615
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009616/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009617 * ALC262 support
9618 */
9619
9620#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9621#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9622
9623#define alc262_dac_nids alc260_dac_nids
9624#define alc262_adc_nids alc882_adc_nids
9625#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009626#define alc262_capsrc_nids alc882_capsrc_nids
9627#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009628
9629#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009630#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009631
Kailang Yang4e555fe2008-08-26 13:05:55 +02009632static hda_nid_t alc262_dmic_adc_nids[1] = {
9633 /* ADC0 */
9634 0x09
9635};
9636
9637static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9638
Kailang Yangdf694da2005-12-05 19:42:22 +01009639static struct snd_kcontrol_new alc262_base_mixer[] = {
9640 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9641 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009648 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9650 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009651 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009656 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009657};
9658
Takashi Iwaice875f02008-01-28 18:17:43 +01009659/* update HP, line and mono-out pins according to the master switch */
9660static void alc262_hp_master_update(struct hda_codec *codec)
9661{
9662 struct alc_spec *spec = codec->spec;
9663 int val = spec->master_sw;
9664
9665 /* HP & line-out */
9666 snd_hda_codec_write_cache(codec, 0x1b, 0,
9667 AC_VERB_SET_PIN_WIDGET_CONTROL,
9668 val ? PIN_HP : 0);
9669 snd_hda_codec_write_cache(codec, 0x15, 0,
9670 AC_VERB_SET_PIN_WIDGET_CONTROL,
9671 val ? PIN_HP : 0);
9672 /* mono (speaker) depending on the HP jack sense */
9673 val = val && !spec->jack_present;
9674 snd_hda_codec_write_cache(codec, 0x16, 0,
9675 AC_VERB_SET_PIN_WIDGET_CONTROL,
9676 val ? PIN_OUT : 0);
9677}
9678
9679static void alc262_hp_bpc_automute(struct hda_codec *codec)
9680{
9681 struct alc_spec *spec = codec->spec;
9682 unsigned int presence;
9683 presence = snd_hda_codec_read(codec, 0x1b, 0,
9684 AC_VERB_GET_PIN_SENSE, 0);
9685 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9686 alc262_hp_master_update(codec);
9687}
9688
9689static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9690{
9691 if ((res >> 26) != ALC880_HP_EVENT)
9692 return;
9693 alc262_hp_bpc_automute(codec);
9694}
9695
9696static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9697{
9698 struct alc_spec *spec = codec->spec;
9699 unsigned int presence;
9700 presence = snd_hda_codec_read(codec, 0x15, 0,
9701 AC_VERB_GET_PIN_SENSE, 0);
9702 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9703 alc262_hp_master_update(codec);
9704}
9705
9706static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9707 unsigned int res)
9708{
9709 if ((res >> 26) != ALC880_HP_EVENT)
9710 return;
9711 alc262_hp_wildwest_automute(codec);
9712}
9713
Takashi Iwaib72519b2009-05-08 14:31:55 +02009714#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009715
9716static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9717 struct snd_ctl_elem_value *ucontrol)
9718{
9719 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9720 struct alc_spec *spec = codec->spec;
9721 int val = !!*ucontrol->value.integer.value;
9722
9723 if (val == spec->master_sw)
9724 return 0;
9725 spec->master_sw = val;
9726 alc262_hp_master_update(codec);
9727 return 1;
9728}
9729
Takashi Iwaib72519b2009-05-08 14:31:55 +02009730#define ALC262_HP_MASTER_SWITCH \
9731 { \
9732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9733 .name = "Master Playback Switch", \
9734 .info = snd_ctl_boolean_mono_info, \
9735 .get = alc262_hp_master_sw_get, \
9736 .put = alc262_hp_master_sw_put, \
9737 }
9738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009740 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9742 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009744 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9745 HDA_OUTPUT),
9746 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9747 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009750 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9752 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009753 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009754 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9755 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009758 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9759 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9760 { } /* end */
9761};
9762
Kailang Yangcd7509a2007-01-26 18:33:17 +01009763static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009764 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009765 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9766 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009769 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9770 HDA_OUTPUT),
9771 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9772 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009773 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9774 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009775 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9778 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9779 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009780 { } /* end */
9781};
9782
9783static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9784 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9785 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009786 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009787 { } /* end */
9788};
9789
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009790/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009791static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009792{
9793 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009794
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009795 spec->autocfg.hp_pins[0] = 0x15;
9796 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9797 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009798}
9799
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009800static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009801 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9802 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009803 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9808 { } /* end */
9809};
9810
9811static struct hda_verb alc262_hp_t5735_verbs[] = {
9812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9813 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9814
9815 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9816 { }
9817};
9818
Kailang Yang8c427222008-01-10 13:03:59 +01009819static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9823 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009824 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9825 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9826 { } /* end */
9827};
9828
9829static struct hda_verb alc262_hp_rp5700_verbs[] = {
9830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9831 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9832 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9834 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9835 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9836 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9838 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9840 {}
9841};
9842
9843static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9844 .num_items = 1,
9845 .items = {
9846 { "Line", 0x1 },
9847 },
9848};
9849
Takashi Iwai42171c12009-05-08 14:11:43 +02009850/* bind hp and internal speaker mute (with plug check) as master switch */
9851static void alc262_hippo_master_update(struct hda_codec *codec)
9852{
9853 struct alc_spec *spec = codec->spec;
9854 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9855 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9856 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9857 unsigned int mute;
9858
9859 /* HP */
9860 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9861 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9862 HDA_AMP_MUTE, mute);
9863 /* mute internal speaker per jack sense */
9864 if (spec->jack_present)
9865 mute = HDA_AMP_MUTE;
9866 if (line_nid)
9867 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9868 HDA_AMP_MUTE, mute);
9869 if (speaker_nid && speaker_nid != line_nid)
9870 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9871 HDA_AMP_MUTE, mute);
9872}
9873
9874#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9875
9876static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9877 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009878{
9879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009880 struct alc_spec *spec = codec->spec;
9881 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009882
Takashi Iwai42171c12009-05-08 14:11:43 +02009883 if (val == spec->master_sw)
9884 return 0;
9885 spec->master_sw = val;
9886 alc262_hippo_master_update(codec);
9887 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009888}
Takashi Iwai5b319542007-07-26 11:49:22 +02009889
Takashi Iwai42171c12009-05-08 14:11:43 +02009890#define ALC262_HIPPO_MASTER_SWITCH \
9891 { \
9892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9893 .name = "Master Playback Switch", \
9894 .info = snd_ctl_boolean_mono_info, \
9895 .get = alc262_hippo_master_sw_get, \
9896 .put = alc262_hippo_master_sw_put, \
9897 }
9898
9899static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9900 ALC262_HIPPO_MASTER_SWITCH,
9901 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9904 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9905 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9908 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9911 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9913 { } /* end */
9914};
9915
9916static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9917 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9918 ALC262_HIPPO_MASTER_SWITCH,
9919 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9920 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9921 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9922 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9925 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9928 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9929 { } /* end */
9930};
9931
9932/* mute/unmute internal speaker according to the hp jack and mute state */
9933static void alc262_hippo_automute(struct hda_codec *codec)
9934{
9935 struct alc_spec *spec = codec->spec;
9936 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9937 unsigned int present;
9938
9939 /* need to execute and sync at first */
9940 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9941 present = snd_hda_codec_read(codec, hp_nid, 0,
9942 AC_VERB_GET_PIN_SENSE, 0);
9943 spec->jack_present = (present & 0x80000000) != 0;
9944 alc262_hippo_master_update(codec);
9945}
9946
9947static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9948{
9949 if ((res >> 26) != ALC880_HP_EVENT)
9950 return;
9951 alc262_hippo_automute(codec);
9952}
9953
9954static void alc262_hippo_init_hook(struct hda_codec *codec)
9955{
9956 struct alc_spec *spec = codec->spec;
9957
9958 spec->autocfg.hp_pins[0] = 0x15;
9959 spec->autocfg.speaker_pins[0] = 0x14;
9960 alc262_hippo_automute(codec);
9961}
9962
9963static void alc262_hippo1_init_hook(struct hda_codec *codec)
9964{
9965 struct alc_spec *spec = codec->spec;
9966
9967 spec->autocfg.hp_pins[0] = 0x1b;
9968 spec->autocfg.speaker_pins[0] = 0x14;
9969 alc262_hippo_automute(codec);
9970}
9971
9972
Kailang Yang272a5272007-05-14 11:00:38 +02009973static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009974 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009975 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9978 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9979 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9980 { } /* end */
9981};
9982
Kailang Yang83c34212007-07-05 11:43:05 +02009983static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009984 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9985 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9989 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9990 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9991 { } /* end */
9992};
Kailang Yang272a5272007-05-14 11:00:38 +02009993
Tony Vroonba340e82009-02-02 19:01:30 +00009994static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9995 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9996 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9997 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9998 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9999 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10000 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10003 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10004 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10005 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10006 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10007 { } /* end */
10008};
10009
10010static struct hda_verb alc262_tyan_verbs[] = {
10011 /* Headphone automute */
10012 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10013 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10014 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10015
10016 /* P11 AUX_IN, white 4-pin connector */
10017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10018 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10019 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10020 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10021
10022 {}
10023};
10024
10025/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010026static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010027{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010028 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010029
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010030 spec->autocfg.hp_pins[0] = 0x1b;
10031 spec->autocfg.speaker_pins[0] = 0x15;
10032 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010033}
10034
Tony Vroonba340e82009-02-02 19:01:30 +000010035
Kailang Yangdf694da2005-12-05 19:42:22 +010010036#define alc262_capture_mixer alc882_capture_mixer
10037#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10038
10039/*
10040 * generic initialization of ADC, input mixers and output mixers
10041 */
10042static struct hda_verb alc262_init_verbs[] = {
10043 /*
10044 * Unmute ADC0-2 and set the default input to mic-in
10045 */
10046 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10050 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10052
Takashi Iwaicb53c622007-08-10 17:21:45 +020010053 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010054 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010055 * Note: PASD motherboards uses the Line In 2 as the input for
10056 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010057 */
10058 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010064
10065 /*
10066 * Set up output mixers (0x0c - 0x0e)
10067 */
10068 /* set vol=0 to output mixers */
10069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10072 /* set up input amps for analog loopback */
10073 /* Amp Indices: DAC = 0, mixer = 1 */
10074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10080
10081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10084 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10086 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10087
10088 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010093
Kailang Yangdf694da2005-12-05 19:42:22 +010010094 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010096
Kailang Yangdf694da2005-12-05 19:42:22 +010010097 /* FIXME: use matrix-type input source selection */
10098 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10099 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10104 /* Input mixer2 */
10105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10109 /* Input mixer3 */
10110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010114
10115 { }
10116};
10117
Kailang Yang4e555fe2008-08-26 13:05:55 +020010118static struct hda_verb alc262_eapd_verbs[] = {
10119 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10120 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10121 { }
10122};
10123
Kailang Yangccc656c2006-10-17 12:32:26 +020010124static struct hda_verb alc262_hippo_unsol_verbs[] = {
10125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10127 {}
10128};
10129
10130static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10132 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10133 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10134
10135 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10137 {}
10138};
10139
Kailang Yang272a5272007-05-14 11:00:38 +020010140static struct hda_verb alc262_sony_unsol_verbs[] = {
10141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10142 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10143 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10144
10145 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010147 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010148};
10149
Kailang Yang4e555fe2008-08-26 13:05:55 +020010150static struct hda_input_mux alc262_dmic_capture_source = {
10151 .num_items = 2,
10152 .items = {
10153 { "Int DMic", 0x9 },
10154 { "Mic", 0x0 },
10155 },
10156};
10157
10158static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10160 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010164 { } /* end */
10165};
10166
10167static struct hda_verb alc262_toshiba_s06_verbs[] = {
10168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10172 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10174 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10175 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10176 {}
10177};
10178
10179static void alc262_dmic_automute(struct hda_codec *codec)
10180{
10181 unsigned int present;
10182
10183 present = snd_hda_codec_read(codec, 0x18, 0,
10184 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10185 snd_hda_codec_write(codec, 0x22, 0,
10186 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10187}
10188
Kailang Yang4e555fe2008-08-26 13:05:55 +020010189
10190/* unsolicited event for HP jack sensing */
10191static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10192 unsigned int res)
10193{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010194 if ((res >> 26) == ALC880_MIC_EVENT)
10195 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010196 else
10197 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010198}
10199
10200static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10201{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010202 struct alc_spec *spec = codec->spec;
10203
10204 spec->autocfg.hp_pins[0] = 0x15;
10205 spec->autocfg.speaker_pins[0] = 0x14;
10206 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010207 alc262_dmic_automute(codec);
10208}
10209
Takashi Iwai834be882006-03-01 14:16:17 +010010210/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010211 * nec model
10212 * 0x15 = headphone
10213 * 0x16 = internal speaker
10214 * 0x18 = external mic
10215 */
10216
10217static struct snd_kcontrol_new alc262_nec_mixer[] = {
10218 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10220
10221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10224
10225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10227 { } /* end */
10228};
10229
10230static struct hda_verb alc262_nec_verbs[] = {
10231 /* Unmute Speaker */
10232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10233
10234 /* Headphone */
10235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10237
10238 /* External mic to headphone */
10239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10240 /* External mic to speaker */
10241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10242 {}
10243};
10244
10245/*
Takashi Iwai834be882006-03-01 14:16:17 +010010246 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010247 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10248 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010249 */
10250
10251#define ALC_HP_EVENT 0x37
10252
10253static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10254 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010258 {}
10259};
10260
Jiang zhe0e31daf2008-03-20 12:12:39 +010010261static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10264 {}
10265};
10266
Takashi Iwai834be882006-03-01 14:16:17 +010010267static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010268 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010269 .items = {
10270 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010271 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010272 { "CD", 0x4 },
10273 },
10274};
10275
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010276static struct hda_input_mux alc262_HP_capture_source = {
10277 .num_items = 5,
10278 .items = {
10279 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010280 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010281 { "Line", 0x2 },
10282 { "CD", 0x4 },
10283 { "AUX IN", 0x6 },
10284 },
10285};
10286
zhejiangaccbe492007-08-31 12:36:05 +020010287static struct hda_input_mux alc262_HP_D7000_capture_source = {
10288 .num_items = 4,
10289 .items = {
10290 { "Mic", 0x0 },
10291 { "Front Mic", 0x2 },
10292 { "Line", 0x1 },
10293 { "CD", 0x4 },
10294 },
10295};
10296
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010297/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010298static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10299{
10300 struct alc_spec *spec = codec->spec;
10301 unsigned int mute;
10302
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010303 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010304 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010305 /* need to execute and sync at first */
10306 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010307 /* check laptop HP jack */
10308 present = snd_hda_codec_read(codec, 0x14, 0,
10309 AC_VERB_GET_PIN_SENSE, 0);
10310 /* need to execute and sync at first */
10311 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10312 /* check docking HP jack */
10313 present |= snd_hda_codec_read(codec, 0x1b, 0,
10314 AC_VERB_GET_PIN_SENSE, 0);
10315 if (present & AC_PINSENSE_PRESENCE)
10316 spec->jack_present = 1;
10317 else
10318 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010319 spec->sense_updated = 1;
10320 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010321 /* unmute internal speaker only if both HPs are unplugged and
10322 * master switch is on
10323 */
10324 if (spec->jack_present)
10325 mute = HDA_AMP_MUTE;
10326 else
Takashi Iwai834be882006-03-01 14:16:17 +010010327 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010328 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10329 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010330}
10331
10332/* unsolicited event for HP jack sensing */
10333static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10334 unsigned int res)
10335{
10336 if ((res >> 26) != ALC_HP_EVENT)
10337 return;
10338 alc262_fujitsu_automute(codec, 1);
10339}
10340
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010341static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10342{
10343 alc262_fujitsu_automute(codec, 1);
10344}
10345
Takashi Iwai834be882006-03-01 14:16:17 +010010346/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010347static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10348 .ops = &snd_hda_bind_vol,
10349 .values = {
10350 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10351 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10352 0
10353 },
10354};
Takashi Iwai834be882006-03-01 14:16:17 +010010355
Jiang zhe0e31daf2008-03-20 12:12:39 +010010356/* mute/unmute internal speaker according to the hp jack and mute state */
10357static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10358{
10359 struct alc_spec *spec = codec->spec;
10360 unsigned int mute;
10361
10362 if (force || !spec->sense_updated) {
10363 unsigned int present_int_hp;
10364 /* need to execute and sync at first */
10365 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10366 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10367 AC_VERB_GET_PIN_SENSE, 0);
10368 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10369 spec->sense_updated = 1;
10370 }
10371 if (spec->jack_present) {
10372 /* mute internal speaker */
10373 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10374 HDA_AMP_MUTE, HDA_AMP_MUTE);
10375 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10376 HDA_AMP_MUTE, HDA_AMP_MUTE);
10377 } else {
10378 /* unmute internal speaker if necessary */
10379 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10380 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10381 HDA_AMP_MUTE, mute);
10382 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10383 HDA_AMP_MUTE, mute);
10384 }
10385}
10386
10387/* unsolicited event for HP jack sensing */
10388static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10389 unsigned int res)
10390{
10391 if ((res >> 26) != ALC_HP_EVENT)
10392 return;
10393 alc262_lenovo_3000_automute(codec, 1);
10394}
10395
Takashi Iwai8de56b72009-07-24 16:51:47 +020010396static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10397 int dir, int idx, long *valp)
10398{
10399 int i, change = 0;
10400
10401 for (i = 0; i < 2; i++, valp++)
10402 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10403 HDA_AMP_MUTE,
10404 *valp ? 0 : HDA_AMP_MUTE);
10405 return change;
10406}
10407
Takashi Iwai834be882006-03-01 14:16:17 +010010408/* bind hp and internal speaker mute (with plug check) */
10409static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10410 struct snd_ctl_elem_value *ucontrol)
10411{
10412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10413 long *valp = ucontrol->value.integer.value;
10414 int change;
10415
Takashi Iwai8de56b72009-07-24 16:51:47 +020010416 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10417 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010418 if (change)
10419 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010420 return change;
10421}
10422
10423static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010424 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010425 {
10426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10427 .name = "Master Playback Switch",
10428 .info = snd_hda_mixer_amp_switch_info,
10429 .get = snd_hda_mixer_amp_switch_get,
10430 .put = alc262_fujitsu_master_sw_put,
10431 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10432 },
10433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10436 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010438 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10439 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10440 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010441 { } /* end */
10442};
10443
Jiang zhe0e31daf2008-03-20 12:12:39 +010010444/* bind hp and internal speaker mute (with plug check) */
10445static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10446 struct snd_ctl_elem_value *ucontrol)
10447{
10448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10449 long *valp = ucontrol->value.integer.value;
10450 int change;
10451
Takashi Iwai8de56b72009-07-24 16:51:47 +020010452 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010453 if (change)
10454 alc262_lenovo_3000_automute(codec, 0);
10455 return change;
10456}
10457
10458static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10459 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10460 {
10461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10462 .name = "Master Playback Switch",
10463 .info = snd_hda_mixer_amp_switch_info,
10464 .get = snd_hda_mixer_amp_switch_get,
10465 .put = alc262_lenovo_3000_master_sw_put,
10466 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10467 },
10468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10470 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10473 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10474 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10475 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10476 { } /* end */
10477};
10478
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010479static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10480 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010481 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10484 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10487 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10488 { } /* end */
10489};
10490
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010491/* additional init verbs for Benq laptops */
10492static struct hda_verb alc262_EAPD_verbs[] = {
10493 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10494 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10495 {}
10496};
10497
Kailang Yang83c34212007-07-05 11:43:05 +020010498static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10501
10502 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10503 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10504 {}
10505};
10506
Tobin Davisf651b502007-10-26 12:40:47 +020010507/* Samsung Q1 Ultra Vista model setup */
10508static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010509 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10510 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10513 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010514 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010515 { } /* end */
10516};
10517
10518static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010519 /* output mixer */
10520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10523 /* speaker */
10524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10527 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10528 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10533 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10534 /* internal mic */
10535 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10537 /* ADC, choose mic */
10538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10545 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010548 {}
10549};
10550
Tobin Davisf651b502007-10-26 12:40:47 +020010551/* mute/unmute internal speaker according to the hp jack and mute state */
10552static void alc262_ultra_automute(struct hda_codec *codec)
10553{
10554 struct alc_spec *spec = codec->spec;
10555 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010556
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010557 mute = 0;
10558 /* auto-mute only when HP is used as HP */
10559 if (!spec->cur_mux[0]) {
10560 unsigned int present;
10561 /* need to execute and sync at first */
10562 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10563 present = snd_hda_codec_read(codec, 0x15, 0,
10564 AC_VERB_GET_PIN_SENSE, 0);
10565 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10566 if (spec->jack_present)
10567 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010568 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010569 /* mute/unmute internal speaker */
10570 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10571 HDA_AMP_MUTE, mute);
10572 /* mute/unmute HP */
10573 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10574 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010575}
10576
10577/* unsolicited event for HP jack sensing */
10578static void alc262_ultra_unsol_event(struct hda_codec *codec,
10579 unsigned int res)
10580{
10581 if ((res >> 26) != ALC880_HP_EVENT)
10582 return;
10583 alc262_ultra_automute(codec);
10584}
10585
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010586static struct hda_input_mux alc262_ultra_capture_source = {
10587 .num_items = 2,
10588 .items = {
10589 { "Mic", 0x1 },
10590 { "Headphone", 0x7 },
10591 },
10592};
10593
10594static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10595 struct snd_ctl_elem_value *ucontrol)
10596{
10597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10598 struct alc_spec *spec = codec->spec;
10599 int ret;
10600
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010601 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010602 if (!ret)
10603 return 0;
10604 /* reprogram the HP pin as mic or HP according to the input source */
10605 snd_hda_codec_write_cache(codec, 0x15, 0,
10606 AC_VERB_SET_PIN_WIDGET_CONTROL,
10607 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10608 alc262_ultra_automute(codec); /* mute/unmute HP */
10609 return ret;
10610}
10611
10612static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10613 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10614 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10615 {
10616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10617 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010618 .info = alc_mux_enum_info,
10619 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010620 .put = alc262_ultra_mux_enum_put,
10621 },
10622 { } /* end */
10623};
10624
Kailang Yangdf694da2005-12-05 19:42:22 +010010625/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010626static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10627 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010628{
10629 hda_nid_t nid;
10630 int err;
10631
10632 spec->multiout.num_dacs = 1; /* only use one dac */
10633 spec->multiout.dac_nids = spec->private_dac_nids;
10634 spec->multiout.dac_nids[0] = 2;
10635
10636 nid = cfg->line_out_pins[0];
10637 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010638 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10639 "Front Playback Volume",
10640 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10641 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010642 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010643 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10644 "Front Playback Switch",
10645 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10646 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010647 return err;
10648 }
10649
Takashi Iwai82bc9552006-03-21 11:24:42 +010010650 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010651 if (nid) {
10652 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010653 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10654 "Speaker Playback Volume",
10655 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10656 HDA_OUTPUT));
10657 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010658 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010659 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10660 "Speaker Playback Switch",
10661 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10662 HDA_OUTPUT));
10663 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010664 return err;
10665 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010666 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10667 "Speaker Playback Switch",
10668 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10669 HDA_OUTPUT));
10670 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010671 return err;
10672 }
10673 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010674 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010675 if (nid) {
10676 /* spec->multiout.hp_nid = 2; */
10677 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010678 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10679 "Headphone Playback Volume",
10680 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10681 HDA_OUTPUT));
10682 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010683 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010684 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10685 "Headphone Playback Switch",
10686 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10687 HDA_OUTPUT));
10688 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010689 return err;
10690 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010691 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10692 "Headphone Playback Switch",
10693 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10694 HDA_OUTPUT));
10695 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010696 return err;
10697 }
10698 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010699 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010700}
10701
Takashi Iwai8c927b42009-06-22 10:56:54 +020010702static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10703 const struct auto_pin_cfg *cfg)
10704{
10705 int err;
10706
10707 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10708 if (err < 0)
10709 return err;
10710 /* digital-mic input pin is excluded in alc880_auto_create..()
10711 * because it's under 0x18
10712 */
10713 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10714 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10715 struct hda_input_mux *imux = &spec->private_imux[0];
10716 imux->items[imux->num_items].label = "Int Mic";
10717 imux->items[imux->num_items].index = 0x09;
10718 imux->num_items++;
10719 }
10720 return 0;
10721}
10722
Kailang Yangdf694da2005-12-05 19:42:22 +010010723
10724/*
10725 * generic initialization of ADC, input mixers and output mixers
10726 */
10727static struct hda_verb alc262_volume_init_verbs[] = {
10728 /*
10729 * Unmute ADC0-2 and set the default input to mic-in
10730 */
10731 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10733 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10735 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10737
Takashi Iwaicb53c622007-08-10 17:21:45 +020010738 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010739 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010740 * Note: PASD motherboards uses the Line In 2 as the input for
10741 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010742 */
10743 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010749
10750 /*
10751 * Set up output mixers (0x0c - 0x0f)
10752 */
10753 /* set vol=0 to output mixers */
10754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010757
Kailang Yangdf694da2005-12-05 19:42:22 +010010758 /* set up input amps for analog loopback */
10759 /* Amp Indices: DAC = 0, mixer = 1 */
10760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10761 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10762 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10763 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10764 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10765 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10766
10767 /* FIXME: use matrix-type input source selection */
10768 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10769 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10774 /* Input mixer2 */
10775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10779 /* Input mixer3 */
10780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10784
10785 { }
10786};
10787
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010788static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10789 /*
10790 * Unmute ADC0-2 and set the default input to mic-in
10791 */
10792 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10794 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10796 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798
Takashi Iwaicb53c622007-08-10 17:21:45 +020010799 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010800 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010801 * Note: PASD motherboards uses the Line In 2 as the input for
10802 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010803 */
10804 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10811 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010812
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010813 /*
10814 * Set up output mixers (0x0c - 0x0e)
10815 */
10816 /* set vol=0 to output mixers */
10817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10818 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10820
10821 /* set up input amps for analog loopback */
10822 /* Amp Indices: DAC = 0, mixer = 1 */
10823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10824 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10826 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10828 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10829
Takashi Iwaice875f02008-01-28 18:17:43 +010010830 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10832 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10833
10834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10836
10837 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10839
10840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10844 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10845
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010850 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10851 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10852
10853
10854 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010855 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10856 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010866 /* Input mixer2 */
10867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010876 /* Input mixer3 */
10877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010886
Takashi Iwaice875f02008-01-28 18:17:43 +010010887 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10888
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010889 { }
10890};
10891
Kailang Yangcd7509a2007-01-26 18:33:17 +010010892static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10893 /*
10894 * Unmute ADC0-2 and set the default input to mic-in
10895 */
10896 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10898 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10900 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10902
Takashi Iwaicb53c622007-08-10 17:21:45 +020010903 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010904 * mixer widget
10905 * Note: PASD motherboards uses the Line In 2 as the input for front
10906 * panel mic (mic 2)
10907 */
10908 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10914 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010917 /*
10918 * Set up output mixers (0x0c - 0x0e)
10919 */
10920 /* set vol=0 to output mixers */
10921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10924
10925 /* set up input amps for analog loopback */
10926 /* Amp Indices: DAC = 0, mixer = 1 */
10927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10929 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10930 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10932 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10933
10934
10935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10936 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10937 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10938 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10939 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10940 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10942
10943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10945
10946 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10947 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10948
10949 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10952 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10953 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10954 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10955
10956 /* FIXME: use matrix-type input source selection */
10957 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10958 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10962 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10963 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10964 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10965 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10966 /* Input mixer2 */
10967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10968 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10969 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10970 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10971 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10972 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10974 /* Input mixer3 */
10975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10980 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10982
Takashi Iwaice875f02008-01-28 18:17:43 +010010983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10984
Kailang Yangcd7509a2007-01-26 18:33:17 +010010985 { }
10986};
10987
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010988static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10989
10990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10991 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10992 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10993
10994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10996 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10997 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10998
10999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11002 {}
11003};
11004
11005
Takashi Iwaicb53c622007-08-10 17:21:45 +020011006#ifdef CONFIG_SND_HDA_POWER_SAVE
11007#define alc262_loopbacks alc880_loopbacks
11008#endif
11009
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011010/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011011#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11012#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11013#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11014#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11015
11016/*
11017 * BIOS auto configuration
11018 */
11019static int alc262_parse_auto_config(struct hda_codec *codec)
11020{
11021 struct alc_spec *spec = codec->spec;
11022 int err;
11023 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11024
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011025 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11026 alc262_ignore);
11027 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011028 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011029 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011030 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011031 spec->multiout.max_channels = 2;
11032 spec->no_analog = 1;
11033 goto dig_only;
11034 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011035 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011036 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011037 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11038 if (err < 0)
11039 return err;
11040 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11041 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011042 return err;
11043
11044 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11045
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011046 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011047 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011048 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011049 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011050 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011051 if (spec->autocfg.dig_in_pin)
11052 spec->dig_in_nid = ALC262_DIGIN_NID;
11053
Takashi Iwai603c4012008-07-30 15:01:44 +020011054 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011055 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011056
Takashi Iwaid88897e2008-10-31 15:01:37 +010011057 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011058 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011059 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011060
Takashi Iwai776e1842007-08-29 15:07:11 +020011061 err = alc_auto_add_mic_boost(codec);
11062 if (err < 0)
11063 return err;
11064
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011065 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11066
Kailang Yangdf694da2005-12-05 19:42:22 +010011067 return 1;
11068}
11069
11070#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11071#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11072#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011073#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011074
11075
11076/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011077static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011079 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011080 alc262_auto_init_multi_out(codec);
11081 alc262_auto_init_hp_out(codec);
11082 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011083 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011084 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011085 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011086}
11087
11088/*
11089 * configuration and preset
11090 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011091static const char *alc262_models[ALC262_MODEL_LAST] = {
11092 [ALC262_BASIC] = "basic",
11093 [ALC262_HIPPO] = "hippo",
11094 [ALC262_HIPPO_1] = "hippo_1",
11095 [ALC262_FUJITSU] = "fujitsu",
11096 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011097 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011098 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011099 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011100 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011101 [ALC262_BENQ_T31] = "benq-t31",
11102 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011103 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011104 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011105 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011106 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011107 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011108 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011109 [ALC262_AUTO] = "auto",
11110};
11111
11112static struct snd_pci_quirk alc262_cfg_tbl[] = {
11113 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011114 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011115 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11116 ALC262_HP_BPC),
11117 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11118 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011119 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11120 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011121 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011123 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011124 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011125 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011126 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011127 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011128 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011129 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11130 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11131 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011132 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11133 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011134 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011135 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011136 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011137 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011138 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011139 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011140 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11141 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011142 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011143 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011144 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011145 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011146 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011147 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011148 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11149 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011150 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011151 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011152 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011153 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011154 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011155 {}
11156};
11157
11158static struct alc_config_preset alc262_presets[] = {
11159 [ALC262_BASIC] = {
11160 .mixers = { alc262_base_mixer },
11161 .init_verbs = { alc262_init_verbs },
11162 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11163 .dac_nids = alc262_dac_nids,
11164 .hp_nid = 0x03,
11165 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11166 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011167 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011168 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011169 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011170 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011171 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11172 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11173 .dac_nids = alc262_dac_nids,
11174 .hp_nid = 0x03,
11175 .dig_out_nid = ALC262_DIGOUT_NID,
11176 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11177 .channel_mode = alc262_modes,
11178 .input_mux = &alc262_capture_source,
11179 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011180 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011181 },
11182 [ALC262_HIPPO_1] = {
11183 .mixers = { alc262_hippo1_mixer },
11184 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11185 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11186 .dac_nids = alc262_dac_nids,
11187 .hp_nid = 0x02,
11188 .dig_out_nid = ALC262_DIGOUT_NID,
11189 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11190 .channel_mode = alc262_modes,
11191 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011192 .unsol_event = alc262_hippo_unsol_event,
11193 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011194 },
Takashi Iwai834be882006-03-01 14:16:17 +010011195 [ALC262_FUJITSU] = {
11196 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011197 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11198 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011199 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11200 .dac_nids = alc262_dac_nids,
11201 .hp_nid = 0x03,
11202 .dig_out_nid = ALC262_DIGOUT_NID,
11203 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11204 .channel_mode = alc262_modes,
11205 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011206 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011207 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011208 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011209 [ALC262_HP_BPC] = {
11210 .mixers = { alc262_HP_BPC_mixer },
11211 .init_verbs = { alc262_HP_BPC_init_verbs },
11212 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11213 .dac_nids = alc262_dac_nids,
11214 .hp_nid = 0x03,
11215 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11216 .channel_mode = alc262_modes,
11217 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011218 .unsol_event = alc262_hp_bpc_unsol_event,
11219 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011220 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011221 [ALC262_HP_BPC_D7000_WF] = {
11222 .mixers = { alc262_HP_BPC_WildWest_mixer },
11223 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11224 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11225 .dac_nids = alc262_dac_nids,
11226 .hp_nid = 0x03,
11227 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11228 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011229 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011230 .unsol_event = alc262_hp_wildwest_unsol_event,
11231 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011232 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011233 [ALC262_HP_BPC_D7000_WL] = {
11234 .mixers = { alc262_HP_BPC_WildWest_mixer,
11235 alc262_HP_BPC_WildWest_option_mixer },
11236 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11237 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11238 .dac_nids = alc262_dac_nids,
11239 .hp_nid = 0x03,
11240 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11241 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011242 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011243 .unsol_event = alc262_hp_wildwest_unsol_event,
11244 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011245 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011246 [ALC262_HP_TC_T5735] = {
11247 .mixers = { alc262_hp_t5735_mixer },
11248 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11249 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11250 .dac_nids = alc262_dac_nids,
11251 .hp_nid = 0x03,
11252 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11253 .channel_mode = alc262_modes,
11254 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011255 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011256 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011257 },
11258 [ALC262_HP_RP5700] = {
11259 .mixers = { alc262_hp_rp5700_mixer },
11260 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11261 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11262 .dac_nids = alc262_dac_nids,
11263 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11264 .channel_mode = alc262_modes,
11265 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011266 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011267 [ALC262_BENQ_ED8] = {
11268 .mixers = { alc262_base_mixer },
11269 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11270 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11271 .dac_nids = alc262_dac_nids,
11272 .hp_nid = 0x03,
11273 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11274 .channel_mode = alc262_modes,
11275 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011276 },
Kailang Yang272a5272007-05-14 11:00:38 +020011277 [ALC262_SONY_ASSAMD] = {
11278 .mixers = { alc262_sony_mixer },
11279 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11280 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11281 .dac_nids = alc262_dac_nids,
11282 .hp_nid = 0x02,
11283 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11284 .channel_mode = alc262_modes,
11285 .input_mux = &alc262_capture_source,
11286 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011287 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011288 },
11289 [ALC262_BENQ_T31] = {
11290 .mixers = { alc262_benq_t31_mixer },
11291 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11292 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11293 .dac_nids = alc262_dac_nids,
11294 .hp_nid = 0x03,
11295 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11296 .channel_mode = alc262_modes,
11297 .input_mux = &alc262_capture_source,
11298 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011299 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011300 },
Tobin Davisf651b502007-10-26 12:40:47 +020011301 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011302 .mixers = { alc262_ultra_mixer },
11303 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011304 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011305 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11306 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011307 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11308 .channel_mode = alc262_modes,
11309 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011310 .adc_nids = alc262_adc_nids, /* ADC0 */
11311 .capsrc_nids = alc262_capsrc_nids,
11312 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011313 .unsol_event = alc262_ultra_unsol_event,
11314 .init_hook = alc262_ultra_automute,
11315 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011316 [ALC262_LENOVO_3000] = {
11317 .mixers = { alc262_lenovo_3000_mixer },
11318 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11319 alc262_lenovo_3000_unsol_verbs },
11320 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11321 .dac_nids = alc262_dac_nids,
11322 .hp_nid = 0x03,
11323 .dig_out_nid = ALC262_DIGOUT_NID,
11324 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11325 .channel_mode = alc262_modes,
11326 .input_mux = &alc262_fujitsu_capture_source,
11327 .unsol_event = alc262_lenovo_3000_unsol_event,
11328 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011329 [ALC262_NEC] = {
11330 .mixers = { alc262_nec_mixer },
11331 .init_verbs = { alc262_nec_verbs },
11332 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11333 .dac_nids = alc262_dac_nids,
11334 .hp_nid = 0x03,
11335 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11336 .channel_mode = alc262_modes,
11337 .input_mux = &alc262_capture_source,
11338 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011339 [ALC262_TOSHIBA_S06] = {
11340 .mixers = { alc262_toshiba_s06_mixer },
11341 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11342 alc262_eapd_verbs },
11343 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11344 .capsrc_nids = alc262_dmic_capsrc_nids,
11345 .dac_nids = alc262_dac_nids,
11346 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011347 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011348 .dig_out_nid = ALC262_DIGOUT_NID,
11349 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11350 .channel_mode = alc262_modes,
11351 .input_mux = &alc262_dmic_capture_source,
11352 .unsol_event = alc262_toshiba_s06_unsol_event,
11353 .init_hook = alc262_toshiba_s06_init_hook,
11354 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011355 [ALC262_TOSHIBA_RX1] = {
11356 .mixers = { alc262_toshiba_rx1_mixer },
11357 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11358 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11359 .dac_nids = alc262_dac_nids,
11360 .hp_nid = 0x03,
11361 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11362 .channel_mode = alc262_modes,
11363 .input_mux = &alc262_capture_source,
11364 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011365 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011366 },
Tony Vroonba340e82009-02-02 19:01:30 +000011367 [ALC262_TYAN] = {
11368 .mixers = { alc262_tyan_mixer },
11369 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11370 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11371 .dac_nids = alc262_dac_nids,
11372 .hp_nid = 0x02,
11373 .dig_out_nid = ALC262_DIGOUT_NID,
11374 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11375 .channel_mode = alc262_modes,
11376 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011377 .unsol_event = alc_automute_amp_unsol_event,
11378 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011379 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011380};
11381
11382static int patch_alc262(struct hda_codec *codec)
11383{
11384 struct alc_spec *spec;
11385 int board_config;
11386 int err;
11387
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011388 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011389 if (spec == NULL)
11390 return -ENOMEM;
11391
11392 codec->spec = spec;
11393#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011394 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11395 * under-run
11396 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011397 {
11398 int tmp;
11399 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11400 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11401 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11402 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11403 }
11404#endif
11405
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011406 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11407
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011408 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11409 alc262_models,
11410 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011411
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011412 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011413 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11414 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011415 board_config = ALC262_AUTO;
11416 }
11417
11418 if (board_config == ALC262_AUTO) {
11419 /* automatic parse from the BIOS config */
11420 err = alc262_parse_auto_config(codec);
11421 if (err < 0) {
11422 alc_free(codec);
11423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011425 printk(KERN_INFO
11426 "hda_codec: Cannot set up configuration "
11427 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011428 board_config = ALC262_BASIC;
11429 }
11430 }
11431
Takashi Iwai07eba612009-02-19 08:06:35 +010011432 if (!spec->no_analog) {
11433 err = snd_hda_attach_beep_device(codec, 0x1);
11434 if (err < 0) {
11435 alc_free(codec);
11436 return err;
11437 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011438 }
11439
Kailang Yangdf694da2005-12-05 19:42:22 +010011440 if (board_config != ALC262_AUTO)
11441 setup_preset(spec, &alc262_presets[board_config]);
11442
Kailang Yangdf694da2005-12-05 19:42:22 +010011443 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11444 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011445
Kailang Yangdf694da2005-12-05 19:42:22 +010011446 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11447 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011449 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011450 int i;
11451 /* check whether the digital-mic has to be supported */
11452 for (i = 0; i < spec->input_mux->num_items; i++) {
11453 if (spec->input_mux->items[i].index >= 9)
11454 break;
11455 }
11456 if (i < spec->input_mux->num_items) {
11457 /* use only ADC0 */
11458 spec->adc_nids = alc262_dmic_adc_nids;
11459 spec->num_adc_nids = 1;
11460 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011461 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011462 /* all analog inputs */
11463 /* check whether NID 0x07 is valid */
11464 unsigned int wcap = get_wcaps(codec, 0x07);
11465
11466 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011467 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011468 if (wcap != AC_WID_AUD_IN) {
11469 spec->adc_nids = alc262_adc_nids_alt;
11470 spec->num_adc_nids =
11471 ARRAY_SIZE(alc262_adc_nids_alt);
11472 spec->capsrc_nids = alc262_capsrc_nids_alt;
11473 } else {
11474 spec->adc_nids = alc262_adc_nids;
11475 spec->num_adc_nids =
11476 ARRAY_SIZE(alc262_adc_nids);
11477 spec->capsrc_nids = alc262_capsrc_nids;
11478 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011479 }
11480 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011481 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011482 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011483 if (!spec->no_analog)
11484 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011485
Takashi Iwai2134ea42008-01-10 16:53:55 +010011486 spec->vmaster_nid = 0x0c;
11487
Kailang Yangdf694da2005-12-05 19:42:22 +010011488 codec->patch_ops = alc_patch_ops;
11489 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011490 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011491#ifdef CONFIG_SND_HDA_POWER_SAVE
11492 if (!spec->loopback.amplist)
11493 spec->loopback.amplist = alc262_loopbacks;
11494#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011495 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011496
Kailang Yangdf694da2005-12-05 19:42:22 +010011497 return 0;
11498}
11499
Kailang Yangdf694da2005-12-05 19:42:22 +010011500/*
Kailang Yanga361d842007-06-05 12:30:55 +020011501 * ALC268 channel source setting (2 channel)
11502 */
11503#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11504#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011505
Kailang Yanga361d842007-06-05 12:30:55 +020011506static hda_nid_t alc268_dac_nids[2] = {
11507 /* front, hp */
11508 0x02, 0x03
11509};
11510
11511static hda_nid_t alc268_adc_nids[2] = {
11512 /* ADC0-1 */
11513 0x08, 0x07
11514};
11515
11516static hda_nid_t alc268_adc_nids_alt[1] = {
11517 /* ADC0 */
11518 0x08
11519};
11520
Takashi Iwaie1406342008-02-11 18:32:32 +010011521static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11522
Kailang Yanga361d842007-06-05 12:30:55 +020011523static struct snd_kcontrol_new alc268_base_mixer[] = {
11524 /* output mixer control */
11525 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11526 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11527 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11530 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11531 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011532 { }
11533};
11534
Takashi Iwai42171c12009-05-08 14:11:43 +020011535static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11536 /* output mixer control */
11537 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11538 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11539 ALC262_HIPPO_MASTER_SWITCH,
11540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11541 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11542 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11543 { }
11544};
11545
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011546/* bind Beep switches of both NID 0x0f and 0x10 */
11547static struct hda_bind_ctls alc268_bind_beep_sw = {
11548 .ops = &snd_hda_bind_sw,
11549 .values = {
11550 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11551 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11552 0
11553 },
11554};
11555
11556static struct snd_kcontrol_new alc268_beep_mixer[] = {
11557 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11558 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11559 { }
11560};
11561
Kailang Yangd1a991a2007-08-15 16:21:59 +020011562static struct hda_verb alc268_eapd_verbs[] = {
11563 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11564 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11565 { }
11566};
11567
Takashi Iwaid2738092007-08-16 14:59:45 +020011568/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011569static struct hda_verb alc268_toshiba_verbs[] = {
11570 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11571 { } /* end */
11572};
11573
Kailang Yang8ef355d2008-08-26 13:10:22 +020011574static struct hda_input_mux alc268_acer_lc_capture_source = {
11575 .num_items = 2,
11576 .items = {
11577 { "i-Mic", 0x6 },
11578 { "E-Mic", 0x0 },
11579 },
11580};
11581
Takashi Iwaid2738092007-08-16 14:59:45 +020011582/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011583/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011584static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11585 .ops = &snd_hda_bind_vol,
11586 .values = {
11587 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11588 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11589 0
11590 },
11591};
11592
Takashi Iwai889c4392007-08-23 18:56:52 +020011593/* mute/unmute internal speaker according to the hp jack and mute state */
11594static void alc268_acer_automute(struct hda_codec *codec, int force)
11595{
11596 struct alc_spec *spec = codec->spec;
11597 unsigned int mute;
11598
11599 if (force || !spec->sense_updated) {
11600 unsigned int present;
11601 present = snd_hda_codec_read(codec, 0x14, 0,
11602 AC_VERB_GET_PIN_SENSE, 0);
11603 spec->jack_present = (present & 0x80000000) != 0;
11604 spec->sense_updated = 1;
11605 }
11606 if (spec->jack_present)
11607 mute = HDA_AMP_MUTE; /* mute internal speaker */
11608 else /* unmute internal speaker if necessary */
11609 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11610 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11611 HDA_AMP_MUTE, mute);
11612}
11613
11614
11615/* bind hp and internal speaker mute (with plug check) */
11616static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11617 struct snd_ctl_elem_value *ucontrol)
11618{
11619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11620 long *valp = ucontrol->value.integer.value;
11621 int change;
11622
Takashi Iwai8de56b72009-07-24 16:51:47 +020011623 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011624 if (change)
11625 alc268_acer_automute(codec, 0);
11626 return change;
11627}
Takashi Iwaid2738092007-08-16 14:59:45 +020011628
Kailang Yang8ef355d2008-08-26 13:10:22 +020011629static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11630 /* output mixer control */
11631 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11632 {
11633 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11634 .name = "Master Playback Switch",
11635 .info = snd_hda_mixer_amp_switch_info,
11636 .get = snd_hda_mixer_amp_switch_get,
11637 .put = alc268_acer_master_sw_put,
11638 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11639 },
11640 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11641 { }
11642};
11643
Takashi Iwaid2738092007-08-16 14:59:45 +020011644static struct snd_kcontrol_new alc268_acer_mixer[] = {
11645 /* output mixer control */
11646 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11647 {
11648 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11649 .name = "Master Playback Switch",
11650 .info = snd_hda_mixer_amp_switch_info,
11651 .get = snd_hda_mixer_amp_switch_get,
11652 .put = alc268_acer_master_sw_put,
11653 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11654 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11656 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11657 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011658 { }
11659};
11660
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011661static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11662 /* output mixer control */
11663 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11664 {
11665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11666 .name = "Master Playback Switch",
11667 .info = snd_hda_mixer_amp_switch_info,
11668 .get = snd_hda_mixer_amp_switch_get,
11669 .put = alc268_acer_master_sw_put,
11670 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11671 },
11672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11673 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11674 { }
11675};
11676
Kailang Yang8ef355d2008-08-26 13:10:22 +020011677static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11680 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11681 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11682 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11684 { }
11685};
11686
Takashi Iwaid2738092007-08-16 14:59:45 +020011687static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011688 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11689 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11693 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011694 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11695 { }
11696};
11697
11698/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011699#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11700#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011701
11702static void alc268_acer_unsol_event(struct hda_codec *codec,
11703 unsigned int res)
11704{
Takashi Iwai889c4392007-08-23 18:56:52 +020011705 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011706 return;
11707 alc268_acer_automute(codec, 1);
11708}
11709
Takashi Iwai889c4392007-08-23 18:56:52 +020011710static void alc268_acer_init_hook(struct hda_codec *codec)
11711{
11712 alc268_acer_automute(codec, 1);
11713}
11714
Kailang Yang8ef355d2008-08-26 13:10:22 +020011715/* toggle speaker-output according to the hp-jack state */
11716static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11717{
11718 unsigned int present;
11719 unsigned char bits;
11720
11721 present = snd_hda_codec_read(codec, 0x15, 0,
11722 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11723 bits = present ? AMP_IN_MUTE(0) : 0;
11724 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11725 AMP_IN_MUTE(0), bits);
11726 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11727 AMP_IN_MUTE(0), bits);
11728}
11729
11730
11731static void alc268_acer_mic_automute(struct hda_codec *codec)
11732{
11733 unsigned int present;
11734
11735 present = snd_hda_codec_read(codec, 0x18, 0,
11736 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11737 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11738 present ? 0x0 : 0x6);
11739}
11740
11741static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11742 unsigned int res)
11743{
11744 if ((res >> 26) == ALC880_HP_EVENT)
11745 alc268_aspire_one_speaker_automute(codec);
11746 if ((res >> 26) == ALC880_MIC_EVENT)
11747 alc268_acer_mic_automute(codec);
11748}
11749
11750static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11751{
11752 alc268_aspire_one_speaker_automute(codec);
11753 alc268_acer_mic_automute(codec);
11754}
11755
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011756static struct snd_kcontrol_new alc268_dell_mixer[] = {
11757 /* output mixer control */
11758 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11759 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11762 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11763 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11764 { }
11765};
11766
11767static struct hda_verb alc268_dell_verbs[] = {
11768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11769 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11770 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11771 { }
11772};
11773
11774/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011775static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011776{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011777 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011778
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011779 spec->autocfg.hp_pins[0] = 0x15;
11780 spec->autocfg.speaker_pins[0] = 0x14;
11781 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011782}
11783
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011784static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11785 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11786 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11789 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11790 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11791 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11792 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11793 { }
11794};
11795
11796static struct hda_verb alc267_quanta_il1_verbs[] = {
11797 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11798 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11799 { }
11800};
11801
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011802static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11803{
11804 unsigned int present;
11805
11806 present = snd_hda_codec_read(codec, 0x18, 0,
11807 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11808 snd_hda_codec_write(codec, 0x23, 0,
11809 AC_VERB_SET_CONNECT_SEL,
11810 present ? 0x00 : 0x01);
11811}
11812
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011813static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011814{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011815 struct alc_spec *spec = codec->spec;
11816
11817 spec->autocfg.hp_pins[0] = 0x15;
11818 spec->autocfg.speaker_pins[0] = 0x14;
11819 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011820 alc267_quanta_il1_mic_automute(codec);
11821}
11822
11823static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11824 unsigned int res)
11825{
11826 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011827 case ALC880_MIC_EVENT:
11828 alc267_quanta_il1_mic_automute(codec);
11829 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011830 default:
11831 alc_sku_unsol_event(codec, res);
11832 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011833 }
11834}
11835
Kailang Yanga361d842007-06-05 12:30:55 +020011836/*
11837 * generic initialization of ADC, input mixers and output mixers
11838 */
11839static struct hda_verb alc268_base_init_verbs[] = {
11840 /* Unmute DAC0-1 and set vol = 0 */
11841 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011842 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011843
11844 /*
11845 * Set up output mixers (0x0c - 0x0e)
11846 */
11847 /* set vol=0 to output mixers */
11848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011849 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11850
11851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11852 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11853
11854 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11858 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11861 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11862
11863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011868
11869 /* set PCBEEP vol = 0, mute connections */
11870 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11871 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11872 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011873
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011874 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011875
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011876 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11878 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11879 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011880
Kailang Yanga361d842007-06-05 12:30:55 +020011881 { }
11882};
11883
11884/*
11885 * generic initialization of ADC, input mixers and output mixers
11886 */
11887static struct hda_verb alc268_volume_init_verbs[] = {
11888 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011889 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11890 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011891
11892 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11895 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11896 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11897
Kailang Yanga361d842007-06-05 12:30:55 +020011898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011899 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11900 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11901
11902 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011904
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011905 /* set PCBEEP vol = 0, mute connections */
11906 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11908 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011909
11910 { }
11911};
11912
Kailang Yanga361d842007-06-05 12:30:55 +020011913static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11914 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11915 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11916 {
11917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11918 /* The multiple "Capture Source" controls confuse alsamixer
11919 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011920 */
11921 /* .name = "Capture Source", */
11922 .name = "Input Source",
11923 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011924 .info = alc_mux_enum_info,
11925 .get = alc_mux_enum_get,
11926 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011927 },
11928 { } /* end */
11929};
11930
11931static struct snd_kcontrol_new alc268_capture_mixer[] = {
11932 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11933 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11934 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11935 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11936 {
11937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11938 /* The multiple "Capture Source" controls confuse alsamixer
11939 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011940 */
11941 /* .name = "Capture Source", */
11942 .name = "Input Source",
11943 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011944 .info = alc_mux_enum_info,
11945 .get = alc_mux_enum_get,
11946 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011947 },
11948 { } /* end */
11949};
11950
11951static struct hda_input_mux alc268_capture_source = {
11952 .num_items = 4,
11953 .items = {
11954 { "Mic", 0x0 },
11955 { "Front Mic", 0x1 },
11956 { "Line", 0x2 },
11957 { "CD", 0x3 },
11958 },
11959};
11960
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011961static struct hda_input_mux alc268_acer_capture_source = {
11962 .num_items = 3,
11963 .items = {
11964 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011965 { "Internal Mic", 0x1 },
11966 { "Line", 0x2 },
11967 },
11968};
11969
11970static struct hda_input_mux alc268_acer_dmic_capture_source = {
11971 .num_items = 3,
11972 .items = {
11973 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011974 { "Internal Mic", 0x6 },
11975 { "Line", 0x2 },
11976 },
11977};
11978
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011979#ifdef CONFIG_SND_DEBUG
11980static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011981 /* Volume widgets */
11982 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11983 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11984 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11985 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11986 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11987 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11988 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11989 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11990 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11991 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11992 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11993 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11994 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011995 /* The below appears problematic on some hardwares */
11996 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011997 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11998 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11999 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12000 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12001
12002 /* Modes for retasking pin widgets */
12003 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12004 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12005 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12006 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12007
12008 /* Controls for GPIO pins, assuming they are configured as outputs */
12009 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12010 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12011 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12012 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12013
12014 /* Switches to allow the digital SPDIF output pin to be enabled.
12015 * The ALC268 does not have an SPDIF input.
12016 */
12017 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12018
12019 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12020 * this output to turn on an external amplifier.
12021 */
12022 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12023 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12024
12025 { } /* end */
12026};
12027#endif
12028
Kailang Yanga361d842007-06-05 12:30:55 +020012029/* create input playback/capture controls for the given pin */
12030static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12031 const char *ctlname, int idx)
12032{
12033 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012034 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012035 int err;
12036
12037 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012038 switch (nid) {
12039 case 0x14:
12040 case 0x16:
12041 dac = 0x02;
12042 break;
12043 case 0x15:
12044 dac = 0x03;
12045 break;
12046 default:
12047 return 0;
12048 }
12049 if (spec->multiout.dac_nids[0] != dac &&
12050 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012051 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012052 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012053 HDA_OUTPUT));
12054 if (err < 0)
12055 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012056 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12057 }
12058
Kailang Yanga361d842007-06-05 12:30:55 +020012059 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012060 if (nid != 0x16)
12061 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012062 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012063 else /* mono */
12064 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12065 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012066 if (err < 0)
12067 return err;
12068 return 0;
12069}
12070
12071/* add playback controls from the parsed DAC table */
12072static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12073 const struct auto_pin_cfg *cfg)
12074{
12075 hda_nid_t nid;
12076 int err;
12077
Kailang Yanga361d842007-06-05 12:30:55 +020012078 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012079
12080 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012081 if (nid) {
12082 const char *name;
12083 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12084 name = "Speaker";
12085 else
12086 name = "Front";
12087 err = alc268_new_analog_output(spec, nid, name, 0);
12088 if (err < 0)
12089 return err;
12090 }
Kailang Yanga361d842007-06-05 12:30:55 +020012091
12092 nid = cfg->speaker_pins[0];
12093 if (nid == 0x1d) {
12094 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12095 "Speaker Playback Volume",
12096 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12097 if (err < 0)
12098 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012099 } else {
12100 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12101 if (err < 0)
12102 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012103 }
12104 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012105 if (nid) {
12106 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12107 if (err < 0)
12108 return err;
12109 }
Kailang Yanga361d842007-06-05 12:30:55 +020012110
12111 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12112 if (nid == 0x16) {
12113 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12114 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012115 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012116 if (err < 0)
12117 return err;
12118 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012119 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012120}
12121
12122/* create playback/capture controls for input pins */
12123static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12124 const struct auto_pin_cfg *cfg)
12125{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012126 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012127 int i, idx1;
12128
12129 for (i = 0; i < AUTO_PIN_LAST; i++) {
12130 switch(cfg->input_pins[i]) {
12131 case 0x18:
12132 idx1 = 0; /* Mic 1 */
12133 break;
12134 case 0x19:
12135 idx1 = 1; /* Mic 2 */
12136 break;
12137 case 0x1a:
12138 idx1 = 2; /* Line In */
12139 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012140 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012141 idx1 = 3; /* CD */
12142 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012143 case 0x12:
12144 case 0x13:
12145 idx1 = 6; /* digital mics */
12146 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012147 default:
12148 continue;
12149 }
12150 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12151 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012152 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012153 }
12154 return 0;
12155}
12156
12157static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12158{
12159 struct alc_spec *spec = codec->spec;
12160 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12161 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12162 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12163 unsigned int dac_vol1, dac_vol2;
12164
12165 if (speaker_nid) {
12166 snd_hda_codec_write(codec, speaker_nid, 0,
12167 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12168 snd_hda_codec_write(codec, 0x0f, 0,
12169 AC_VERB_SET_AMP_GAIN_MUTE,
12170 AMP_IN_UNMUTE(1));
12171 snd_hda_codec_write(codec, 0x10, 0,
12172 AC_VERB_SET_AMP_GAIN_MUTE,
12173 AMP_IN_UNMUTE(1));
12174 } else {
12175 snd_hda_codec_write(codec, 0x0f, 0,
12176 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12177 snd_hda_codec_write(codec, 0x10, 0,
12178 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12179 }
12180
12181 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012182 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012183 dac_vol2 = AMP_OUT_ZERO;
12184 else if (line_nid == 0x15)
12185 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012186 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012187 dac_vol2 = AMP_OUT_ZERO;
12188 else if (hp_nid == 0x15)
12189 dac_vol1 = AMP_OUT_ZERO;
12190 if (line_nid != 0x16 || hp_nid != 0x16 ||
12191 spec->autocfg.line_out_pins[1] != 0x16 ||
12192 spec->autocfg.line_out_pins[2] != 0x16)
12193 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12194
12195 snd_hda_codec_write(codec, 0x02, 0,
12196 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12197 snd_hda_codec_write(codec, 0x03, 0,
12198 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12199}
12200
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012201/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012202#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12203#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012204#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012205#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12206
12207/*
12208 * BIOS auto configuration
12209 */
12210static int alc268_parse_auto_config(struct hda_codec *codec)
12211{
12212 struct alc_spec *spec = codec->spec;
12213 int err;
12214 static hda_nid_t alc268_ignore[] = { 0 };
12215
12216 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12217 alc268_ignore);
12218 if (err < 0)
12219 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012220 if (!spec->autocfg.line_outs) {
12221 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12222 spec->multiout.max_channels = 2;
12223 spec->no_analog = 1;
12224 goto dig_only;
12225 }
Kailang Yanga361d842007-06-05 12:30:55 +020012226 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012227 }
Kailang Yanga361d842007-06-05 12:30:55 +020012228 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12229 if (err < 0)
12230 return err;
12231 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12232 if (err < 0)
12233 return err;
12234
12235 spec->multiout.max_channels = 2;
12236
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012237 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012238 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012239 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012240 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012241 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12242 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012243 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012244 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012245
Takashi Iwai892981f2009-03-02 08:04:35 +010012246 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012247 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012248
Takashi Iwaid88897e2008-10-31 15:01:37 +010012249 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012250 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012251 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012252
Takashi Iwai776e1842007-08-29 15:07:11 +020012253 err = alc_auto_add_mic_boost(codec);
12254 if (err < 0)
12255 return err;
12256
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012257 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12258
Kailang Yanga361d842007-06-05 12:30:55 +020012259 return 1;
12260}
12261
12262#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12263#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12264#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12265
12266/* init callback for auto-configuration model -- overriding the default init */
12267static void alc268_auto_init(struct hda_codec *codec)
12268{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012269 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012270 alc268_auto_init_multi_out(codec);
12271 alc268_auto_init_hp_out(codec);
12272 alc268_auto_init_mono_speaker_out(codec);
12273 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012274 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012275 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012276}
12277
12278/*
12279 * configuration and preset
12280 */
12281static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012282 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012283 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012284 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012285 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012286 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012287 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012288 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012289 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012290#ifdef CONFIG_SND_DEBUG
12291 [ALC268_TEST] = "test",
12292#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012293 [ALC268_AUTO] = "auto",
12294};
12295
12296static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012297 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012298 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012299 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012300 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012301 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012302 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12303 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012304 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012305 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012306 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12307 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012308 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012309 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12310 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12311 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012312 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012313 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012314 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012315 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012316 {}
12317};
12318
12319static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012320 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012321 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012322 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12323 alc267_quanta_il1_verbs },
12324 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12325 .dac_nids = alc268_dac_nids,
12326 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12327 .adc_nids = alc268_adc_nids_alt,
12328 .hp_nid = 0x03,
12329 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12330 .channel_mode = alc268_modes,
12331 .input_mux = &alc268_capture_source,
12332 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012333 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012334 },
Kailang Yanga361d842007-06-05 12:30:55 +020012335 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012336 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12337 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012338 .init_verbs = { alc268_base_init_verbs },
12339 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12340 .dac_nids = alc268_dac_nids,
12341 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12342 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012343 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012344 .hp_nid = 0x03,
12345 .dig_out_nid = ALC268_DIGOUT_NID,
12346 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12347 .channel_mode = alc268_modes,
12348 .input_mux = &alc268_capture_source,
12349 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012350 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012351 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012352 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012353 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12354 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012355 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12356 .dac_nids = alc268_dac_nids,
12357 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12358 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012359 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012360 .hp_nid = 0x03,
12361 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12362 .channel_mode = alc268_modes,
12363 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012364 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012365 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012366 },
12367 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012368 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12369 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012370 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12371 alc268_acer_verbs },
12372 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12373 .dac_nids = alc268_dac_nids,
12374 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12375 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012376 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012377 .hp_nid = 0x02,
12378 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12379 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012380 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012381 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012382 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012383 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012384 [ALC268_ACER_DMIC] = {
12385 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12386 alc268_beep_mixer },
12387 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12388 alc268_acer_verbs },
12389 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12390 .dac_nids = alc268_dac_nids,
12391 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12392 .adc_nids = alc268_adc_nids_alt,
12393 .capsrc_nids = alc268_capsrc_nids,
12394 .hp_nid = 0x02,
12395 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12396 .channel_mode = alc268_modes,
12397 .input_mux = &alc268_acer_dmic_capture_source,
12398 .unsol_event = alc268_acer_unsol_event,
12399 .init_hook = alc268_acer_init_hook,
12400 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012401 [ALC268_ACER_ASPIRE_ONE] = {
12402 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012403 alc268_beep_mixer,
12404 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012405 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12406 alc268_acer_aspire_one_verbs },
12407 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12408 .dac_nids = alc268_dac_nids,
12409 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12410 .adc_nids = alc268_adc_nids_alt,
12411 .capsrc_nids = alc268_capsrc_nids,
12412 .hp_nid = 0x03,
12413 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12414 .channel_mode = alc268_modes,
12415 .input_mux = &alc268_acer_lc_capture_source,
12416 .unsol_event = alc268_acer_lc_unsol_event,
12417 .init_hook = alc268_acer_lc_init_hook,
12418 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012419 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012420 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012421 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12422 alc268_dell_verbs },
12423 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12424 .dac_nids = alc268_dac_nids,
12425 .hp_nid = 0x02,
12426 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12427 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012428 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012429 .init_hook = alc268_dell_init_hook,
12430 .input_mux = &alc268_capture_source,
12431 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012432 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012433 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12434 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012435 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12436 alc268_toshiba_verbs },
12437 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12438 .dac_nids = alc268_dac_nids,
12439 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12440 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012441 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012442 .hp_nid = 0x03,
12443 .dig_out_nid = ALC268_DIGOUT_NID,
12444 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12445 .channel_mode = alc268_modes,
12446 .input_mux = &alc268_capture_source,
12447 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012448 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012449 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012450#ifdef CONFIG_SND_DEBUG
12451 [ALC268_TEST] = {
12452 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12453 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12454 alc268_volume_init_verbs },
12455 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12456 .dac_nids = alc268_dac_nids,
12457 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12458 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012459 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012460 .hp_nid = 0x03,
12461 .dig_out_nid = ALC268_DIGOUT_NID,
12462 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12463 .channel_mode = alc268_modes,
12464 .input_mux = &alc268_capture_source,
12465 },
12466#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012467};
12468
12469static int patch_alc268(struct hda_codec *codec)
12470{
12471 struct alc_spec *spec;
12472 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012473 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012474
12475 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12476 if (spec == NULL)
12477 return -ENOMEM;
12478
12479 codec->spec = spec;
12480
12481 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12482 alc268_models,
12483 alc268_cfg_tbl);
12484
12485 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012486 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12487 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012488 board_config = ALC268_AUTO;
12489 }
12490
12491 if (board_config == ALC268_AUTO) {
12492 /* automatic parse from the BIOS config */
12493 err = alc268_parse_auto_config(codec);
12494 if (err < 0) {
12495 alc_free(codec);
12496 return err;
12497 } else if (!err) {
12498 printk(KERN_INFO
12499 "hda_codec: Cannot set up configuration "
12500 "from BIOS. Using base mode...\n");
12501 board_config = ALC268_3ST;
12502 }
12503 }
12504
12505 if (board_config != ALC268_AUTO)
12506 setup_preset(spec, &alc268_presets[board_config]);
12507
Kailang Yanga361d842007-06-05 12:30:55 +020012508 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12509 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012510 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012511
Kailang Yanga361d842007-06-05 12:30:55 +020012512 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12513
Takashi Iwai22971e32009-02-10 11:56:44 +010012514 has_beep = 0;
12515 for (i = 0; i < spec->num_mixers; i++) {
12516 if (spec->mixers[i] == alc268_beep_mixer) {
12517 has_beep = 1;
12518 break;
12519 }
12520 }
12521
12522 if (has_beep) {
12523 err = snd_hda_attach_beep_device(codec, 0x1);
12524 if (err < 0) {
12525 alc_free(codec);
12526 return err;
12527 }
12528 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12529 /* override the amp caps for beep generator */
12530 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012531 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12532 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12533 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12534 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012535 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012536
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012537 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012538 /* check whether NID 0x07 is valid */
12539 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012540 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012541
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012542 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012543 wcap = get_wcaps_type(wcap);
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012544 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012545 spec->adc_nids = alc268_adc_nids_alt;
12546 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012547 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012548 } else {
12549 spec->adc_nids = alc268_adc_nids;
12550 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012551 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012552 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012553 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012554 /* set default input source */
12555 for (i = 0; i < spec->num_adc_nids; i++)
12556 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12557 0, AC_VERB_SET_CONNECT_SEL,
12558 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012559 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012560
12561 spec->vmaster_nid = 0x02;
12562
Kailang Yanga361d842007-06-05 12:30:55 +020012563 codec->patch_ops = alc_patch_ops;
12564 if (board_config == ALC268_AUTO)
12565 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012566
Takashi Iwaidaead532008-11-28 12:55:36 +010012567 codec->proc_widget_hook = print_realtek_coef;
12568
Kailang Yanga361d842007-06-05 12:30:55 +020012569 return 0;
12570}
12571
12572/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012573 * ALC269 channel source setting (2 channel)
12574 */
12575#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12576
12577#define alc269_dac_nids alc260_dac_nids
12578
12579static hda_nid_t alc269_adc_nids[1] = {
12580 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012581 0x08,
12582};
12583
Takashi Iwaie01bf502008-08-21 16:25:07 +020012584static hda_nid_t alc269_capsrc_nids[1] = {
12585 0x23,
12586};
12587
12588/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12589 * not a mux!
12590 */
12591
Kailang Yangf53281e2008-07-18 12:36:43 +020012592static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12593 .num_items = 2,
12594 .items = {
12595 { "i-Mic", 0x5 },
12596 { "e-Mic", 0x0 },
12597 },
12598};
12599
12600static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12601 .num_items = 2,
12602 .items = {
12603 { "i-Mic", 0x1 },
12604 { "e-Mic", 0x0 },
12605 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012606};
12607
12608#define alc269_modes alc260_modes
12609#define alc269_capture_source alc880_lg_lw_capture_source
12610
12611static struct snd_kcontrol_new alc269_base_mixer[] = {
12612 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12613 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12621 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12623 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12624 { } /* end */
12625};
12626
Kailang Yang60db6b52008-08-26 13:13:00 +020012627static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12628 /* output mixer control */
12629 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12630 {
12631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12632 .name = "Master Playback Switch",
12633 .info = snd_hda_mixer_amp_switch_info,
12634 .get = snd_hda_mixer_amp_switch_get,
12635 .put = alc268_acer_master_sw_put,
12636 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12637 },
12638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12641 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12642 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12643 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012644 { }
12645};
12646
Tony Vroon64154832008-11-06 15:08:49 +000012647static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12648 /* output mixer control */
12649 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12650 {
12651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12652 .name = "Master Playback Switch",
12653 .info = snd_hda_mixer_amp_switch_info,
12654 .get = snd_hda_mixer_amp_switch_get,
12655 .put = alc268_acer_master_sw_put,
12656 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12657 },
12658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12661 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12662 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12663 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12664 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12665 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12666 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012667 { }
12668};
12669
Kailang Yangf53281e2008-07-18 12:36:43 +020012670static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012671 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012672 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012674 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012675 { } /* end */
12676};
12677
Kailang Yangf6a92242007-12-13 16:52:54 +010012678/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012679static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12680 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12681 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012682 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12683 { } /* end */
12684};
12685
12686/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012687#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012688
Kailang Yang60db6b52008-08-26 13:13:00 +020012689static struct hda_verb alc269_quanta_fl1_verbs[] = {
12690 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12691 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12693 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12694 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12695 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12696 { }
12697};
12698
Tony Vroon64154832008-11-06 15:08:49 +000012699static struct hda_verb alc269_lifebook_verbs[] = {
12700 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12701 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12702 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12703 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12706 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12707 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12708 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12709 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12710 { }
12711};
12712
Kailang Yang60db6b52008-08-26 13:13:00 +020012713/* toggle speaker-output according to the hp-jack state */
12714static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12715{
12716 unsigned int present;
12717 unsigned char bits;
12718
12719 present = snd_hda_codec_read(codec, 0x15, 0,
12720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12721 bits = present ? AMP_IN_MUTE(0) : 0;
12722 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12723 AMP_IN_MUTE(0), bits);
12724 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12725 AMP_IN_MUTE(0), bits);
12726
12727 snd_hda_codec_write(codec, 0x20, 0,
12728 AC_VERB_SET_COEF_INDEX, 0x0c);
12729 snd_hda_codec_write(codec, 0x20, 0,
12730 AC_VERB_SET_PROC_COEF, 0x680);
12731
12732 snd_hda_codec_write(codec, 0x20, 0,
12733 AC_VERB_SET_COEF_INDEX, 0x0c);
12734 snd_hda_codec_write(codec, 0x20, 0,
12735 AC_VERB_SET_PROC_COEF, 0x480);
12736}
12737
Tony Vroon64154832008-11-06 15:08:49 +000012738/* toggle speaker-output according to the hp-jacks state */
12739static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12740{
12741 unsigned int present;
12742 unsigned char bits;
12743
12744 /* Check laptop headphone socket */
12745 present = snd_hda_codec_read(codec, 0x15, 0,
12746 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12747
12748 /* Check port replicator headphone socket */
12749 present |= snd_hda_codec_read(codec, 0x1a, 0,
12750 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12751
12752 bits = present ? AMP_IN_MUTE(0) : 0;
12753 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12754 AMP_IN_MUTE(0), bits);
12755 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12756 AMP_IN_MUTE(0), bits);
12757
12758 snd_hda_codec_write(codec, 0x20, 0,
12759 AC_VERB_SET_COEF_INDEX, 0x0c);
12760 snd_hda_codec_write(codec, 0x20, 0,
12761 AC_VERB_SET_PROC_COEF, 0x680);
12762
12763 snd_hda_codec_write(codec, 0x20, 0,
12764 AC_VERB_SET_COEF_INDEX, 0x0c);
12765 snd_hda_codec_write(codec, 0x20, 0,
12766 AC_VERB_SET_PROC_COEF, 0x480);
12767}
12768
Kailang Yang60db6b52008-08-26 13:13:00 +020012769static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12770{
12771 unsigned int present;
12772
12773 present = snd_hda_codec_read(codec, 0x18, 0,
12774 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12775 snd_hda_codec_write(codec, 0x23, 0,
12776 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12777}
12778
Tony Vroon64154832008-11-06 15:08:49 +000012779static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12780{
12781 unsigned int present_laptop;
12782 unsigned int present_dock;
12783
12784 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12785 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12786
12787 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12788 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12789
12790 /* Laptop mic port overrides dock mic port, design decision */
12791 if (present_dock)
12792 snd_hda_codec_write(codec, 0x23, 0,
12793 AC_VERB_SET_CONNECT_SEL, 0x3);
12794 if (present_laptop)
12795 snd_hda_codec_write(codec, 0x23, 0,
12796 AC_VERB_SET_CONNECT_SEL, 0x0);
12797 if (!present_dock && !present_laptop)
12798 snd_hda_codec_write(codec, 0x23, 0,
12799 AC_VERB_SET_CONNECT_SEL, 0x1);
12800}
12801
Kailang Yang60db6b52008-08-26 13:13:00 +020012802static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12803 unsigned int res)
12804{
12805 if ((res >> 26) == ALC880_HP_EVENT)
12806 alc269_quanta_fl1_speaker_automute(codec);
12807 if ((res >> 26) == ALC880_MIC_EVENT)
12808 alc269_quanta_fl1_mic_automute(codec);
12809}
12810
Tony Vroon64154832008-11-06 15:08:49 +000012811static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12812 unsigned int res)
12813{
12814 if ((res >> 26) == ALC880_HP_EVENT)
12815 alc269_lifebook_speaker_automute(codec);
12816 if ((res >> 26) == ALC880_MIC_EVENT)
12817 alc269_lifebook_mic_autoswitch(codec);
12818}
12819
Kailang Yang60db6b52008-08-26 13:13:00 +020012820static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12821{
12822 alc269_quanta_fl1_speaker_automute(codec);
12823 alc269_quanta_fl1_mic_automute(codec);
12824}
12825
Tony Vroon64154832008-11-06 15:08:49 +000012826static void alc269_lifebook_init_hook(struct hda_codec *codec)
12827{
12828 alc269_lifebook_speaker_automute(codec);
12829 alc269_lifebook_mic_autoswitch(codec);
12830}
12831
Kailang Yang60db6b52008-08-26 13:13:00 +020012832static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12833 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12834 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12835 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12836 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12837 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12838 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12839 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12840 {}
12841};
12842
12843static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12844 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12845 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12846 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12848 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12849 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12850 {}
12851};
12852
12853/* toggle speaker-output according to the hp-jack state */
12854static void alc269_speaker_automute(struct hda_codec *codec)
12855{
12856 unsigned int present;
12857 unsigned char bits;
12858
12859 present = snd_hda_codec_read(codec, 0x15, 0,
12860 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12861 bits = present ? AMP_IN_MUTE(0) : 0;
12862 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12863 AMP_IN_MUTE(0), bits);
12864 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12865 AMP_IN_MUTE(0), bits);
12866}
12867
12868static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12869{
12870 unsigned int present;
12871
12872 present = snd_hda_codec_read(codec, 0x18, 0,
12873 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12874 snd_hda_codec_write(codec, 0x23, 0,
12875 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12876}
12877
12878static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12879{
12880 unsigned int present;
12881
12882 present = snd_hda_codec_read(codec, 0x18, 0,
12883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12884 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12885 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12886 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12887 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12888}
12889
12890/* unsolicited event for HP jack sensing */
12891static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12892 unsigned int res)
12893{
12894 if ((res >> 26) == ALC880_HP_EVENT)
12895 alc269_speaker_automute(codec);
12896
12897 if ((res >> 26) == ALC880_MIC_EVENT)
12898 alc269_eeepc_dmic_automute(codec);
12899}
12900
12901static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12902{
12903 alc269_speaker_automute(codec);
12904 alc269_eeepc_dmic_automute(codec);
12905}
12906
12907/* unsolicited event for HP jack sensing */
12908static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12909 unsigned int res)
12910{
12911 if ((res >> 26) == ALC880_HP_EVENT)
12912 alc269_speaker_automute(codec);
12913
12914 if ((res >> 26) == ALC880_MIC_EVENT)
12915 alc269_eeepc_amic_automute(codec);
12916}
12917
12918static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12919{
12920 alc269_speaker_automute(codec);
12921 alc269_eeepc_amic_automute(codec);
12922}
12923
Kailang Yangf6a92242007-12-13 16:52:54 +010012924/*
12925 * generic initialization of ADC, input mixers and output mixers
12926 */
12927static struct hda_verb alc269_init_verbs[] = {
12928 /*
12929 * Unmute ADC0 and set the default input to mic-in
12930 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012932
12933 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12934 * analog-loopback mixer widget
12935 * Note: PASD motherboards uses the Line In 2 as the input for
12936 * front panel mic (mic 2)
12937 */
12938 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12944
12945 /*
12946 * Set up output mixers (0x0c - 0x0e)
12947 */
12948 /* set vol=0 to output mixers */
12949 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12950 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12951
12952 /* set up input amps for analog loopback */
12953 /* Amp Indices: DAC = 0, mixer = 1 */
12954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12960
12961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12963 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12964 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12965 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12966 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12967 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12968
12969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12971 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12976
12977 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12979
12980 /* FIXME: use matrix-type input source selection */
12981 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12982 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12987
12988 /* set EAPD */
12989 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12990 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12991 { }
12992};
12993
12994/* add playback controls from the parsed DAC table */
12995static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12996 const struct auto_pin_cfg *cfg)
12997{
12998 hda_nid_t nid;
12999 int err;
13000
13001 spec->multiout.num_dacs = 1; /* only use one dac */
13002 spec->multiout.dac_nids = spec->private_dac_nids;
13003 spec->multiout.dac_nids[0] = 2;
13004
13005 nid = cfg->line_out_pins[0];
13006 if (nid) {
13007 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13008 "Front Playback Volume",
13009 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13010 if (err < 0)
13011 return err;
13012 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13013 "Front Playback Switch",
13014 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13015 if (err < 0)
13016 return err;
13017 }
13018
13019 nid = cfg->speaker_pins[0];
13020 if (nid) {
13021 if (!cfg->line_out_pins[0]) {
13022 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13023 "Speaker Playback Volume",
13024 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13025 HDA_OUTPUT));
13026 if (err < 0)
13027 return err;
13028 }
13029 if (nid == 0x16) {
13030 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13031 "Speaker Playback Switch",
13032 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13033 HDA_OUTPUT));
13034 if (err < 0)
13035 return err;
13036 } else {
13037 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13038 "Speaker Playback Switch",
13039 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13040 HDA_OUTPUT));
13041 if (err < 0)
13042 return err;
13043 }
13044 }
13045 nid = cfg->hp_pins[0];
13046 if (nid) {
13047 /* spec->multiout.hp_nid = 2; */
13048 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13049 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13050 "Headphone Playback Volume",
13051 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13052 HDA_OUTPUT));
13053 if (err < 0)
13054 return err;
13055 }
13056 if (nid == 0x16) {
13057 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13058 "Headphone Playback Switch",
13059 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13060 HDA_OUTPUT));
13061 if (err < 0)
13062 return err;
13063 } else {
13064 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13065 "Headphone Playback Switch",
13066 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13067 HDA_OUTPUT));
13068 if (err < 0)
13069 return err;
13070 }
13071 }
13072 return 0;
13073}
13074
Takashi Iwai8c927b42009-06-22 10:56:54 +020013075#define alc269_auto_create_analog_input_ctls \
13076 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013077
13078#ifdef CONFIG_SND_HDA_POWER_SAVE
13079#define alc269_loopbacks alc880_loopbacks
13080#endif
13081
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013082/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013083#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13084#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13085#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13086#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13087
Takashi Iwaif03d3112009-03-05 14:18:16 +010013088static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13089 .substreams = 1,
13090 .channels_min = 2,
13091 .channels_max = 8,
13092 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13093 /* NID is set in alc_build_pcms */
13094 .ops = {
13095 .open = alc880_playback_pcm_open,
13096 .prepare = alc880_playback_pcm_prepare,
13097 .cleanup = alc880_playback_pcm_cleanup
13098 },
13099};
13100
13101static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13102 .substreams = 1,
13103 .channels_min = 2,
13104 .channels_max = 2,
13105 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13106 /* NID is set in alc_build_pcms */
13107};
13108
Kailang Yangf6a92242007-12-13 16:52:54 +010013109/*
13110 * BIOS auto configuration
13111 */
13112static int alc269_parse_auto_config(struct hda_codec *codec)
13113{
13114 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013115 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013116 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13117
13118 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13119 alc269_ignore);
13120 if (err < 0)
13121 return err;
13122
13123 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13124 if (err < 0)
13125 return err;
13126 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13127 if (err < 0)
13128 return err;
13129
13130 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13131
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013132 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013133 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13134
Takashi Iwai603c4012008-07-30 15:01:44 +020013135 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013136 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013137
Takashi Iwaid88897e2008-10-31 15:01:37 +010013138 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013139 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013140 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013141 /* set default input source */
13142 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13143 0, AC_VERB_SET_CONNECT_SEL,
13144 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013145
13146 err = alc_auto_add_mic_boost(codec);
13147 if (err < 0)
13148 return err;
13149
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013150 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013151 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013152
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013153 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13154
Kailang Yangf6a92242007-12-13 16:52:54 +010013155 return 1;
13156}
13157
13158#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13159#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13160#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13161
13162
13163/* init callback for auto-configuration model -- overriding the default init */
13164static void alc269_auto_init(struct hda_codec *codec)
13165{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013166 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013167 alc269_auto_init_multi_out(codec);
13168 alc269_auto_init_hp_out(codec);
13169 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013170 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013171 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013172}
13173
13174/*
13175 * configuration and preset
13176 */
13177static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013178 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013179 [ALC269_QUANTA_FL1] = "quanta",
13180 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013181 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013182 [ALC269_FUJITSU] = "fujitsu",
13183 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013184};
13185
13186static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013187 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013188 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13189 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013190 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13191 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13192 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13193 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13194 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13195 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013196 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13197 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013198 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13199 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013200 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013201 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013202 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013203 {}
13204};
13205
13206static struct alc_config_preset alc269_presets[] = {
13207 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013208 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013209 .init_verbs = { alc269_init_verbs },
13210 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13211 .dac_nids = alc269_dac_nids,
13212 .hp_nid = 0x03,
13213 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13214 .channel_mode = alc269_modes,
13215 .input_mux = &alc269_capture_source,
13216 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013217 [ALC269_QUANTA_FL1] = {
13218 .mixers = { alc269_quanta_fl1_mixer },
13219 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13220 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13221 .dac_nids = alc269_dac_nids,
13222 .hp_nid = 0x03,
13223 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13224 .channel_mode = alc269_modes,
13225 .input_mux = &alc269_capture_source,
13226 .unsol_event = alc269_quanta_fl1_unsol_event,
13227 .init_hook = alc269_quanta_fl1_init_hook,
13228 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013229 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013230 .mixers = { alc269_eeepc_mixer },
13231 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013232 .init_verbs = { alc269_init_verbs,
13233 alc269_eeepc_amic_init_verbs },
13234 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13235 .dac_nids = alc269_dac_nids,
13236 .hp_nid = 0x03,
13237 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13238 .channel_mode = alc269_modes,
13239 .input_mux = &alc269_eeepc_amic_capture_source,
13240 .unsol_event = alc269_eeepc_amic_unsol_event,
13241 .init_hook = alc269_eeepc_amic_inithook,
13242 },
13243 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013244 .mixers = { alc269_eeepc_mixer },
13245 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013246 .init_verbs = { alc269_init_verbs,
13247 alc269_eeepc_dmic_init_verbs },
13248 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13249 .dac_nids = alc269_dac_nids,
13250 .hp_nid = 0x03,
13251 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13252 .channel_mode = alc269_modes,
13253 .input_mux = &alc269_eeepc_dmic_capture_source,
13254 .unsol_event = alc269_eeepc_dmic_unsol_event,
13255 .init_hook = alc269_eeepc_dmic_inithook,
13256 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013257 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013258 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013259 .cap_mixer = alc269_epc_capture_mixer,
13260 .init_verbs = { alc269_init_verbs,
13261 alc269_eeepc_dmic_init_verbs },
13262 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13263 .dac_nids = alc269_dac_nids,
13264 .hp_nid = 0x03,
13265 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13266 .channel_mode = alc269_modes,
13267 .input_mux = &alc269_eeepc_dmic_capture_source,
13268 .unsol_event = alc269_eeepc_dmic_unsol_event,
13269 .init_hook = alc269_eeepc_dmic_inithook,
13270 },
Tony Vroon64154832008-11-06 15:08:49 +000013271 [ALC269_LIFEBOOK] = {
13272 .mixers = { alc269_lifebook_mixer },
13273 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13274 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13275 .dac_nids = alc269_dac_nids,
13276 .hp_nid = 0x03,
13277 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13278 .channel_mode = alc269_modes,
13279 .input_mux = &alc269_capture_source,
13280 .unsol_event = alc269_lifebook_unsol_event,
13281 .init_hook = alc269_lifebook_init_hook,
13282 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013283};
13284
13285static int patch_alc269(struct hda_codec *codec)
13286{
13287 struct alc_spec *spec;
13288 int board_config;
13289 int err;
13290
13291 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13292 if (spec == NULL)
13293 return -ENOMEM;
13294
13295 codec->spec = spec;
13296
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013297 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13298
Kailang Yangf6a92242007-12-13 16:52:54 +010013299 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13300 alc269_models,
13301 alc269_cfg_tbl);
13302
13303 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013304 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13305 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013306 board_config = ALC269_AUTO;
13307 }
13308
13309 if (board_config == ALC269_AUTO) {
13310 /* automatic parse from the BIOS config */
13311 err = alc269_parse_auto_config(codec);
13312 if (err < 0) {
13313 alc_free(codec);
13314 return err;
13315 } else if (!err) {
13316 printk(KERN_INFO
13317 "hda_codec: Cannot set up configuration "
13318 "from BIOS. Using base mode...\n");
13319 board_config = ALC269_BASIC;
13320 }
13321 }
13322
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013323 err = snd_hda_attach_beep_device(codec, 0x1);
13324 if (err < 0) {
13325 alc_free(codec);
13326 return err;
13327 }
13328
Kailang Yangf6a92242007-12-13 16:52:54 +010013329 if (board_config != ALC269_AUTO)
13330 setup_preset(spec, &alc269_presets[board_config]);
13331
Takashi Iwaif03d3112009-03-05 14:18:16 +010013332 if (codec->subsystem_id == 0x17aa3bf8) {
13333 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13334 * fix the sample rate of analog I/O to 44.1kHz
13335 */
13336 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13337 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13338 } else {
13339 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13340 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13341 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013342 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13343 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13344
13345 spec->adc_nids = alc269_adc_nids;
13346 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013347 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013348 if (!spec->cap_mixer)
13349 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013350 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013351
13352 codec->patch_ops = alc_patch_ops;
13353 if (board_config == ALC269_AUTO)
13354 spec->init_hook = alc269_auto_init;
13355#ifdef CONFIG_SND_HDA_POWER_SAVE
13356 if (!spec->loopback.amplist)
13357 spec->loopback.amplist = alc269_loopbacks;
13358#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013359 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013360
13361 return 0;
13362}
13363
13364/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013365 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13366 */
13367
13368/*
13369 * set the path ways for 2 channel output
13370 * need to set the codec line out and mic 1 pin widgets to inputs
13371 */
13372static struct hda_verb alc861_threestack_ch2_init[] = {
13373 /* set pin widget 1Ah (line in) for input */
13374 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013375 /* set pin widget 18h (mic1/2) for input, for mic also enable
13376 * the vref
13377 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013378 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13379
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13381#if 0
13382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13383 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13384#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013385 { } /* end */
13386};
13387/*
13388 * 6ch mode
13389 * need to set the codec line out and mic 1 pin widgets to outputs
13390 */
13391static struct hda_verb alc861_threestack_ch6_init[] = {
13392 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13393 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13394 /* set pin widget 18h (mic1) for output (CLFE)*/
13395 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13396
13397 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013398 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013399
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013400 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13401#if 0
13402 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13404#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013405 { } /* end */
13406};
13407
13408static struct hda_channel_mode alc861_threestack_modes[2] = {
13409 { 2, alc861_threestack_ch2_init },
13410 { 6, alc861_threestack_ch6_init },
13411};
Takashi Iwai22309c32006-08-09 16:57:28 +020013412/* Set mic1 as input and unmute the mixer */
13413static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13416 { } /* end */
13417};
13418/* Set mic1 as output and mute mixer */
13419static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13420 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13422 { } /* end */
13423};
13424
13425static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13426 { 2, alc861_uniwill_m31_ch2_init },
13427 { 4, alc861_uniwill_m31_ch4_init },
13428};
Kailang Yangdf694da2005-12-05 19:42:22 +010013429
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013430/* Set mic1 and line-in as input and unmute the mixer */
13431static struct hda_verb alc861_asus_ch2_init[] = {
13432 /* set pin widget 1Ah (line in) for input */
13433 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013434 /* set pin widget 18h (mic1/2) for input, for mic also enable
13435 * the vref
13436 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013437 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13438
13439 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13440#if 0
13441 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13442 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13443#endif
13444 { } /* end */
13445};
13446/* Set mic1 nad line-in as output and mute mixer */
13447static struct hda_verb alc861_asus_ch6_init[] = {
13448 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13449 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13450 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13451 /* set pin widget 18h (mic1) for output (CLFE)*/
13452 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13453 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13454 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13455 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13456
13457 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13458#if 0
13459 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13460 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13461#endif
13462 { } /* end */
13463};
13464
13465static struct hda_channel_mode alc861_asus_modes[2] = {
13466 { 2, alc861_asus_ch2_init },
13467 { 6, alc861_asus_ch6_init },
13468};
13469
Kailang Yangdf694da2005-12-05 19:42:22 +010013470/* patch-ALC861 */
13471
13472static struct snd_kcontrol_new alc861_base_mixer[] = {
13473 /* output mixer control */
13474 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13475 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13476 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13477 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13478 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13479
13480 /*Input mixer control */
13481 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13482 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13483 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13484 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13485 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13486 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13487 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13488 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013491
Kailang Yangdf694da2005-12-05 19:42:22 +010013492 { } /* end */
13493};
13494
13495static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13496 /* output mixer control */
13497 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13498 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13499 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13500 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13501 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13502
13503 /* Input mixer control */
13504 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13505 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13506 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13507 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13508 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13509 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13511 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13512 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013514
Kailang Yangdf694da2005-12-05 19:42:22 +010013515 {
13516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13517 .name = "Channel Mode",
13518 .info = alc_ch_mode_info,
13519 .get = alc_ch_mode_get,
13520 .put = alc_ch_mode_put,
13521 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13522 },
13523 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013524};
13525
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013526static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013527 /* output mixer control */
13528 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13530 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013531
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013532 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013534
Takashi Iwai22309c32006-08-09 16:57:28 +020013535static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13536 /* output mixer control */
13537 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13538 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13539 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13540 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13541 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13542
13543 /* Input mixer control */
13544 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13545 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13546 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13547 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13548 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13549 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13551 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013554
Takashi Iwai22309c32006-08-09 16:57:28 +020013555 {
13556 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13557 .name = "Channel Mode",
13558 .info = alc_ch_mode_info,
13559 .get = alc_ch_mode_get,
13560 .put = alc_ch_mode_put,
13561 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13562 },
13563 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013564};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013565
13566static struct snd_kcontrol_new alc861_asus_mixer[] = {
13567 /* output mixer control */
13568 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13569 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13570 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13571 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13572 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13573
13574 /* Input mixer control */
13575 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13576 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13577 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13578 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13579 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13580 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13582 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13583 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13585
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013586 {
13587 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13588 .name = "Channel Mode",
13589 .info = alc_ch_mode_info,
13590 .get = alc_ch_mode_get,
13591 .put = alc_ch_mode_put,
13592 .private_value = ARRAY_SIZE(alc861_asus_modes),
13593 },
13594 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013595};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013596
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013597/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013598static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013599 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13600 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013601 { }
13602};
13603
Kailang Yangdf694da2005-12-05 19:42:22 +010013604/*
13605 * generic initialization of ADC, input mixers and output mixers
13606 */
13607static struct hda_verb alc861_base_init_verbs[] = {
13608 /*
13609 * Unmute ADC0 and set the default input to mic-in
13610 */
13611 /* port-A for surround (rear panel) */
13612 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13613 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13614 /* port-B for mic-in (rear panel) with vref */
13615 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13616 /* port-C for line-in (rear panel) */
13617 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13618 /* port-D for Front */
13619 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13620 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13621 /* port-E for HP out (front panel) */
13622 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13623 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013624 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013625 /* port-F for mic-in (front panel) with vref */
13626 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13627 /* port-G for CLFE (rear panel) */
13628 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13629 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13630 /* port-H for side (rear panel) */
13631 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13632 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13633 /* CD-in */
13634 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13635 /* route front mic to ADC1*/
13636 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13637 {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_UNMUTE},
13641 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13642 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13643 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
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)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013657
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)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013666 /* hp used DAC 3 (Front) */
13667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13669
13670 { }
13671};
13672
13673static struct hda_verb alc861_threestack_init_verbs[] = {
13674 /*
13675 * Unmute ADC0 and set the default input to mic-in
13676 */
13677 /* port-A for surround (rear panel) */
13678 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13679 /* port-B for mic-in (rear panel) with vref */
13680 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13681 /* port-C for line-in (rear panel) */
13682 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13683 /* port-D for Front */
13684 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13685 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13686 /* port-E for HP out (front panel) */
13687 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13688 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013689 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013690 /* port-F for mic-in (front panel) with vref */
13691 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13692 /* port-G for CLFE (rear panel) */
13693 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13694 /* port-H for side (rear panel) */
13695 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13696 /* CD-in */
13697 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13698 /* route front mic to ADC1*/
13699 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13700 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13701 /* Unmute DAC0~3 & spdif out*/
13702 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13703 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13704 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13705 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013707
Kailang Yangdf694da2005-12-05 19:42:22 +010013708 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13709 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13710 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13711 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13712 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013713
Kailang Yangdf694da2005-12-05 19:42:22 +010013714 /* Unmute Stereo Mixer 15 */
13715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13717 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013719
13720 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13721 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13724 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13727 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013728 /* hp used DAC 3 (Front) */
13729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013730 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13731 { }
13732};
Takashi Iwai22309c32006-08-09 16:57:28 +020013733
13734static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13735 /*
13736 * Unmute ADC0 and set the default input to mic-in
13737 */
13738 /* port-A for surround (rear panel) */
13739 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13740 /* port-B for mic-in (rear panel) with vref */
13741 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13742 /* port-C for line-in (rear panel) */
13743 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13744 /* port-D for Front */
13745 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13746 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13747 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013748 /* this has to be set to VREF80 */
13749 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013750 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013751 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013752 /* port-F for mic-in (front panel) with vref */
13753 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13754 /* port-G for CLFE (rear panel) */
13755 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13756 /* port-H for side (rear panel) */
13757 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13758 /* CD-in */
13759 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13760 /* route front mic to ADC1*/
13761 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13762 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13763 /* Unmute DAC0~3 & spdif out*/
13764 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13765 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13766 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13767 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013769
Takashi Iwai22309c32006-08-09 16:57:28 +020013770 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13771 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13774 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013775
Takashi Iwai22309c32006-08-09 16:57:28 +020013776 /* Unmute Stereo Mixer 15 */
13777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013781
13782 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13783 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13784 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13785 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13786 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13787 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013790 /* hp used DAC 3 (Front) */
13791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13793 { }
13794};
13795
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013796static struct hda_verb alc861_asus_init_verbs[] = {
13797 /*
13798 * Unmute ADC0 and set the default input to mic-in
13799 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013800 /* port-A for surround (rear panel)
13801 * according to codec#0 this is the HP jack
13802 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013803 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13804 /* route front PCM to HP */
13805 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13806 /* port-B for mic-in (rear panel) with vref */
13807 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13808 /* port-C for line-in (rear panel) */
13809 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13810 /* port-D for Front */
13811 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13812 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13813 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013814 /* this has to be set to VREF80 */
13815 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013816 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013818 /* port-F for mic-in (front panel) with vref */
13819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13820 /* port-G for CLFE (rear panel) */
13821 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 /* port-H for side (rear panel) */
13823 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13824 /* CD-in */
13825 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13826 /* route front mic to ADC1*/
13827 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13829 /* Unmute DAC0~3 & spdif out*/
13830 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13832 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13833 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13835 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13836 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13837 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13838 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13839 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013840
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013841 /* Unmute Stereo Mixer 15 */
13842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013846
13847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013855 /* hp used DAC 3 (Front) */
13856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13858 { }
13859};
13860
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013861/* additional init verbs for ASUS laptops */
13862static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13863 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13864 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13865 { }
13866};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013867
Kailang Yangdf694da2005-12-05 19:42:22 +010013868/*
13869 * generic initialization of ADC, input mixers and output mixers
13870 */
13871static struct hda_verb alc861_auto_init_verbs[] = {
13872 /*
13873 * Unmute ADC0 and set the default input to mic-in
13874 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013875 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013876 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013877
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 /* Unmute DAC0~3 & spdif out*/
13879 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13880 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13881 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13882 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013884
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13886 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013890
Kailang Yangdf694da2005-12-05 19:42:22 +010013891 /* Unmute Stereo Mixer 15 */
13892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13896
Takashi Iwai1c209302009-07-22 15:17:45 +020013897 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13898 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13899 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13901 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13902 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13904 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013905
13906 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13907 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013910 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13911 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13913 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013914
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013915 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013916
13917 { }
13918};
13919
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013920static struct hda_verb alc861_toshiba_init_verbs[] = {
13921 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013922
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013923 { }
13924};
13925
13926/* toggle speaker-output according to the hp-jack state */
13927static void alc861_toshiba_automute(struct hda_codec *codec)
13928{
13929 unsigned int present;
13930
13931 present = snd_hda_codec_read(codec, 0x0f, 0,
13932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013933 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13934 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13935 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13936 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013937}
13938
13939static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13940 unsigned int res)
13941{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013942 if ((res >> 26) == ALC880_HP_EVENT)
13943 alc861_toshiba_automute(codec);
13944}
13945
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013946/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013947#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13948#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13949#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13950#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13951
13952
13953#define ALC861_DIGOUT_NID 0x07
13954
13955static struct hda_channel_mode alc861_8ch_modes[1] = {
13956 { 8, NULL }
13957};
13958
13959static hda_nid_t alc861_dac_nids[4] = {
13960 /* front, surround, clfe, side */
13961 0x03, 0x06, 0x05, 0x04
13962};
13963
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013964static hda_nid_t alc660_dac_nids[3] = {
13965 /* front, clfe, surround */
13966 0x03, 0x05, 0x06
13967};
13968
Kailang Yangdf694da2005-12-05 19:42:22 +010013969static hda_nid_t alc861_adc_nids[1] = {
13970 /* ADC0-2 */
13971 0x08,
13972};
13973
13974static struct hda_input_mux alc861_capture_source = {
13975 .num_items = 5,
13976 .items = {
13977 { "Mic", 0x0 },
13978 { "Front Mic", 0x3 },
13979 { "Line", 0x1 },
13980 { "CD", 0x4 },
13981 { "Mixer", 0x5 },
13982 },
13983};
13984
Takashi Iwai1c209302009-07-22 15:17:45 +020013985static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
13986{
13987 struct alc_spec *spec = codec->spec;
13988 hda_nid_t mix, srcs[5];
13989 int i, j, num;
13990
13991 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
13992 return 0;
13993 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
13994 if (num < 0)
13995 return 0;
13996 for (i = 0; i < num; i++) {
13997 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020013998 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020013999 if (type != AC_WID_AUD_OUT)
14000 continue;
14001 for (j = 0; j < spec->multiout.num_dacs; j++)
14002 if (spec->multiout.dac_nids[j] == srcs[i])
14003 break;
14004 if (j >= spec->multiout.num_dacs)
14005 return srcs[i];
14006 }
14007 return 0;
14008}
14009
Kailang Yangdf694da2005-12-05 19:42:22 +010014010/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014011static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014012 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014013{
Takashi Iwai1c209302009-07-22 15:17:45 +020014014 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014015 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014016 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014017
14018 spec->multiout.dac_nids = spec->private_dac_nids;
14019 for (i = 0; i < cfg->line_outs; i++) {
14020 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014021 dac = alc861_look_for_dac(codec, nid);
14022 if (!dac)
14023 continue;
14024 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014025 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014026 return 0;
14027}
14028
Takashi Iwai1c209302009-07-22 15:17:45 +020014029static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14030 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014031{
14032 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014033 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14034 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14035 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14036}
14037
14038/* add playback controls from the parsed DAC table */
14039static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14040 const struct auto_pin_cfg *cfg)
14041{
14042 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014043 static const char *chname[4] = {
14044 "Front", "Surround", NULL /*CLFE*/, "Side"
14045 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014046 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014047 int i, err;
14048
14049 if (cfg->line_outs == 1) {
14050 const char *pfx = NULL;
14051 if (!cfg->hp_outs)
14052 pfx = "Master";
14053 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14054 pfx = "Speaker";
14055 if (pfx) {
14056 nid = spec->multiout.dac_nids[0];
14057 return alc861_create_out_sw(codec, pfx, nid, 3);
14058 }
14059 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014060
14061 for (i = 0; i < cfg->line_outs; i++) {
14062 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014063 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014064 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014065 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014066 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014067 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014069 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014070 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014071 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014072 return err;
14073 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014074 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014075 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014076 return err;
14077 }
14078 }
14079 return 0;
14080}
14081
Takashi Iwai1c209302009-07-22 15:17:45 +020014082static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014083{
Takashi Iwai1c209302009-07-22 15:17:45 +020014084 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014085 int err;
14086 hda_nid_t nid;
14087
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014088 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014089 return 0;
14090
14091 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014092 nid = alc861_look_for_dac(codec, pin);
14093 if (nid) {
14094 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14095 if (err < 0)
14096 return err;
14097 spec->multiout.hp_nid = nid;
14098 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014099 }
14100 return 0;
14101}
14102
14103/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014104static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014105 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014106{
Takashi Iwai1c209302009-07-22 15:17:45 +020014107 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014108 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014109 int i, err, idx, idx1;
14110
14111 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014112 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014113 case 0x0c:
14114 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014115 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014116 break;
14117 case 0x0f:
14118 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014119 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014120 break;
14121 case 0x0d:
14122 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014123 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014124 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014125 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014126 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014127 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014128 break;
14129 case 0x11:
14130 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014131 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014132 break;
14133 default:
14134 continue;
14135 }
14136
Takashi Iwai4a471b72005-12-07 13:56:29 +010014137 err = new_analog_input(spec, cfg->input_pins[i],
14138 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014139 if (err < 0)
14140 return err;
14141
Takashi Iwai4a471b72005-12-07 13:56:29 +010014142 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014143 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014144 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014145 }
14146 return 0;
14147}
14148
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014149static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14150 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014151 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014152{
Takashi Iwai1c209302009-07-22 15:17:45 +020014153 hda_nid_t mix, srcs[5];
14154 int i, num;
14155
Jacek Luczak564c5be2008-05-03 18:41:23 +020014156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14157 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014158 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014159 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014160 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14161 return;
14162 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14163 if (num < 0)
14164 return;
14165 for (i = 0; i < num; i++) {
14166 unsigned int mute;
14167 if (srcs[i] == dac || srcs[i] == 0x15)
14168 mute = AMP_IN_UNMUTE(i);
14169 else
14170 mute = AMP_IN_MUTE(i);
14171 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14172 mute);
14173 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014174}
14175
14176static void alc861_auto_init_multi_out(struct hda_codec *codec)
14177{
14178 struct alc_spec *spec = codec->spec;
14179 int i;
14180
14181 for (i = 0; i < spec->autocfg.line_outs; i++) {
14182 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014183 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014185 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014186 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014187 }
14188}
14189
14190static void alc861_auto_init_hp_out(struct hda_codec *codec)
14191{
14192 struct alc_spec *spec = codec->spec;
14193 hda_nid_t pin;
14194
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014195 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014196 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014197 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014198 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014199 pin = spec->autocfg.speaker_pins[0];
14200 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014201 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14202 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014203}
14204
14205static void alc861_auto_init_analog_input(struct hda_codec *codec)
14206{
14207 struct alc_spec *spec = codec->spec;
14208 int i;
14209
14210 for (i = 0; i < AUTO_PIN_LAST; i++) {
14211 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014212 if (nid >= 0x0c && nid <= 0x11)
14213 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014214 }
14215}
14216
14217/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014218/* return 1 if successful, 0 if the proper config is not found,
14219 * or a negative error code
14220 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014221static int alc861_parse_auto_config(struct hda_codec *codec)
14222{
14223 struct alc_spec *spec = codec->spec;
14224 int err;
14225 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14228 alc861_ignore);
14229 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014231 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014232 return 0; /* can't find valid BIOS pin config */
14233
Takashi Iwai1c209302009-07-22 15:17:45 +020014234 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014235 if (err < 0)
14236 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014237 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 if (err < 0)
14239 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014240 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014241 if (err < 0)
14242 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014243 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014245 return err;
14246
14247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14248
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014249 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014250 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14251
Takashi Iwai603c4012008-07-30 15:01:44 +020014252 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014253 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014254
Takashi Iwaid88897e2008-10-31 15:01:37 +010014255 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014256
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014257 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014258 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014259
14260 spec->adc_nids = alc861_adc_nids;
14261 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014262 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014263
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014264 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14265
Kailang Yangdf694da2005-12-05 19:42:22 +010014266 return 1;
14267}
14268
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014269/* additional initialization for auto-configuration model */
14270static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014272 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014273 alc861_auto_init_multi_out(codec);
14274 alc861_auto_init_hp_out(codec);
14275 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014276 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014277 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014278}
14279
Takashi Iwaicb53c622007-08-10 17:21:45 +020014280#ifdef CONFIG_SND_HDA_POWER_SAVE
14281static struct hda_amp_list alc861_loopbacks[] = {
14282 { 0x15, HDA_INPUT, 0 },
14283 { 0x15, HDA_INPUT, 1 },
14284 { 0x15, HDA_INPUT, 2 },
14285 { 0x15, HDA_INPUT, 3 },
14286 { } /* end */
14287};
14288#endif
14289
Kailang Yangdf694da2005-12-05 19:42:22 +010014290
14291/*
14292 * configuration and preset
14293 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014294static const char *alc861_models[ALC861_MODEL_LAST] = {
14295 [ALC861_3ST] = "3stack",
14296 [ALC660_3ST] = "3stack-660",
14297 [ALC861_3ST_DIG] = "3stack-dig",
14298 [ALC861_6ST_DIG] = "6stack-dig",
14299 [ALC861_UNIWILL_M31] = "uniwill-m31",
14300 [ALC861_TOSHIBA] = "toshiba",
14301 [ALC861_ASUS] = "asus",
14302 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14303 [ALC861_AUTO] = "auto",
14304};
14305
14306static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014307 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014308 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14309 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14310 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014311 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014312 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014313 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014314 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14315 * Any other models that need this preset?
14316 */
14317 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014318 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14319 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014320 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14321 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14322 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14323 /* FIXME: the below seems conflict */
14324 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14325 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14326 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014327 {}
14328};
14329
14330static struct alc_config_preset alc861_presets[] = {
14331 [ALC861_3ST] = {
14332 .mixers = { alc861_3ST_mixer },
14333 .init_verbs = { alc861_threestack_init_verbs },
14334 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14335 .dac_nids = alc861_dac_nids,
14336 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14337 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014338 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014339 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14340 .adc_nids = alc861_adc_nids,
14341 .input_mux = &alc861_capture_source,
14342 },
14343 [ALC861_3ST_DIG] = {
14344 .mixers = { alc861_base_mixer },
14345 .init_verbs = { alc861_threestack_init_verbs },
14346 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14347 .dac_nids = alc861_dac_nids,
14348 .dig_out_nid = ALC861_DIGOUT_NID,
14349 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14350 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014351 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014352 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14353 .adc_nids = alc861_adc_nids,
14354 .input_mux = &alc861_capture_source,
14355 },
14356 [ALC861_6ST_DIG] = {
14357 .mixers = { alc861_base_mixer },
14358 .init_verbs = { alc861_base_init_verbs },
14359 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14360 .dac_nids = alc861_dac_nids,
14361 .dig_out_nid = ALC861_DIGOUT_NID,
14362 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14363 .channel_mode = alc861_8ch_modes,
14364 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14365 .adc_nids = alc861_adc_nids,
14366 .input_mux = &alc861_capture_source,
14367 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014368 [ALC660_3ST] = {
14369 .mixers = { alc861_3ST_mixer },
14370 .init_verbs = { alc861_threestack_init_verbs },
14371 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14372 .dac_nids = alc660_dac_nids,
14373 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14374 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014375 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014376 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14377 .adc_nids = alc861_adc_nids,
14378 .input_mux = &alc861_capture_source,
14379 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014380 [ALC861_UNIWILL_M31] = {
14381 .mixers = { alc861_uniwill_m31_mixer },
14382 .init_verbs = { alc861_uniwill_m31_init_verbs },
14383 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14384 .dac_nids = alc861_dac_nids,
14385 .dig_out_nid = ALC861_DIGOUT_NID,
14386 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14387 .channel_mode = alc861_uniwill_m31_modes,
14388 .need_dac_fix = 1,
14389 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14390 .adc_nids = alc861_adc_nids,
14391 .input_mux = &alc861_capture_source,
14392 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014393 [ALC861_TOSHIBA] = {
14394 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014395 .init_verbs = { alc861_base_init_verbs,
14396 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014397 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14398 .dac_nids = alc861_dac_nids,
14399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14400 .channel_mode = alc883_3ST_2ch_modes,
14401 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14402 .adc_nids = alc861_adc_nids,
14403 .input_mux = &alc861_capture_source,
14404 .unsol_event = alc861_toshiba_unsol_event,
14405 .init_hook = alc861_toshiba_automute,
14406 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014407 [ALC861_ASUS] = {
14408 .mixers = { alc861_asus_mixer },
14409 .init_verbs = { alc861_asus_init_verbs },
14410 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14411 .dac_nids = alc861_dac_nids,
14412 .dig_out_nid = ALC861_DIGOUT_NID,
14413 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14414 .channel_mode = alc861_asus_modes,
14415 .need_dac_fix = 1,
14416 .hp_nid = 0x06,
14417 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14418 .adc_nids = alc861_adc_nids,
14419 .input_mux = &alc861_capture_source,
14420 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014421 [ALC861_ASUS_LAPTOP] = {
14422 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14423 .init_verbs = { alc861_asus_init_verbs,
14424 alc861_asus_laptop_init_verbs },
14425 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14426 .dac_nids = alc861_dac_nids,
14427 .dig_out_nid = ALC861_DIGOUT_NID,
14428 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14429 .channel_mode = alc883_3ST_2ch_modes,
14430 .need_dac_fix = 1,
14431 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14432 .adc_nids = alc861_adc_nids,
14433 .input_mux = &alc861_capture_source,
14434 },
14435};
Kailang Yangdf694da2005-12-05 19:42:22 +010014436
14437
14438static int patch_alc861(struct hda_codec *codec)
14439{
14440 struct alc_spec *spec;
14441 int board_config;
14442 int err;
14443
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014444 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014445 if (spec == NULL)
14446 return -ENOMEM;
14447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014448 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014449
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014450 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14451 alc861_models,
14452 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014453
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014454 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014455 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14456 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014457 board_config = ALC861_AUTO;
14458 }
14459
14460 if (board_config == ALC861_AUTO) {
14461 /* automatic parse from the BIOS config */
14462 err = alc861_parse_auto_config(codec);
14463 if (err < 0) {
14464 alc_free(codec);
14465 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014466 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014467 printk(KERN_INFO
14468 "hda_codec: Cannot set up configuration "
14469 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014470 board_config = ALC861_3ST_DIG;
14471 }
14472 }
14473
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014474 err = snd_hda_attach_beep_device(codec, 0x23);
14475 if (err < 0) {
14476 alc_free(codec);
14477 return err;
14478 }
14479
Kailang Yangdf694da2005-12-05 19:42:22 +010014480 if (board_config != ALC861_AUTO)
14481 setup_preset(spec, &alc861_presets[board_config]);
14482
Kailang Yangdf694da2005-12-05 19:42:22 +010014483 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14484 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14485
Kailang Yangdf694da2005-12-05 19:42:22 +010014486 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14487 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14488
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014489 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14490
Takashi Iwai2134ea42008-01-10 16:53:55 +010014491 spec->vmaster_nid = 0x03;
14492
Kailang Yangdf694da2005-12-05 19:42:22 +010014493 codec->patch_ops = alc_patch_ops;
14494 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014495 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014496#ifdef CONFIG_SND_HDA_POWER_SAVE
14497 if (!spec->loopback.amplist)
14498 spec->loopback.amplist = alc861_loopbacks;
14499#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014500 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014501
Kailang Yangdf694da2005-12-05 19:42:22 +010014502 return 0;
14503}
14504
14505/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014506 * ALC861-VD support
14507 *
14508 * Based on ALC882
14509 *
14510 * In addition, an independent DAC
14511 */
14512#define ALC861VD_DIGOUT_NID 0x06
14513
14514static hda_nid_t alc861vd_dac_nids[4] = {
14515 /* front, surr, clfe, side surr */
14516 0x02, 0x03, 0x04, 0x05
14517};
14518
14519/* dac_nids for ALC660vd are in a different order - according to
14520 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014521 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014522 * of ALC660vd codecs, but for now there is only 3stack mixer
14523 * - and it is the same as in 861vd.
14524 * adc_nids in ALC660vd are (is) the same as in 861vd
14525 */
14526static hda_nid_t alc660vd_dac_nids[3] = {
14527 /* front, rear, clfe, rear_surr */
14528 0x02, 0x04, 0x03
14529};
14530
14531static hda_nid_t alc861vd_adc_nids[1] = {
14532 /* ADC0 */
14533 0x09,
14534};
14535
Takashi Iwaie1406342008-02-11 18:32:32 +010014536static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14537
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014538/* input MUX */
14539/* FIXME: should be a matrix-type input source selection */
14540static struct hda_input_mux alc861vd_capture_source = {
14541 .num_items = 4,
14542 .items = {
14543 { "Mic", 0x0 },
14544 { "Front Mic", 0x1 },
14545 { "Line", 0x2 },
14546 { "CD", 0x4 },
14547 },
14548};
14549
Kailang Yang272a5272007-05-14 11:00:38 +020014550static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014551 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014552 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014553 { "Ext Mic", 0x0 },
14554 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014555 },
14556};
14557
Kailang Yangd1a991a2007-08-15 16:21:59 +020014558static struct hda_input_mux alc861vd_hp_capture_source = {
14559 .num_items = 2,
14560 .items = {
14561 { "Front Mic", 0x0 },
14562 { "ATAPI Mic", 0x1 },
14563 },
14564};
14565
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014566/*
14567 * 2ch mode
14568 */
14569static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14570 { 2, NULL }
14571};
14572
14573/*
14574 * 6ch mode
14575 */
14576static struct hda_verb alc861vd_6stack_ch6_init[] = {
14577 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14578 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14579 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14580 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14581 { } /* end */
14582};
14583
14584/*
14585 * 8ch mode
14586 */
14587static struct hda_verb alc861vd_6stack_ch8_init[] = {
14588 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14589 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14590 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14591 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14592 { } /* end */
14593};
14594
14595static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14596 { 6, alc861vd_6stack_ch6_init },
14597 { 8, alc861vd_6stack_ch8_init },
14598};
14599
14600static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14601 {
14602 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14603 .name = "Channel Mode",
14604 .info = alc_ch_mode_info,
14605 .get = alc_ch_mode_get,
14606 .put = alc_ch_mode_put,
14607 },
14608 { } /* end */
14609};
14610
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014611/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14612 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14613 */
14614static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14615 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14616 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14617
14618 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14619 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14620
14621 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14622 HDA_OUTPUT),
14623 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14624 HDA_OUTPUT),
14625 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14626 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14627
14628 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14629 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14630
14631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14632
14633 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14636
14637 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14640
14641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14643
14644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14646
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014647 { } /* end */
14648};
14649
14650static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14651 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14652 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14653
14654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14655
14656 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14659
14660 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14663
14664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14666
14667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14669
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014670 { } /* end */
14671};
14672
Kailang Yangbdd148a2007-05-08 15:19:08 +020014673static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14674 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14675 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14676 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14677
14678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14679
14680 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14683
14684 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14685 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14686 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14687
14688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14690
14691 { } /* end */
14692};
14693
Tobin Davisb419f342008-03-07 11:57:51 +010014694/* Pin assignment: Speaker=0x14, HP = 0x15,
14695 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014696 */
14697static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014698 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14699 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014700 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14701 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014702 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14703 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14704 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14705 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14706 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14707 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014708 { } /* end */
14709};
14710
Kailang Yangd1a991a2007-08-15 16:21:59 +020014711/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14712 * Front Mic=0x18, ATAPI Mic = 0x19,
14713 */
14714static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14715 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14716 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14717 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14718 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14719 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14720 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14721 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14722 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014723
Kailang Yangd1a991a2007-08-15 16:21:59 +020014724 { } /* end */
14725};
14726
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014727/*
14728 * generic initialization of ADC, input mixers and output mixers
14729 */
14730static struct hda_verb alc861vd_volume_init_verbs[] = {
14731 /*
14732 * Unmute ADC0 and set the default input to mic-in
14733 */
14734 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14736
14737 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14738 * the analog-loopback mixer widget
14739 */
14740 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746
14747 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014752
14753 /*
14754 * Set up output mixers (0x02 - 0x05)
14755 */
14756 /* set vol=0 to output mixers */
14757 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14758 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14759 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14760 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14761
14762 /* set up input amps for analog loopback */
14763 /* Amp Indices: DAC = 0, mixer = 1 */
14764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14767 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14770 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14771 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14772
14773 { }
14774};
14775
14776/*
14777 * 3-stack pin configuration:
14778 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14779 */
14780static struct hda_verb alc861vd_3stack_init_verbs[] = {
14781 /*
14782 * Set pin mode and muting
14783 */
14784 /* set front pin widgets 0x14 for output */
14785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14787 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14788
14789 /* Mic (rear) pin: input vref at 80% */
14790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14792 /* Front Mic pin: input vref at 80% */
14793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14794 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14795 /* Line In pin: input */
14796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14798 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14801 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14802 /* CD pin widget for input */
14803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14804
14805 { }
14806};
14807
14808/*
14809 * 6-stack pin configuration:
14810 */
14811static struct hda_verb alc861vd_6stack_init_verbs[] = {
14812 /*
14813 * Set pin mode and muting
14814 */
14815 /* set front pin widgets 0x14 for output */
14816 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14818 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14819
14820 /* Rear Pin: output 1 (0x0d) */
14821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14823 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14824 /* CLFE Pin: output 2 (0x0e) */
14825 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14826 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14827 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14828 /* Side Pin: output 3 (0x0f) */
14829 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14831 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14832
14833 /* Mic (rear) pin: input vref at 80% */
14834 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14835 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14836 /* Front Mic pin: input vref at 80% */
14837 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14839 /* Line In pin: input */
14840 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14842 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14843 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14844 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14845 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14846 /* CD pin widget for input */
14847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14848
14849 { }
14850};
14851
Kailang Yangbdd148a2007-05-08 15:19:08 +020014852static struct hda_verb alc861vd_eapd_verbs[] = {
14853 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14854 { }
14855};
14856
Kailang Yangf9423e72008-05-27 12:32:25 +020014857static struct hda_verb alc660vd_eapd_verbs[] = {
14858 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14859 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14860 { }
14861};
14862
Kailang Yangbdd148a2007-05-08 15:19:08 +020014863static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14867 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014868 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014869 {}
14870};
14871
Kailang Yangbdd148a2007-05-08 15:19:08 +020014872static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14873{
14874 unsigned int present;
14875 unsigned char bits;
14876
14877 present = snd_hda_codec_read(codec, 0x18, 0,
14878 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014879 bits = present ? HDA_AMP_MUTE : 0;
14880 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14881 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014882}
14883
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014884static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014885{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014886 struct alc_spec *spec = codec->spec;
14887
14888 spec->autocfg.hp_pins[0] = 0x1b;
14889 spec->autocfg.speaker_pins[0] = 0x14;
14890 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014891 alc861vd_lenovo_mic_automute(codec);
14892}
14893
14894static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14895 unsigned int res)
14896{
14897 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014898 case ALC880_MIC_EVENT:
14899 alc861vd_lenovo_mic_automute(codec);
14900 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014901 default:
14902 alc_automute_amp_unsol_event(codec, res);
14903 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014904 }
14905}
14906
Kailang Yang272a5272007-05-14 11:00:38 +020014907static struct hda_verb alc861vd_dallas_verbs[] = {
14908 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14909 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14910 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14911 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14912
14913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014921
Kailang Yang272a5272007-05-14 11:00:38 +020014922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14928 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14929 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14930
14931 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14932 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14933 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14934 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14937 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14938 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14939
14940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14944
14945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014946 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14948
14949 { } /* end */
14950};
14951
14952/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014953static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014954{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014955 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014956
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014957 spec->autocfg.hp_pins[0] = 0x15;
14958 spec->autocfg.speaker_pins[0] = 0x14;
14959 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014960}
14961
Takashi Iwaicb53c622007-08-10 17:21:45 +020014962#ifdef CONFIG_SND_HDA_POWER_SAVE
14963#define alc861vd_loopbacks alc880_loopbacks
14964#endif
14965
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014966/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014967#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14968#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14969#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14970#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14971
14972/*
14973 * configuration and preset
14974 */
14975static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14976 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014977 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014978 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014979 [ALC861VD_3ST] = "3stack",
14980 [ALC861VD_3ST_DIG] = "3stack-digout",
14981 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014982 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014983 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014984 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014985 [ALC861VD_AUTO] = "auto",
14986};
14987
14988static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014989 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14990 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014991 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014992 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014993 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014994 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014996 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014997 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014998 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014999 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015000 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015001 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015002 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015003 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015004 {}
15005};
15006
15007static struct alc_config_preset alc861vd_presets[] = {
15008 [ALC660VD_3ST] = {
15009 .mixers = { alc861vd_3st_mixer },
15010 .init_verbs = { alc861vd_volume_init_verbs,
15011 alc861vd_3stack_init_verbs },
15012 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15013 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15015 .channel_mode = alc861vd_3stack_2ch_modes,
15016 .input_mux = &alc861vd_capture_source,
15017 },
Mike Crash6963f842007-06-25 12:12:51 +020015018 [ALC660VD_3ST_DIG] = {
15019 .mixers = { alc861vd_3st_mixer },
15020 .init_verbs = { alc861vd_volume_init_verbs,
15021 alc861vd_3stack_init_verbs },
15022 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15023 .dac_nids = alc660vd_dac_nids,
15024 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015025 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15026 .channel_mode = alc861vd_3stack_2ch_modes,
15027 .input_mux = &alc861vd_capture_source,
15028 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015029 [ALC861VD_3ST] = {
15030 .mixers = { alc861vd_3st_mixer },
15031 .init_verbs = { alc861vd_volume_init_verbs,
15032 alc861vd_3stack_init_verbs },
15033 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15034 .dac_nids = alc861vd_dac_nids,
15035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15036 .channel_mode = alc861vd_3stack_2ch_modes,
15037 .input_mux = &alc861vd_capture_source,
15038 },
15039 [ALC861VD_3ST_DIG] = {
15040 .mixers = { alc861vd_3st_mixer },
15041 .init_verbs = { alc861vd_volume_init_verbs,
15042 alc861vd_3stack_init_verbs },
15043 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15044 .dac_nids = alc861vd_dac_nids,
15045 .dig_out_nid = ALC861VD_DIGOUT_NID,
15046 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15047 .channel_mode = alc861vd_3stack_2ch_modes,
15048 .input_mux = &alc861vd_capture_source,
15049 },
15050 [ALC861VD_6ST_DIG] = {
15051 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15052 .init_verbs = { alc861vd_volume_init_verbs,
15053 alc861vd_6stack_init_verbs },
15054 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15055 .dac_nids = alc861vd_dac_nids,
15056 .dig_out_nid = ALC861VD_DIGOUT_NID,
15057 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15058 .channel_mode = alc861vd_6stack_modes,
15059 .input_mux = &alc861vd_capture_source,
15060 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 [ALC861VD_LENOVO] = {
15062 .mixers = { alc861vd_lenovo_mixer },
15063 .init_verbs = { alc861vd_volume_init_verbs,
15064 alc861vd_3stack_init_verbs,
15065 alc861vd_eapd_verbs,
15066 alc861vd_lenovo_unsol_verbs },
15067 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15068 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015069 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15070 .channel_mode = alc861vd_3stack_2ch_modes,
15071 .input_mux = &alc861vd_capture_source,
15072 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015073 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015074 },
Kailang Yang272a5272007-05-14 11:00:38 +020015075 [ALC861VD_DALLAS] = {
15076 .mixers = { alc861vd_dallas_mixer },
15077 .init_verbs = { alc861vd_dallas_verbs },
15078 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15079 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015080 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15081 .channel_mode = alc861vd_3stack_2ch_modes,
15082 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015083 .unsol_event = alc_automute_amp_unsol_event,
15084 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015085 },
15086 [ALC861VD_HP] = {
15087 .mixers = { alc861vd_hp_mixer },
15088 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15089 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15090 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015091 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015092 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15093 .channel_mode = alc861vd_3stack_2ch_modes,
15094 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015095 .unsol_event = alc_automute_amp_unsol_event,
15096 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015097 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015098 [ALC660VD_ASUS_V1S] = {
15099 .mixers = { alc861vd_lenovo_mixer },
15100 .init_verbs = { alc861vd_volume_init_verbs,
15101 alc861vd_3stack_init_verbs,
15102 alc861vd_eapd_verbs,
15103 alc861vd_lenovo_unsol_verbs },
15104 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15105 .dac_nids = alc660vd_dac_nids,
15106 .dig_out_nid = ALC861VD_DIGOUT_NID,
15107 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15108 .channel_mode = alc861vd_3stack_2ch_modes,
15109 .input_mux = &alc861vd_capture_source,
15110 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015111 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015112 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015113};
15114
15115/*
15116 * BIOS auto configuration
15117 */
15118static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15119 hda_nid_t nid, int pin_type, int dac_idx)
15120{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015121 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015122}
15123
15124static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15125{
15126 struct alc_spec *spec = codec->spec;
15127 int i;
15128
15129 for (i = 0; i <= HDA_SIDE; i++) {
15130 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015131 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015132 if (nid)
15133 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015134 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015135 }
15136}
15137
15138
15139static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15140{
15141 struct alc_spec *spec = codec->spec;
15142 hda_nid_t pin;
15143
15144 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015145 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015146 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015147 pin = spec->autocfg.speaker_pins[0];
15148 if (pin)
15149 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015150}
15151
15152#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15153#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15154
15155static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15156{
15157 struct alc_spec *spec = codec->spec;
15158 int i;
15159
15160 for (i = 0; i < AUTO_PIN_LAST; i++) {
15161 hda_nid_t nid = spec->autocfg.input_pins[i];
15162 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015163 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015164 if (nid != ALC861VD_PIN_CD_NID &&
15165 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 snd_hda_codec_write(codec, nid, 0,
15167 AC_VERB_SET_AMP_GAIN_MUTE,
15168 AMP_OUT_MUTE);
15169 }
15170 }
15171}
15172
Takashi Iwaif511b012008-08-15 16:46:42 +020015173#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15174
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015175#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15176#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15177
15178/* add playback controls from the parsed DAC table */
15179/* Based on ALC880 version. But ALC861VD has separate,
15180 * different NIDs for mute/unmute switch and volume control */
15181static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15182 const struct auto_pin_cfg *cfg)
15183{
15184 char name[32];
15185 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15186 hda_nid_t nid_v, nid_s;
15187 int i, err;
15188
15189 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015190 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015191 continue;
15192 nid_v = alc861vd_idx_to_mixer_vol(
15193 alc880_dac_to_idx(
15194 spec->multiout.dac_nids[i]));
15195 nid_s = alc861vd_idx_to_mixer_switch(
15196 alc880_dac_to_idx(
15197 spec->multiout.dac_nids[i]));
15198
15199 if (i == 2) {
15200 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015201 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15202 "Center Playback Volume",
15203 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15204 HDA_OUTPUT));
15205 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015206 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015207 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15208 "LFE Playback Volume",
15209 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15210 HDA_OUTPUT));
15211 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015212 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015213 err = add_control(spec, ALC_CTL_BIND_MUTE,
15214 "Center Playback Switch",
15215 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15216 HDA_INPUT));
15217 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015218 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015219 err = add_control(spec, ALC_CTL_BIND_MUTE,
15220 "LFE Playback Switch",
15221 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15222 HDA_INPUT));
15223 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015224 return err;
15225 } else {
15226 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015227 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15228 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15229 HDA_OUTPUT));
15230 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015231 return err;
15232 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015233 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015234 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015235 HDA_INPUT));
15236 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015237 return err;
15238 }
15239 }
15240 return 0;
15241}
15242
15243/* add playback controls for speaker and HP outputs */
15244/* Based on ALC880 version. But ALC861VD has separate,
15245 * different NIDs for mute/unmute switch and volume control */
15246static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15247 hda_nid_t pin, const char *pfx)
15248{
15249 hda_nid_t nid_v, nid_s;
15250 int err;
15251 char name[32];
15252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015253 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015254 return 0;
15255
15256 if (alc880_is_fixed_pin(pin)) {
15257 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15258 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015259 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015260 spec->multiout.hp_nid = nid_v;
15261 else
15262 spec->multiout.extra_out_nid[0] = nid_v;
15263 /* control HP volume/switch on the output mixer amp */
15264 nid_v = alc861vd_idx_to_mixer_vol(
15265 alc880_fixed_pin_idx(pin));
15266 nid_s = alc861vd_idx_to_mixer_switch(
15267 alc880_fixed_pin_idx(pin));
15268
15269 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015270 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15271 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15272 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015273 return err;
15274 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015275 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15276 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15277 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015278 return err;
15279 } else if (alc880_is_multi_pin(pin)) {
15280 /* set manual connection */
15281 /* we have only a switch on HP-out PIN */
15282 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015283 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15284 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15285 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015286 return err;
15287 }
15288 return 0;
15289}
15290
15291/* parse the BIOS configuration and set up the alc_spec
15292 * return 1 if successful, 0 if the proper config is not found,
15293 * or a negative error code
15294 * Based on ALC880 version - had to change it to override
15295 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15296static int alc861vd_parse_auto_config(struct hda_codec *codec)
15297{
15298 struct alc_spec *spec = codec->spec;
15299 int err;
15300 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15301
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015302 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15303 alc861vd_ignore);
15304 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015305 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015306 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 return 0; /* can't find valid BIOS pin config */
15308
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015309 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15310 if (err < 0)
15311 return err;
15312 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15313 if (err < 0)
15314 return err;
15315 err = alc861vd_auto_create_extra_out(spec,
15316 spec->autocfg.speaker_pins[0],
15317 "Speaker");
15318 if (err < 0)
15319 return err;
15320 err = alc861vd_auto_create_extra_out(spec,
15321 spec->autocfg.hp_pins[0],
15322 "Headphone");
15323 if (err < 0)
15324 return err;
15325 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15326 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015327 return err;
15328
15329 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15330
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015331 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15333
Takashi Iwai603c4012008-07-30 15:01:44 +020015334 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015335 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015336
Takashi Iwaid88897e2008-10-31 15:01:37 +010015337 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015338
15339 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015340 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015341
Takashi Iwai776e1842007-08-29 15:07:11 +020015342 err = alc_auto_add_mic_boost(codec);
15343 if (err < 0)
15344 return err;
15345
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015346 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15347
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015348 return 1;
15349}
15350
15351/* additional initialization for auto-configuration model */
15352static void alc861vd_auto_init(struct hda_codec *codec)
15353{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015354 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355 alc861vd_auto_init_multi_out(codec);
15356 alc861vd_auto_init_hp_out(codec);
15357 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015358 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015359 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015360 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015361}
15362
15363static int patch_alc861vd(struct hda_codec *codec)
15364{
15365 struct alc_spec *spec;
15366 int err, board_config;
15367
15368 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15369 if (spec == NULL)
15370 return -ENOMEM;
15371
15372 codec->spec = spec;
15373
15374 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15375 alc861vd_models,
15376 alc861vd_cfg_tbl);
15377
15378 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015379 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15380 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015381 board_config = ALC861VD_AUTO;
15382 }
15383
15384 if (board_config == ALC861VD_AUTO) {
15385 /* automatic parse from the BIOS config */
15386 err = alc861vd_parse_auto_config(codec);
15387 if (err < 0) {
15388 alc_free(codec);
15389 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015390 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015391 printk(KERN_INFO
15392 "hda_codec: Cannot set up configuration "
15393 "from BIOS. Using base mode...\n");
15394 board_config = ALC861VD_3ST;
15395 }
15396 }
15397
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015398 err = snd_hda_attach_beep_device(codec, 0x23);
15399 if (err < 0) {
15400 alc_free(codec);
15401 return err;
15402 }
15403
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015404 if (board_config != ALC861VD_AUTO)
15405 setup_preset(spec, &alc861vd_presets[board_config]);
15406
Kailang Yang2f893282008-05-27 12:14:47 +020015407 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015408 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015409 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015410 }
15411
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015412 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15413 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15414
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15416 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15417
15418 spec->adc_nids = alc861vd_adc_nids;
15419 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015420 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015421
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015422 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015423 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015424
Takashi Iwai2134ea42008-01-10 16:53:55 +010015425 spec->vmaster_nid = 0x02;
15426
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015427 codec->patch_ops = alc_patch_ops;
15428
15429 if (board_config == ALC861VD_AUTO)
15430 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015431#ifdef CONFIG_SND_HDA_POWER_SAVE
15432 if (!spec->loopback.amplist)
15433 spec->loopback.amplist = alc861vd_loopbacks;
15434#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015435 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015436
15437 return 0;
15438}
15439
15440/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015441 * ALC662 support
15442 *
15443 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15444 * configuration. Each pin widget can choose any input DACs and a mixer.
15445 * Each ADC is connected from a mixer of all inputs. This makes possible
15446 * 6-channel independent captures.
15447 *
15448 * In addition, an independent DAC for the multi-playback (not used in this
15449 * driver yet).
15450 */
15451#define ALC662_DIGOUT_NID 0x06
15452#define ALC662_DIGIN_NID 0x0a
15453
15454static hda_nid_t alc662_dac_nids[4] = {
15455 /* front, rear, clfe, rear_surr */
15456 0x02, 0x03, 0x04
15457};
15458
Kailang Yang622e84c2009-04-21 07:39:04 +020015459static hda_nid_t alc272_dac_nids[2] = {
15460 0x02, 0x03
15461};
15462
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015463static hda_nid_t alc662_adc_nids[1] = {
15464 /* ADC1-2 */
15465 0x09,
15466};
Takashi Iwaie1406342008-02-11 18:32:32 +010015467
Kailang Yang622e84c2009-04-21 07:39:04 +020015468static hda_nid_t alc272_adc_nids[1] = {
15469 /* ADC1-2 */
15470 0x08,
15471};
15472
Kailang Yang77a261b2008-02-19 11:38:05 +010015473static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015474static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15475
Takashi Iwaie1406342008-02-11 18:32:32 +010015476
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015477/* input MUX */
15478/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015479static struct hda_input_mux alc662_capture_source = {
15480 .num_items = 4,
15481 .items = {
15482 { "Mic", 0x0 },
15483 { "Front Mic", 0x1 },
15484 { "Line", 0x2 },
15485 { "CD", 0x4 },
15486 },
15487};
15488
15489static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15490 .num_items = 2,
15491 .items = {
15492 { "Mic", 0x1 },
15493 { "Line", 0x2 },
15494 },
15495};
Kailang Yang291702f2007-10-16 14:28:03 +020015496
15497static struct hda_input_mux alc662_eeepc_capture_source = {
15498 .num_items = 2,
15499 .items = {
15500 { "i-Mic", 0x1 },
15501 { "e-Mic", 0x0 },
15502 },
15503};
15504
Kailang Yang6dda9f42008-05-27 12:05:31 +020015505static struct hda_input_mux alc663_capture_source = {
15506 .num_items = 3,
15507 .items = {
15508 { "Mic", 0x0 },
15509 { "Front Mic", 0x1 },
15510 { "Line", 0x2 },
15511 },
15512};
15513
15514static struct hda_input_mux alc663_m51va_capture_source = {
15515 .num_items = 2,
15516 .items = {
15517 { "Ext-Mic", 0x0 },
15518 { "D-Mic", 0x9 },
15519 },
15520};
15521
Chris Pockelé9541ba12009-05-12 08:08:53 +020015522#if 1 /* set to 0 for testing other input sources below */
15523static struct hda_input_mux alc272_nc10_capture_source = {
15524 .num_items = 2,
15525 .items = {
15526 { "Autoselect Mic", 0x0 },
15527 { "Internal Mic", 0x1 },
15528 },
15529};
15530#else
15531static struct hda_input_mux alc272_nc10_capture_source = {
15532 .num_items = 16,
15533 .items = {
15534 { "Autoselect Mic", 0x0 },
15535 { "Internal Mic", 0x1 },
15536 { "In-0x02", 0x2 },
15537 { "In-0x03", 0x3 },
15538 { "In-0x04", 0x4 },
15539 { "In-0x05", 0x5 },
15540 { "In-0x06", 0x6 },
15541 { "In-0x07", 0x7 },
15542 { "In-0x08", 0x8 },
15543 { "In-0x09", 0x9 },
15544 { "In-0x0a", 0x0a },
15545 { "In-0x0b", 0x0b },
15546 { "In-0x0c", 0x0c },
15547 { "In-0x0d", 0x0d },
15548 { "In-0x0e", 0x0e },
15549 { "In-0x0f", 0x0f },
15550 },
15551};
15552#endif
15553
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015554/*
15555 * 2ch mode
15556 */
15557static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15558 { 2, NULL }
15559};
15560
15561/*
15562 * 2ch mode
15563 */
15564static struct hda_verb alc662_3ST_ch2_init[] = {
15565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15567 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15568 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15569 { } /* end */
15570};
15571
15572/*
15573 * 6ch mode
15574 */
15575static struct hda_verb alc662_3ST_ch6_init[] = {
15576 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15577 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15578 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15579 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15580 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15581 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15582 { } /* end */
15583};
15584
15585static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15586 { 2, alc662_3ST_ch2_init },
15587 { 6, alc662_3ST_ch6_init },
15588};
15589
15590/*
15591 * 2ch mode
15592 */
15593static struct hda_verb alc662_sixstack_ch6_init[] = {
15594 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15595 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15596 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15597 { } /* end */
15598};
15599
15600/*
15601 * 6ch mode
15602 */
15603static struct hda_verb alc662_sixstack_ch8_init[] = {
15604 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15605 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15606 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15607 { } /* end */
15608};
15609
15610static struct hda_channel_mode alc662_5stack_modes[2] = {
15611 { 2, alc662_sixstack_ch6_init },
15612 { 6, alc662_sixstack_ch8_init },
15613};
15614
15615/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15616 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15617 */
15618
15619static struct snd_kcontrol_new alc662_base_mixer[] = {
15620 /* output mixer control */
15621 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015622 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015624 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15626 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015627 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15628 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15630
15631 /*Input mixer control */
15632 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15633 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15634 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15635 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15636 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15637 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015640 { } /* end */
15641};
15642
15643static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15644 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015645 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15647 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15648 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15649 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15650 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15653 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15654 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015655 { } /* end */
15656};
15657
15658static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15659 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015660 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015662 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015665 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15666 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15668 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15669 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15674 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15675 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015676 { } /* end */
15677};
15678
15679static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15680 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15681 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15683 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015689 { } /* end */
15690};
15691
Kailang Yang291702f2007-10-16 14:28:03 +020015692static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015693 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15694 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015695
15696 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15697 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15698 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15699
15700 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15701 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15702 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15703 { } /* end */
15704};
15705
Kailang Yang8c427222008-01-10 13:03:59 +010015706static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015707 ALC262_HIPPO_MASTER_SWITCH,
15708 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015709 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015710 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15711 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015712 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15713 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15714 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15717 { } /* end */
15718};
15719
Kailang Yangf1d4e282008-08-26 14:03:29 +020015720static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15721 .ops = &snd_hda_bind_vol,
15722 .values = {
15723 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15724 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15725 0
15726 },
15727};
15728
15729static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15730 .ops = &snd_hda_bind_sw,
15731 .values = {
15732 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15733 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15734 0
15735 },
15736};
15737
Kailang Yang6dda9f42008-05-27 12:05:31 +020015738static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015739 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15740 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15743 { } /* end */
15744};
15745
15746static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15747 .ops = &snd_hda_bind_sw,
15748 .values = {
15749 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15750 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15751 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15752 0
15753 },
15754};
15755
15756static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15757 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15758 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15761 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15762 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15763
15764 { } /* end */
15765};
15766
15767static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15768 .ops = &snd_hda_bind_sw,
15769 .values = {
15770 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15771 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15772 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15773 0
15774 },
15775};
15776
15777static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15778 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15779 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15782 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15783 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15784 { } /* end */
15785};
15786
15787static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015788 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15789 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15793 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15794 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15795 { } /* end */
15796};
15797
15798static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15799 .ops = &snd_hda_bind_vol,
15800 .values = {
15801 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15802 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15803 0
15804 },
15805};
15806
15807static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15808 .ops = &snd_hda_bind_sw,
15809 .values = {
15810 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15811 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15812 0
15813 },
15814};
15815
15816static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15817 HDA_BIND_VOL("Master Playback Volume",
15818 &alc663_asus_two_bind_master_vol),
15819 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015824 { } /* end */
15825};
15826
15827static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15828 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15829 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015834 { } /* end */
15835};
15836
15837static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15838 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15839 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15840 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15841 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15843
15844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15846 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15847 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15848 { } /* end */
15849};
15850
15851static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15852 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15853 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15854 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15855
15856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15859 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15862 { } /* end */
15863};
15864
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015865static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15866 {
15867 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15868 .name = "Channel Mode",
15869 .info = alc_ch_mode_info,
15870 .get = alc_ch_mode_get,
15871 .put = alc_ch_mode_put,
15872 },
15873 { } /* end */
15874};
15875
15876static struct hda_verb alc662_init_verbs[] = {
15877 /* ADC: mute amp left and right */
15878 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15879 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15880 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15881
Takashi Iwaicb53c622007-08-10 17:21:45 +020015882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015887
Kailang Yangb60dd392007-09-20 12:50:29 +020015888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015894
15895 /* Front Pin: output 0 (0x0c) */
15896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15898
15899 /* Rear Pin: output 1 (0x0d) */
15900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15902
15903 /* CLFE Pin: output 2 (0x0e) */
15904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15906
15907 /* Mic (rear) pin: input vref at 80% */
15908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15910 /* Front Mic pin: input vref at 80% */
15911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15913 /* Line In pin: input */
15914 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15915 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15916 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15917 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15918 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15919 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15920 /* CD pin widget for input */
15921 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15922
15923 /* FIXME: use matrix-type input source selection */
15924 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15925 /* Input mixer */
15926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015928
15929 /* always trun on EAPD */
15930 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15931 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015933 { }
15934};
15935
15936static struct hda_verb alc662_sue_init_verbs[] = {
15937 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015939 {}
15940};
15941
15942static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15943 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15944 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15945 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015946};
15947
Kailang Yang8c427222008-01-10 13:03:59 +010015948/* Set Unsolicited Event*/
15949static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15950 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15951 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15952 {}
15953};
15954
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015955/*
15956 * generic initialization of ADC, input mixers and output mixers
15957 */
15958static struct hda_verb alc662_auto_init_verbs[] = {
15959 /*
15960 * Unmute ADC and set the default input to mic-in
15961 */
15962 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15964
15965 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15966 * mixer widget
15967 * Note: PASD motherboards uses the Line In 2 as the input for front
15968 * panel mic (mic 2)
15969 */
15970 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015976
15977 /*
15978 * Set up output mixers (0x0c - 0x0f)
15979 */
15980 /* set vol=0 to output mixers */
15981 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15982 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15983 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15984
15985 /* set up input amps for analog loopback */
15986 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015993
15994
15995 /* FIXME: use matrix-type input source selection */
15996 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15997 /* Input mixer */
15998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016000 { }
16001};
16002
Takashi Iwai24fb9172008-09-02 14:48:20 +020016003/* additional verbs for ALC663 */
16004static struct hda_verb alc663_auto_init_verbs[] = {
16005 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16006 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16007 { }
16008};
16009
Kailang Yang6dda9f42008-05-27 12:05:31 +020016010static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016013 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16014 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016015 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16016 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016018 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16019 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16020 {}
16021};
16022
Kailang Yangf1d4e282008-08-26 14:03:29 +020016023static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16024 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16025 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16026 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16029 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16030 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16031 {}
16032};
16033
16034static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16035 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16037 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16038 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16041 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16043 {}
16044};
16045
16046static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16049 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16052 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16054 {}
16055};
16056
16057static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16058 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16059 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16060 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16061 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16067 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16068 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16069 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16070 {}
16071};
16072
16073static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16074 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16077 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16078 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16080 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16083 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16084 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16085 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16086 {}
16087};
16088
Kailang Yang6dda9f42008-05-27 12:05:31 +020016089static struct hda_verb alc663_g71v_init_verbs[] = {
16090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16091 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16092 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16093
16094 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16095 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16096 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16097
16098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16099 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16100 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16101 {}
16102};
16103
16104static struct hda_verb alc663_g50v_init_verbs[] = {
16105 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16106 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16107 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16108
16109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16110 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16111 {}
16112};
16113
Kailang Yangf1d4e282008-08-26 14:03:29 +020016114static struct hda_verb alc662_ecs_init_verbs[] = {
16115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16117 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16118 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16119 {}
16120};
16121
Kailang Yang622e84c2009-04-21 07:39:04 +020016122static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16123 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16124 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16126 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16127 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16128 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16129 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16132 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16133 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16134 {}
16135};
16136
16137static struct hda_verb alc272_dell_init_verbs[] = {
16138 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16139 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16141 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16142 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16143 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16144 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16147 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16148 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16149 {}
16150};
16151
Kailang Yangf1d4e282008-08-26 14:03:29 +020016152static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16153 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16154 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16155 { } /* end */
16156};
16157
Kailang Yang622e84c2009-04-21 07:39:04 +020016158static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16159 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16160 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16161 { } /* end */
16162};
16163
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016164static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16165{
16166 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016167 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016168
16169 present = snd_hda_codec_read(codec, 0x14, 0,
16170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016171 bits = present ? HDA_AMP_MUTE : 0;
16172 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16173 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016174}
16175
16176static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16177{
16178 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016179 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016180
16181 present = snd_hda_codec_read(codec, 0x1b, 0,
16182 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016183 bits = present ? HDA_AMP_MUTE : 0;
16184 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16185 HDA_AMP_MUTE, bits);
16186 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16187 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016188}
16189
16190static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16191 unsigned int res)
16192{
16193 if ((res >> 26) == ALC880_HP_EVENT)
16194 alc662_lenovo_101e_all_automute(codec);
16195 if ((res >> 26) == ALC880_FRONT_EVENT)
16196 alc662_lenovo_101e_ispeaker_automute(codec);
16197}
16198
Kailang Yang291702f2007-10-16 14:28:03 +020016199static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16200{
16201 unsigned int present;
16202
16203 present = snd_hda_codec_read(codec, 0x18, 0,
16204 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16205 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16206 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16207 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16208 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16209 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16210 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16211 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16212 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16213}
16214
16215/* unsolicited event for HP jack sensing */
16216static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16217 unsigned int res)
16218{
Kailang Yang291702f2007-10-16 14:28:03 +020016219 if ((res >> 26) == ALC880_MIC_EVENT)
16220 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016221 else
16222 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016223}
16224
16225static void alc662_eeepc_inithook(struct hda_codec *codec)
16226{
Takashi Iwai42171c12009-05-08 14:11:43 +020016227 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016228 alc662_eeepc_mic_automute(codec);
16229}
16230
Kailang Yang8c427222008-01-10 13:03:59 +010016231static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16232{
Takashi Iwai42171c12009-05-08 14:11:43 +020016233 struct alc_spec *spec = codec->spec;
16234
16235 spec->autocfg.hp_pins[0] = 0x14;
16236 spec->autocfg.speaker_pins[0] = 0x1b;
16237 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016238}
16239
Kailang Yang6dda9f42008-05-27 12:05:31 +020016240static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16241{
16242 unsigned int present;
16243 unsigned char bits;
16244
16245 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016246 AC_VERB_GET_PIN_SENSE, 0)
16247 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016248 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016249 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16250 AMP_IN_MUTE(0), bits);
16251 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16252 AMP_IN_MUTE(0), bits);
16253}
16254
16255static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16256{
16257 unsigned int present;
16258 unsigned char bits;
16259
16260 present = snd_hda_codec_read(codec, 0x21, 0,
16261 AC_VERB_GET_PIN_SENSE, 0)
16262 & AC_PINSENSE_PRESENCE;
16263 bits = present ? HDA_AMP_MUTE : 0;
16264 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16265 AMP_IN_MUTE(0), bits);
16266 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16267 AMP_IN_MUTE(0), bits);
16268 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16269 AMP_IN_MUTE(0), bits);
16270 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16271 AMP_IN_MUTE(0), bits);
16272}
16273
16274static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16275{
16276 unsigned int present;
16277 unsigned char bits;
16278
16279 present = snd_hda_codec_read(codec, 0x15, 0,
16280 AC_VERB_GET_PIN_SENSE, 0)
16281 & AC_PINSENSE_PRESENCE;
16282 bits = present ? HDA_AMP_MUTE : 0;
16283 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16284 AMP_IN_MUTE(0), bits);
16285 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16286 AMP_IN_MUTE(0), bits);
16287 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16288 AMP_IN_MUTE(0), bits);
16289 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16290 AMP_IN_MUTE(0), bits);
16291}
16292
16293static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16294{
16295 unsigned int present;
16296 unsigned char bits;
16297
16298 present = snd_hda_codec_read(codec, 0x1b, 0,
16299 AC_VERB_GET_PIN_SENSE, 0)
16300 & AC_PINSENSE_PRESENCE;
16301 bits = present ? 0 : PIN_OUT;
16302 snd_hda_codec_write(codec, 0x14, 0,
16303 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16304}
16305
16306static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16307{
16308 unsigned int present1, present2;
16309
16310 present1 = snd_hda_codec_read(codec, 0x21, 0,
16311 AC_VERB_GET_PIN_SENSE, 0)
16312 & AC_PINSENSE_PRESENCE;
16313 present2 = snd_hda_codec_read(codec, 0x15, 0,
16314 AC_VERB_GET_PIN_SENSE, 0)
16315 & AC_PINSENSE_PRESENCE;
16316
16317 if (present1 || present2) {
16318 snd_hda_codec_write_cache(codec, 0x14, 0,
16319 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16320 } else {
16321 snd_hda_codec_write_cache(codec, 0x14, 0,
16322 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16323 }
16324}
16325
16326static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16327{
16328 unsigned int present1, present2;
16329
16330 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16331 AC_VERB_GET_PIN_SENSE, 0)
16332 & AC_PINSENSE_PRESENCE;
16333 present2 = snd_hda_codec_read(codec, 0x15, 0,
16334 AC_VERB_GET_PIN_SENSE, 0)
16335 & AC_PINSENSE_PRESENCE;
16336
16337 if (present1 || present2) {
16338 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16339 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16340 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16341 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16342 } else {
16343 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16344 AMP_IN_MUTE(0), 0);
16345 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16346 AMP_IN_MUTE(0), 0);
16347 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016348}
16349
16350static void alc663_m51va_mic_automute(struct hda_codec *codec)
16351{
16352 unsigned int present;
16353
16354 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016355 AC_VERB_GET_PIN_SENSE, 0)
16356 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016357 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016358 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016359 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016360 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016361 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016362 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016363 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016364 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016365}
16366
16367static void alc663_m51va_unsol_event(struct hda_codec *codec,
16368 unsigned int res)
16369{
16370 switch (res >> 26) {
16371 case ALC880_HP_EVENT:
16372 alc663_m51va_speaker_automute(codec);
16373 break;
16374 case ALC880_MIC_EVENT:
16375 alc663_m51va_mic_automute(codec);
16376 break;
16377 }
16378}
16379
16380static void alc663_m51va_inithook(struct hda_codec *codec)
16381{
16382 alc663_m51va_speaker_automute(codec);
16383 alc663_m51va_mic_automute(codec);
16384}
16385
Kailang Yangf1d4e282008-08-26 14:03:29 +020016386/* ***************** Mode1 ******************************/
16387static void alc663_mode1_unsol_event(struct hda_codec *codec,
16388 unsigned int res)
16389{
16390 switch (res >> 26) {
16391 case ALC880_HP_EVENT:
16392 alc663_m51va_speaker_automute(codec);
16393 break;
16394 case ALC880_MIC_EVENT:
16395 alc662_eeepc_mic_automute(codec);
16396 break;
16397 }
16398}
16399
16400static void alc663_mode1_inithook(struct hda_codec *codec)
16401{
16402 alc663_m51va_speaker_automute(codec);
16403 alc662_eeepc_mic_automute(codec);
16404}
16405/* ***************** Mode2 ******************************/
16406static void alc662_mode2_unsol_event(struct hda_codec *codec,
16407 unsigned int res)
16408{
16409 switch (res >> 26) {
16410 case ALC880_HP_EVENT:
16411 alc662_f5z_speaker_automute(codec);
16412 break;
16413 case ALC880_MIC_EVENT:
16414 alc662_eeepc_mic_automute(codec);
16415 break;
16416 }
16417}
16418
16419static void alc662_mode2_inithook(struct hda_codec *codec)
16420{
16421 alc662_f5z_speaker_automute(codec);
16422 alc662_eeepc_mic_automute(codec);
16423}
16424/* ***************** Mode3 ******************************/
16425static void alc663_mode3_unsol_event(struct hda_codec *codec,
16426 unsigned int res)
16427{
16428 switch (res >> 26) {
16429 case ALC880_HP_EVENT:
16430 alc663_two_hp_m1_speaker_automute(codec);
16431 break;
16432 case ALC880_MIC_EVENT:
16433 alc662_eeepc_mic_automute(codec);
16434 break;
16435 }
16436}
16437
16438static void alc663_mode3_inithook(struct hda_codec *codec)
16439{
16440 alc663_two_hp_m1_speaker_automute(codec);
16441 alc662_eeepc_mic_automute(codec);
16442}
16443/* ***************** Mode4 ******************************/
16444static void alc663_mode4_unsol_event(struct hda_codec *codec,
16445 unsigned int res)
16446{
16447 switch (res >> 26) {
16448 case ALC880_HP_EVENT:
16449 alc663_21jd_two_speaker_automute(codec);
16450 break;
16451 case ALC880_MIC_EVENT:
16452 alc662_eeepc_mic_automute(codec);
16453 break;
16454 }
16455}
16456
16457static void alc663_mode4_inithook(struct hda_codec *codec)
16458{
16459 alc663_21jd_two_speaker_automute(codec);
16460 alc662_eeepc_mic_automute(codec);
16461}
16462/* ***************** Mode5 ******************************/
16463static void alc663_mode5_unsol_event(struct hda_codec *codec,
16464 unsigned int res)
16465{
16466 switch (res >> 26) {
16467 case ALC880_HP_EVENT:
16468 alc663_15jd_two_speaker_automute(codec);
16469 break;
16470 case ALC880_MIC_EVENT:
16471 alc662_eeepc_mic_automute(codec);
16472 break;
16473 }
16474}
16475
16476static void alc663_mode5_inithook(struct hda_codec *codec)
16477{
16478 alc663_15jd_two_speaker_automute(codec);
16479 alc662_eeepc_mic_automute(codec);
16480}
16481/* ***************** Mode6 ******************************/
16482static void alc663_mode6_unsol_event(struct hda_codec *codec,
16483 unsigned int res)
16484{
16485 switch (res >> 26) {
16486 case ALC880_HP_EVENT:
16487 alc663_two_hp_m2_speaker_automute(codec);
16488 break;
16489 case ALC880_MIC_EVENT:
16490 alc662_eeepc_mic_automute(codec);
16491 break;
16492 }
16493}
16494
16495static void alc663_mode6_inithook(struct hda_codec *codec)
16496{
16497 alc663_two_hp_m2_speaker_automute(codec);
16498 alc662_eeepc_mic_automute(codec);
16499}
16500
Kailang Yang6dda9f42008-05-27 12:05:31 +020016501static void alc663_g71v_hp_automute(struct hda_codec *codec)
16502{
16503 unsigned int present;
16504 unsigned char bits;
16505
16506 present = snd_hda_codec_read(codec, 0x21, 0,
16507 AC_VERB_GET_PIN_SENSE, 0)
16508 & AC_PINSENSE_PRESENCE;
16509 bits = present ? HDA_AMP_MUTE : 0;
16510 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16511 HDA_AMP_MUTE, bits);
16512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16513 HDA_AMP_MUTE, bits);
16514}
16515
16516static void alc663_g71v_front_automute(struct hda_codec *codec)
16517{
16518 unsigned int present;
16519 unsigned char bits;
16520
16521 present = snd_hda_codec_read(codec, 0x15, 0,
16522 AC_VERB_GET_PIN_SENSE, 0)
16523 & AC_PINSENSE_PRESENCE;
16524 bits = present ? HDA_AMP_MUTE : 0;
16525 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16526 HDA_AMP_MUTE, bits);
16527}
16528
16529static void alc663_g71v_unsol_event(struct hda_codec *codec,
16530 unsigned int res)
16531{
16532 switch (res >> 26) {
16533 case ALC880_HP_EVENT:
16534 alc663_g71v_hp_automute(codec);
16535 break;
16536 case ALC880_FRONT_EVENT:
16537 alc663_g71v_front_automute(codec);
16538 break;
16539 case ALC880_MIC_EVENT:
16540 alc662_eeepc_mic_automute(codec);
16541 break;
16542 }
16543}
16544
16545static void alc663_g71v_inithook(struct hda_codec *codec)
16546{
16547 alc663_g71v_front_automute(codec);
16548 alc663_g71v_hp_automute(codec);
16549 alc662_eeepc_mic_automute(codec);
16550}
16551
16552static void alc663_g50v_unsol_event(struct hda_codec *codec,
16553 unsigned int res)
16554{
16555 switch (res >> 26) {
16556 case ALC880_HP_EVENT:
16557 alc663_m51va_speaker_automute(codec);
16558 break;
16559 case ALC880_MIC_EVENT:
16560 alc662_eeepc_mic_automute(codec);
16561 break;
16562 }
16563}
16564
16565static void alc663_g50v_inithook(struct hda_codec *codec)
16566{
16567 alc663_m51va_speaker_automute(codec);
16568 alc662_eeepc_mic_automute(codec);
16569}
16570
Kailang Yangf1d4e282008-08-26 14:03:29 +020016571static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16572 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016573 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016574
16575 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16576 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16577 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16578
16579 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16580 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16581 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16582 { } /* end */
16583};
16584
Chris Pockelé9541ba12009-05-12 08:08:53 +020016585static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16586 /* Master Playback automatically created from Speaker and Headphone */
16587 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16588 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16589 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16591
16592 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16593 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16594 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16595
16596 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16597 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16598 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16599 { } /* end */
16600};
16601
Takashi Iwaicb53c622007-08-10 17:21:45 +020016602#ifdef CONFIG_SND_HDA_POWER_SAVE
16603#define alc662_loopbacks alc880_loopbacks
16604#endif
16605
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016606
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016607/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016608#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16609#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16610#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16611#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16612
16613/*
16614 * configuration and preset
16615 */
16616static const char *alc662_models[ALC662_MODEL_LAST] = {
16617 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16618 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16619 [ALC662_3ST_6ch] = "3stack-6ch",
16620 [ALC662_5ST_DIG] = "6stack-dig",
16621 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016622 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016623 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016624 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016625 [ALC663_ASUS_M51VA] = "m51va",
16626 [ALC663_ASUS_G71V] = "g71v",
16627 [ALC663_ASUS_H13] = "h13",
16628 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016629 [ALC663_ASUS_MODE1] = "asus-mode1",
16630 [ALC662_ASUS_MODE2] = "asus-mode2",
16631 [ALC663_ASUS_MODE3] = "asus-mode3",
16632 [ALC663_ASUS_MODE4] = "asus-mode4",
16633 [ALC663_ASUS_MODE5] = "asus-mode5",
16634 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016635 [ALC272_DELL] = "dell",
16636 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016637 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016638 [ALC662_AUTO] = "auto",
16639};
16640
16641static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016642 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016643 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16644 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016645 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16646 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16647 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16648 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16649 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16650 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16651 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16652 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16653 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16654 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16655 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16656 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016657 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16658 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16659 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016660 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16661 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16662 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16663 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016664 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016665 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16666 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016667 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016668 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16669 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16670 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016671 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16672 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16673 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016674 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16675 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16676 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016677 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016678 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16679 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016680 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016681 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016682 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016683 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16684 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16685 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016686 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016687 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16688 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016689 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016690 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016691 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016692 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016693 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16694 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016695 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016696 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16697 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016698 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016699 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016700 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016701 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016702 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016703 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16704 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016705 {}
16706};
16707
16708static struct alc_config_preset alc662_presets[] = {
16709 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016710 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016711 .init_verbs = { alc662_init_verbs },
16712 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16713 .dac_nids = alc662_dac_nids,
16714 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016715 .dig_in_nid = ALC662_DIGIN_NID,
16716 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16717 .channel_mode = alc662_3ST_2ch_modes,
16718 .input_mux = &alc662_capture_source,
16719 },
16720 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016721 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016722 .init_verbs = { alc662_init_verbs },
16723 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16724 .dac_nids = alc662_dac_nids,
16725 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016726 .dig_in_nid = ALC662_DIGIN_NID,
16727 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16728 .channel_mode = alc662_3ST_6ch_modes,
16729 .need_dac_fix = 1,
16730 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016731 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016732 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016733 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016734 .init_verbs = { alc662_init_verbs },
16735 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16736 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016737 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16738 .channel_mode = alc662_3ST_6ch_modes,
16739 .need_dac_fix = 1,
16740 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016741 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016743 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016744 .init_verbs = { alc662_init_verbs },
16745 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16746 .dac_nids = alc662_dac_nids,
16747 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016748 .dig_in_nid = ALC662_DIGIN_NID,
16749 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16750 .channel_mode = alc662_5stack_modes,
16751 .input_mux = &alc662_capture_source,
16752 },
16753 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016754 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16756 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16757 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016758 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16759 .channel_mode = alc662_3ST_2ch_modes,
16760 .input_mux = &alc662_lenovo_101e_capture_source,
16761 .unsol_event = alc662_lenovo_101e_unsol_event,
16762 .init_hook = alc662_lenovo_101e_all_automute,
16763 },
Kailang Yang291702f2007-10-16 14:28:03 +020016764 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016765 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016766 .init_verbs = { alc662_init_verbs,
16767 alc662_eeepc_sue_init_verbs },
16768 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16769 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016770 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16771 .channel_mode = alc662_3ST_2ch_modes,
16772 .input_mux = &alc662_eeepc_capture_source,
16773 .unsol_event = alc662_eeepc_unsol_event,
16774 .init_hook = alc662_eeepc_inithook,
16775 },
Kailang Yang8c427222008-01-10 13:03:59 +010016776 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016777 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016778 alc662_chmode_mixer },
16779 .init_verbs = { alc662_init_verbs,
16780 alc662_eeepc_ep20_sue_init_verbs },
16781 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16782 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016783 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16784 .channel_mode = alc662_3ST_6ch_modes,
16785 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016786 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016787 .init_hook = alc662_eeepc_ep20_inithook,
16788 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016789 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016790 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016791 .init_verbs = { alc662_init_verbs,
16792 alc662_ecs_init_verbs },
16793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16794 .dac_nids = alc662_dac_nids,
16795 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16796 .channel_mode = alc662_3ST_2ch_modes,
16797 .input_mux = &alc662_eeepc_capture_source,
16798 .unsol_event = alc662_eeepc_unsol_event,
16799 .init_hook = alc662_eeepc_inithook,
16800 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016801 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016802 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016803 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16804 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16805 .dac_nids = alc662_dac_nids,
16806 .dig_out_nid = ALC662_DIGOUT_NID,
16807 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16808 .channel_mode = alc662_3ST_2ch_modes,
16809 .input_mux = &alc663_m51va_capture_source,
16810 .unsol_event = alc663_m51va_unsol_event,
16811 .init_hook = alc663_m51va_inithook,
16812 },
16813 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016814 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016815 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16816 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16817 .dac_nids = alc662_dac_nids,
16818 .dig_out_nid = ALC662_DIGOUT_NID,
16819 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16820 .channel_mode = alc662_3ST_2ch_modes,
16821 .input_mux = &alc662_eeepc_capture_source,
16822 .unsol_event = alc663_g71v_unsol_event,
16823 .init_hook = alc663_g71v_inithook,
16824 },
16825 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016826 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016827 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16829 .dac_nids = alc662_dac_nids,
16830 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16831 .channel_mode = alc662_3ST_2ch_modes,
16832 .input_mux = &alc663_m51va_capture_source,
16833 .unsol_event = alc663_m51va_unsol_event,
16834 .init_hook = alc663_m51va_inithook,
16835 },
16836 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016837 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016838 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16839 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16840 .dac_nids = alc662_dac_nids,
16841 .dig_out_nid = ALC662_DIGOUT_NID,
16842 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16843 .channel_mode = alc662_3ST_6ch_modes,
16844 .input_mux = &alc663_capture_source,
16845 .unsol_event = alc663_g50v_unsol_event,
16846 .init_hook = alc663_g50v_inithook,
16847 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016848 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016849 .mixers = { alc663_m51va_mixer },
16850 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016851 .init_verbs = { alc662_init_verbs,
16852 alc663_21jd_amic_init_verbs },
16853 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16854 .hp_nid = 0x03,
16855 .dac_nids = alc662_dac_nids,
16856 .dig_out_nid = ALC662_DIGOUT_NID,
16857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16858 .channel_mode = alc662_3ST_2ch_modes,
16859 .input_mux = &alc662_eeepc_capture_source,
16860 .unsol_event = alc663_mode1_unsol_event,
16861 .init_hook = alc663_mode1_inithook,
16862 },
16863 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016864 .mixers = { alc662_1bjd_mixer },
16865 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016866 .init_verbs = { alc662_init_verbs,
16867 alc662_1bjd_amic_init_verbs },
16868 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16869 .dac_nids = alc662_dac_nids,
16870 .dig_out_nid = ALC662_DIGOUT_NID,
16871 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16872 .channel_mode = alc662_3ST_2ch_modes,
16873 .input_mux = &alc662_eeepc_capture_source,
16874 .unsol_event = alc662_mode2_unsol_event,
16875 .init_hook = alc662_mode2_inithook,
16876 },
16877 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016878 .mixers = { alc663_two_hp_m1_mixer },
16879 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016880 .init_verbs = { alc662_init_verbs,
16881 alc663_two_hp_amic_m1_init_verbs },
16882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16883 .hp_nid = 0x03,
16884 .dac_nids = alc662_dac_nids,
16885 .dig_out_nid = ALC662_DIGOUT_NID,
16886 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16887 .channel_mode = alc662_3ST_2ch_modes,
16888 .input_mux = &alc662_eeepc_capture_source,
16889 .unsol_event = alc663_mode3_unsol_event,
16890 .init_hook = alc663_mode3_inithook,
16891 },
16892 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016893 .mixers = { alc663_asus_21jd_clfe_mixer },
16894 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016895 .init_verbs = { alc662_init_verbs,
16896 alc663_21jd_amic_init_verbs},
16897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16898 .hp_nid = 0x03,
16899 .dac_nids = alc662_dac_nids,
16900 .dig_out_nid = ALC662_DIGOUT_NID,
16901 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16902 .channel_mode = alc662_3ST_2ch_modes,
16903 .input_mux = &alc662_eeepc_capture_source,
16904 .unsol_event = alc663_mode4_unsol_event,
16905 .init_hook = alc663_mode4_inithook,
16906 },
16907 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016908 .mixers = { alc663_asus_15jd_clfe_mixer },
16909 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016910 .init_verbs = { alc662_init_verbs,
16911 alc663_15jd_amic_init_verbs },
16912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16913 .hp_nid = 0x03,
16914 .dac_nids = alc662_dac_nids,
16915 .dig_out_nid = ALC662_DIGOUT_NID,
16916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16917 .channel_mode = alc662_3ST_2ch_modes,
16918 .input_mux = &alc662_eeepc_capture_source,
16919 .unsol_event = alc663_mode5_unsol_event,
16920 .init_hook = alc663_mode5_inithook,
16921 },
16922 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016923 .mixers = { alc663_two_hp_m2_mixer },
16924 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016925 .init_verbs = { alc662_init_verbs,
16926 alc663_two_hp_amic_m2_init_verbs },
16927 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16928 .hp_nid = 0x03,
16929 .dac_nids = alc662_dac_nids,
16930 .dig_out_nid = ALC662_DIGOUT_NID,
16931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16932 .channel_mode = alc662_3ST_2ch_modes,
16933 .input_mux = &alc662_eeepc_capture_source,
16934 .unsol_event = alc663_mode6_unsol_event,
16935 .init_hook = alc663_mode6_inithook,
16936 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016937 [ALC272_DELL] = {
16938 .mixers = { alc663_m51va_mixer },
16939 .cap_mixer = alc272_auto_capture_mixer,
16940 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16942 .dac_nids = alc662_dac_nids,
16943 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16944 .adc_nids = alc272_adc_nids,
16945 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16946 .capsrc_nids = alc272_capsrc_nids,
16947 .channel_mode = alc662_3ST_2ch_modes,
16948 .input_mux = &alc663_m51va_capture_source,
16949 .unsol_event = alc663_m51va_unsol_event,
16950 .init_hook = alc663_m51va_inithook,
16951 },
16952 [ALC272_DELL_ZM1] = {
16953 .mixers = { alc663_m51va_mixer },
16954 .cap_mixer = alc662_auto_capture_mixer,
16955 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16956 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16957 .dac_nids = alc662_dac_nids,
16958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16959 .adc_nids = alc662_adc_nids,
16960 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16961 .capsrc_nids = alc662_capsrc_nids,
16962 .channel_mode = alc662_3ST_2ch_modes,
16963 .input_mux = &alc663_m51va_capture_source,
16964 .unsol_event = alc663_m51va_unsol_event,
16965 .init_hook = alc663_m51va_inithook,
16966 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016967 [ALC272_SAMSUNG_NC10] = {
16968 .mixers = { alc272_nc10_mixer },
16969 .init_verbs = { alc662_init_verbs,
16970 alc663_21jd_amic_init_verbs },
16971 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16972 .dac_nids = alc272_dac_nids,
16973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16974 .channel_mode = alc662_3ST_2ch_modes,
16975 .input_mux = &alc272_nc10_capture_source,
16976 .unsol_event = alc663_mode4_unsol_event,
16977 .init_hook = alc663_mode4_inithook,
16978 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016979};
16980
16981
16982/*
16983 * BIOS auto configuration
16984 */
16985
16986/* add playback controls from the parsed DAC table */
16987static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16988 const struct auto_pin_cfg *cfg)
16989{
16990 char name[32];
16991 static const char *chname[4] = {
16992 "Front", "Surround", NULL /*CLFE*/, "Side"
16993 };
16994 hda_nid_t nid;
16995 int i, err;
16996
16997 for (i = 0; i < cfg->line_outs; i++) {
16998 if (!spec->multiout.dac_nids[i])
16999 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017000 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017001 if (i == 2) {
17002 /* Center/LFE */
17003 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17004 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017005 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17006 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007 if (err < 0)
17008 return err;
17009 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17010 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017011 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17012 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017013 if (err < 0)
17014 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017015 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017016 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017017 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017018 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017019 if (err < 0)
17020 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017021 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017022 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017023 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017024 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017025 if (err < 0)
17026 return err;
17027 } else {
17028 sprintf(name, "%s Playback Volume", chname[i]);
17029 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017030 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17031 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017032 if (err < 0)
17033 return err;
17034 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017035 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17036 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17037 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017038 if (err < 0)
17039 return err;
17040 }
17041 }
17042 return 0;
17043}
17044
17045/* add playback controls for speaker and HP outputs */
17046static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17047 const char *pfx)
17048{
17049 hda_nid_t nid;
17050 int err;
17051 char name[32];
17052
17053 if (!pin)
17054 return 0;
17055
Takashi Iwai24fb9172008-09-02 14:48:20 +020017056 if (pin == 0x17) {
17057 /* ALC663 has a mono output pin on 0x17 */
17058 sprintf(name, "%s Playback Switch", pfx);
17059 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17060 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17061 return err;
17062 }
17063
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017064 if (alc880_is_fixed_pin(pin)) {
17065 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017066 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067 /* specify the DAC as the extra output */
17068 if (!spec->multiout.hp_nid)
17069 spec->multiout.hp_nid = nid;
17070 else
17071 spec->multiout.extra_out_nid[0] = nid;
17072 /* control HP volume/switch on the output mixer amp */
17073 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17074 sprintf(name, "%s Playback Volume", pfx);
17075 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17076 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17077 if (err < 0)
17078 return err;
17079 sprintf(name, "%s Playback Switch", pfx);
17080 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17081 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17082 if (err < 0)
17083 return err;
17084 } else if (alc880_is_multi_pin(pin)) {
17085 /* set manual connection */
17086 /* we have only a switch on HP-out PIN */
17087 sprintf(name, "%s Playback Switch", pfx);
17088 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17089 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17090 if (err < 0)
17091 return err;
17092 }
17093 return 0;
17094}
17095
Takashi Iwai2d864c42009-03-20 12:52:47 +010017096/* return the index of the src widget from the connection list of the nid.
17097 * return -1 if not found
17098 */
17099static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17100 hda_nid_t src)
17101{
17102 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17103 int i, conns;
17104
17105 conns = snd_hda_get_connections(codec, nid, conn_list,
17106 ARRAY_SIZE(conn_list));
17107 if (conns < 0)
17108 return -1;
17109 for (i = 0; i < conns; i++)
17110 if (conn_list[i] == src)
17111 return i;
17112 return -1;
17113}
17114
17115static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17116{
Takashi Iwai1327a322009-03-23 13:07:47 +010017117 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017118 return (pincap & AC_PINCAP_IN) != 0;
17119}
17120
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017121/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017122static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017123 const struct auto_pin_cfg *cfg)
17124{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017125 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017126 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017127 int i, err, idx;
17128
17129 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017130 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17131 idx = alc662_input_pin_idx(codec, 0x0b,
17132 cfg->input_pins[i]);
17133 if (idx >= 0) {
17134 err = new_analog_input(spec, cfg->input_pins[i],
17135 auto_pin_cfg_labels[i],
17136 idx, 0x0b);
17137 if (err < 0)
17138 return err;
17139 }
17140 idx = alc662_input_pin_idx(codec, 0x22,
17141 cfg->input_pins[i]);
17142 if (idx >= 0) {
17143 imux->items[imux->num_items].label =
17144 auto_pin_cfg_labels[i];
17145 imux->items[imux->num_items].index = idx;
17146 imux->num_items++;
17147 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017148 }
17149 }
17150 return 0;
17151}
17152
17153static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17154 hda_nid_t nid, int pin_type,
17155 int dac_idx)
17156{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017157 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017158 /* need the manual connection? */
17159 if (alc880_is_multi_pin(nid)) {
17160 struct alc_spec *spec = codec->spec;
17161 int idx = alc880_multi_pin_idx(nid);
17162 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17163 AC_VERB_SET_CONNECT_SEL,
17164 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17165 }
17166}
17167
17168static void alc662_auto_init_multi_out(struct hda_codec *codec)
17169{
17170 struct alc_spec *spec = codec->spec;
17171 int i;
17172
17173 for (i = 0; i <= HDA_SIDE; i++) {
17174 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017175 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017176 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017177 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017178 i);
17179 }
17180}
17181
17182static void alc662_auto_init_hp_out(struct hda_codec *codec)
17183{
17184 struct alc_spec *spec = codec->spec;
17185 hda_nid_t pin;
17186
17187 pin = spec->autocfg.hp_pins[0];
17188 if (pin) /* connect to front */
17189 /* use dac 0 */
17190 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017191 pin = spec->autocfg.speaker_pins[0];
17192 if (pin)
17193 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017194}
17195
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017196#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17197
17198static void alc662_auto_init_analog_input(struct hda_codec *codec)
17199{
17200 struct alc_spec *spec = codec->spec;
17201 int i;
17202
17203 for (i = 0; i < AUTO_PIN_LAST; i++) {
17204 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017205 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017206 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017207 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017208 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017209 snd_hda_codec_write(codec, nid, 0,
17210 AC_VERB_SET_AMP_GAIN_MUTE,
17211 AMP_OUT_MUTE);
17212 }
17213 }
17214}
17215
Takashi Iwaif511b012008-08-15 16:46:42 +020017216#define alc662_auto_init_input_src alc882_auto_init_input_src
17217
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017218static int alc662_parse_auto_config(struct hda_codec *codec)
17219{
17220 struct alc_spec *spec = codec->spec;
17221 int err;
17222 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17223
17224 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17225 alc662_ignore);
17226 if (err < 0)
17227 return err;
17228 if (!spec->autocfg.line_outs)
17229 return 0; /* can't find valid BIOS pin config */
17230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017231 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17232 if (err < 0)
17233 return err;
17234 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17235 if (err < 0)
17236 return err;
17237 err = alc662_auto_create_extra_out(spec,
17238 spec->autocfg.speaker_pins[0],
17239 "Speaker");
17240 if (err < 0)
17241 return err;
17242 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17243 "Headphone");
17244 if (err < 0)
17245 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017246 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017247 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248 return err;
17249
17250 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17251
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017252 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017253 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17254
Takashi Iwai603c4012008-07-30 15:01:44 +020017255 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017256 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017257
17258 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017259 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017260
Takashi Iwaid88897e2008-10-31 15:01:37 +010017261 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017262 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017263 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017264
17265 err = alc_auto_add_mic_boost(codec);
17266 if (err < 0)
17267 return err;
17268
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017269 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17270
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017271 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017272}
17273
17274/* additional initialization for auto-configuration model */
17275static void alc662_auto_init(struct hda_codec *codec)
17276{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017277 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017278 alc662_auto_init_multi_out(codec);
17279 alc662_auto_init_hp_out(codec);
17280 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017281 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017282 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017283 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017284}
17285
17286static int patch_alc662(struct hda_codec *codec)
17287{
17288 struct alc_spec *spec;
17289 int err, board_config;
17290
17291 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17292 if (!spec)
17293 return -ENOMEM;
17294
17295 codec->spec = spec;
17296
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017297 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17298
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017299 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17300 alc662_models,
17301 alc662_cfg_tbl);
17302 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017303 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17304 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 board_config = ALC662_AUTO;
17306 }
17307
17308 if (board_config == ALC662_AUTO) {
17309 /* automatic parse from the BIOS config */
17310 err = alc662_parse_auto_config(codec);
17311 if (err < 0) {
17312 alc_free(codec);
17313 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017314 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017315 printk(KERN_INFO
17316 "hda_codec: Cannot set up configuration "
17317 "from BIOS. Using base mode...\n");
17318 board_config = ALC662_3ST_2ch_DIG;
17319 }
17320 }
17321
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017322 err = snd_hda_attach_beep_device(codec, 0x1);
17323 if (err < 0) {
17324 alc_free(codec);
17325 return err;
17326 }
17327
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017328 if (board_config != ALC662_AUTO)
17329 setup_preset(spec, &alc662_presets[board_config]);
17330
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017331 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17332 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17333
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17335 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17336
Takashi Iwaie1406342008-02-11 18:32:32 +010017337 spec->adc_nids = alc662_adc_nids;
17338 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17339 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017340
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017341 if (!spec->cap_mixer)
17342 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017343 if (codec->vendor_id == 0x10ec0662)
17344 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17345 else
17346 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017347
Takashi Iwai2134ea42008-01-10 16:53:55 +010017348 spec->vmaster_nid = 0x02;
17349
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 codec->patch_ops = alc_patch_ops;
17351 if (board_config == ALC662_AUTO)
17352 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017353#ifdef CONFIG_SND_HDA_POWER_SAVE
17354 if (!spec->loopback.amplist)
17355 spec->loopback.amplist = alc662_loopbacks;
17356#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017357 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017358
17359 return 0;
17360}
17361
17362/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017363 * patch entries
17364 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017365static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017366 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017367 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017368 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017369 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017370 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017371 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017372 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017374 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17375 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17376 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017377 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017378 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017379 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17380 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017381 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017382 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017383 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017384 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017385 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017386 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017387 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017388 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017389 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017390 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017391 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017392 .patch = patch_alc882 },
17393 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17394 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017395 {} /* terminator */
17396};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017397
17398MODULE_ALIAS("snd-hda-codec-id:10ec*");
17399
17400MODULE_LICENSE("GPL");
17401MODULE_DESCRIPTION("Realtek HD-audio codec");
17402
17403static struct hda_codec_preset_list realtek_list = {
17404 .preset = snd_hda_preset_realtek,
17405 .owner = THIS_MODULE,
17406};
17407
17408static int __init patch_realtek_init(void)
17409{
17410 return snd_hda_add_codec_preset(&realtek_list);
17411}
17412
17413static void __exit patch_realtek_exit(void)
17414{
17415 snd_hda_delete_codec_preset(&realtek_list);
17416}
17417
17418module_init(patch_realtek_init)
17419module_exit(patch_realtek_exit)