blob: 6794d028119d32696f2e999d5a5f8a7de6b56ed4 [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ünther3e1647c2009-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/*
6684 * 6ch mode
6685 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006686static struct hda_verb alc889_ch6_intel_init[] = {
6687 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6688 { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6689 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6691 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6692 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6693 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6697 { } /* end */
6698};
6699
6700/*
6701 * 8ch mode
6702 */
6703static struct hda_verb alc889_ch8_intel_init[] = {
6704 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6705 { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6706 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6708 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6709 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6710 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6714 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6715 { } /* end */
6716};
6717
6718static struct hda_channel_mode alc889_8ch_intel_modes[2] = {
6719 { 6, alc889_ch6_intel_init },
6720 { 8, alc889_ch8_intel_init },
6721};
6722
6723/*
6724 * 6ch mode
6725 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006726static struct hda_verb alc883_sixstack_ch6_init[] = {
6727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { } /* end */
6732};
6733
6734/*
6735 * 8ch mode
6736 */
6737static struct hda_verb alc883_sixstack_ch8_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { } /* end */
6743};
6744
6745static struct hda_channel_mode alc883_sixstack_modes[2] = {
6746 { 6, alc883_sixstack_ch6_init },
6747 { 8, alc883_sixstack_ch8_init },
6748};
6749
6750
Linus Torvalds1da177e2005-04-16 15:20:36 -07006751/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6752 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6753 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006754static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006757 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006758 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006759 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006761 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6762 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006763 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006764 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6773 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006774 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006775 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006776 { } /* end */
6777};
6778
Takashi Iwai87350ad2007-08-16 18:19:38 +02006779static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6781 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6782 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6783 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6785 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6787 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006788 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006789 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6790 { } /* end */
6791};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006792
6793static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6795 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6797 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6798 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6799 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6800 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6801 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6803 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6805 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6806 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6807 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6808 { } /* end */
6809};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006810
Kailang Yangbdd148a2007-05-08 15:19:08 +02006811static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6813 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006821 { } /* end */
6822};
6823
Kailang Yang272a5272007-05-14 11:00:38 +02006824static struct snd_kcontrol_new alc882_targa_mixer[] = {
6825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6828 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6829 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006837 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006838 { } /* end */
6839};
6840
6841/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6842 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6843 */
6844static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6846 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6848 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6849 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6850 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6853 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6854 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006857 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006858 { } /* end */
6859};
6860
Takashi Iwai914759b2007-09-06 14:52:04 +02006861static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6863 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006872 { } /* end */
6873};
6874
Kailang Yangdf694da2005-12-05 19:42:22 +01006875static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6876 {
6877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6878 .name = "Channel Mode",
6879 .info = alc_ch_mode_info,
6880 .get = alc_ch_mode_get,
6881 .put = alc_ch_mode_put,
6882 },
6883 { } /* end */
6884};
6885
Takashi Iwai4953550a2009-06-30 15:28:30 +02006886static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006887 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006891 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006895 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006899 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006903
Takashi Iwaicb638122009-07-03 10:56:10 +02006904 /* mute analog input loopbacks */
6905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006911 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006914 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006915 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006919 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006922 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006923 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006927 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6930 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6933 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6936 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006940 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006942
6943 /* FIXME: use matrix-type input source selection */
6944 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006945 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006950 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02006955 /* ADC2: mute amp left and right */
6956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006957 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006958 /* ADC3: mute amp left and right */
6959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006960 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006961
6962 { }
6963};
6964
Takashi Iwai4953550a2009-06-30 15:28:30 +02006965static struct hda_verb alc882_adc1_init_verbs[] = {
6966 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6971 /* ADC1: mute amp left and right */
6972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6973 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6974 { }
6975};
6976
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006977static struct hda_verb alc882_eapd_verbs[] = {
6978 /* change to EAPD mode */
6979 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006980 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006981 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006982};
6983
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006984static struct hda_verb alc889_eapd_verbs[] = {
6985 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
6986 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
6987 { }
6988};
6989
6990
6991static struct hda_verb alc885_init_verbs[] = {
6992 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6996 /* Rear mixer */
6997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7000 /* CLFE mixer */
7001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7004 /* Side mixer */
7005 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7006 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7008
7009 /* mute analog input loopbacks */
7010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7013
7014 /* Front HP Pin: output 0 (0x0c) */
7015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7018 /* Front Pin: output 0 (0x0c) */
7019 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7021 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7022 /* Rear Pin: output 1 (0x0d) */
7023 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7025 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7026 /* CLFE Pin: output 2 (0x0e) */
7027 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7028 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7029 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7030 /* Side Pin: output 3 (0x0f) */
7031 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7032 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7033 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7034 /* Mic (rear) pin: input vref at 80% */
7035 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7037 /* Front Mic pin: input vref at 80% */
7038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7040 /* Line In pin: input */
7041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7043
7044 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7045 /* Input mixer1 */
7046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7049 /* Input mixer2 */
7050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7053 /* Input mixer3 */
7054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7057 /* ADC2: mute amp left and right */
7058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7059 /* ADC3: mute amp left and right */
7060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7061
7062 { }
7063};
7064
7065static struct hda_verb alc885_init_input_verbs[] = {
7066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7069 { }
7070};
7071
7072
7073/* Unmute Selector 24h and set the default input to front mic */
7074static struct hda_verb alc889_init_input_verbs[] = {
7075 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7076 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7077 { }
7078};
7079
7080
Takashi Iwai4953550a2009-06-30 15:28:30 +02007081#define alc883_init_verbs alc882_base_init_verbs
7082
Tobin Davis9102cd12006-12-15 10:02:12 +01007083/* Mac Pro test */
7084static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7086 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007090 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007091 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7092 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007093 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007094 { } /* end */
7095};
7096
7097static struct hda_verb alc882_macpro_init_verbs[] = {
7098 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7102 /* Front Pin: output 0 (0x0c) */
7103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7106 /* Front Mic pin: input vref at 80% */
7107 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7109 /* Speaker: output */
7110 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7112 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7113 /* Headphone output (output 0 - 0x0c) */
7114 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7116 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7117
7118 /* FIXME: use matrix-type input source selection */
7119 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7120 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7125 /* Input mixer2 */
7126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7129 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7130 /* Input mixer3 */
7131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7135 /* ADC1: mute amp left and right */
7136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7138 /* ADC2: mute amp left and right */
7139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7140 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7141 /* ADC3: mute amp left and right */
7142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7143 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7144
7145 { }
7146};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007147
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007148/* Macbook 5,1 */
7149static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007150 /* DACs */
7151 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7152 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7153 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7154 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007155 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007159 /* Surround mixer */
7160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7163 /* LFE mixer */
7164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7167 /* HP mixer */
7168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7170 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7171 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007174 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7175 /* LFE Pin (0x0e) */
7176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7178 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7179 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007182 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007183 /* Front Mic pin: input vref at 80% */
7184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7186 /* Line In pin */
7187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7189
7190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7194 { }
7195};
7196
Takashi Iwai87350ad2007-08-16 18:19:38 +02007197/* Macbook Pro rev3 */
7198static struct hda_verb alc885_mbp3_init_verbs[] = {
7199 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7203 /* Rear mixer */
7204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7207 /* Front Pin: output 0 (0x0c) */
7208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7210 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7211 /* HP Pin: output 0 (0x0d) */
7212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7215 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7216 /* Mic (rear) pin: input vref at 80% */
7217 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7218 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7219 /* Front Mic pin: input vref at 80% */
7220 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7222 /* Line In pin: use output 1 when in LineOut mode */
7223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7225 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7226
7227 /* FIXME: use matrix-type input source selection */
7228 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7229 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7234 /* Input mixer2 */
7235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7238 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7239 /* Input mixer3 */
7240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7244 /* ADC1: mute amp left and right */
7245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7246 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7247 /* ADC2: mute amp left and right */
7248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7249 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7250 /* ADC3: mute amp left and right */
7251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7252 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7253
7254 { }
7255};
7256
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007257/* iMac 24 mixer. */
7258static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7259 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7260 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7261 { } /* end */
7262};
7263
7264/* iMac 24 init verbs. */
7265static struct hda_verb alc885_imac24_init_verbs[] = {
7266 /* Internal speakers: output 0 (0x0c) */
7267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7270 /* Internal speakers: output 0 (0x0c) */
7271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7273 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7274 /* Headphone: output 0 (0x0c) */
7275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7277 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7278 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7279 /* Front Mic: input vref at 80% */
7280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7282 { }
7283};
7284
7285/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007286static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007287{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007288 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007289
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007290 spec->autocfg.hp_pins[0] = 0x14;
7291 spec->autocfg.speaker_pins[0] = 0x18;
7292 spec->autocfg.speaker_pins[1] = 0x1a;
7293 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007294}
7295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007296static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007297{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007298 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007299
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007300 spec->autocfg.hp_pins[0] = 0x15;
7301 spec->autocfg.speaker_pins[0] = 0x14;
7302 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007303}
7304
7305
Kailang Yang272a5272007-05-14 11:00:38 +02007306static struct hda_verb alc882_targa_verbs[] = {
7307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7309
7310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007312
Kailang Yang272a5272007-05-14 11:00:38 +02007313 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7314 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7315 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7316
7317 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007318 { } /* end */
7319};
7320
7321/* toggle speaker-output according to the hp-jack state */
7322static void alc882_targa_automute(struct hda_codec *codec)
7323{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007324 struct alc_spec *spec = codec->spec;
7325 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007326 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007327 spec->jack_present ? 1 : 3);
7328}
7329
7330static void alc882_targa_init_hook(struct hda_codec *codec)
7331{
7332 struct alc_spec *spec = codec->spec;
7333
7334 spec->autocfg.hp_pins[0] = 0x14;
7335 spec->autocfg.speaker_pins[0] = 0x1b;
7336 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007337}
7338
7339static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7340{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007341 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007342 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007343}
7344
7345static struct hda_verb alc882_asus_a7j_verbs[] = {
7346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7348
7349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7351 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007352
Kailang Yang272a5272007-05-14 11:00:38 +02007353 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7355 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7356
7357 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7358 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7359 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7360 { } /* end */
7361};
7362
Takashi Iwai914759b2007-09-06 14:52:04 +02007363static struct hda_verb alc882_asus_a7m_verbs[] = {
7364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7366
7367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007370
Takashi Iwai914759b2007-09-06 14:52:04 +02007371 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7373 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7374
7375 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7376 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7377 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7378 { } /* end */
7379};
7380
Tobin Davis9102cd12006-12-15 10:02:12 +01007381static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7382{
7383 unsigned int gpiostate, gpiomask, gpiodir;
7384
7385 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7386 AC_VERB_GET_GPIO_DATA, 0);
7387
7388 if (!muted)
7389 gpiostate |= (1 << pin);
7390 else
7391 gpiostate &= ~(1 << pin);
7392
7393 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7394 AC_VERB_GET_GPIO_MASK, 0);
7395 gpiomask |= (1 << pin);
7396
7397 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7398 AC_VERB_GET_GPIO_DIRECTION, 0);
7399 gpiodir |= (1 << pin);
7400
7401
7402 snd_hda_codec_write(codec, codec->afg, 0,
7403 AC_VERB_SET_GPIO_MASK, gpiomask);
7404 snd_hda_codec_write(codec, codec->afg, 0,
7405 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7406
7407 msleep(1);
7408
7409 snd_hda_codec_write(codec, codec->afg, 0,
7410 AC_VERB_SET_GPIO_DATA, gpiostate);
7411}
7412
Takashi Iwai7debbe52007-08-16 15:01:03 +02007413/* set up GPIO at initialization */
7414static void alc885_macpro_init_hook(struct hda_codec *codec)
7415{
7416 alc882_gpio_mute(codec, 0, 0);
7417 alc882_gpio_mute(codec, 1, 0);
7418}
7419
7420/* set up GPIO and update auto-muting at initialization */
7421static void alc885_imac24_init_hook(struct hda_codec *codec)
7422{
7423 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007424 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007425}
7426
Kailang Yangdf694da2005-12-05 19:42:22 +01007427/*
7428 * generic initialization of ADC, input mixers and output mixers
7429 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007430static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007431 /*
7432 * Unmute ADC0-2 and set the default input to mic-in
7433 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007434 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7436 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7438
Takashi Iwaicb53c622007-08-10 17:21:45 +02007439 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007440 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007441 * Note: PASD motherboards uses the Line In 2 as the input for
7442 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007443 */
7444 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007450
7451 /*
7452 * Set up output mixers (0x0c - 0x0f)
7453 */
7454 /* set vol=0 to output mixers */
7455 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7459 /* set up input amps for analog loopback */
7460 /* Amp Indices: DAC = 0, mixer = 1 */
7461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7467 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7468 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7469 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7470 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7471
7472 /* FIXME: use matrix-type input source selection */
7473 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007474 /* Input mixer2 */
7475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7479 /* Input mixer3 */
7480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7484
7485 { }
7486};
7487
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007488/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7489static struct hda_verb alc889A_mb31_ch2_init[] = {
7490 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7494 { } /* end */
7495};
7496
7497/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7498static struct hda_verb alc889A_mb31_ch4_init[] = {
7499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7503 { } /* end */
7504};
7505
7506/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7507static struct hda_verb alc889A_mb31_ch5_init[] = {
7508 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7512 { } /* end */
7513};
7514
7515/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7516static struct hda_verb alc889A_mb31_ch6_init[] = {
7517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7519 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7520 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7521 { } /* end */
7522};
7523
7524static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7525 { 2, alc889A_mb31_ch2_init },
7526 { 4, alc889A_mb31_ch4_init },
7527 { 5, alc889A_mb31_ch5_init },
7528 { 6, alc889A_mb31_ch6_init },
7529};
7530
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007531static struct hda_verb alc883_medion_eapd_verbs[] = {
7532 /* eanable EAPD on medion laptop */
7533 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7534 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7535 { }
7536};
7537
Takashi Iwai4953550a2009-06-30 15:28:30 +02007538#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007539
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007540static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7541 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7542 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7543 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7544 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7545 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7546 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7549 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7552 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7553 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007554 { } /* end */
7555};
7556
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007557static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007558 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7559 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7561 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7565 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7566 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7567 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007568 { } /* end */
7569};
7570
Jiang zhefb97dc62008-03-06 11:07:11 +01007571static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7573 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7575 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7580 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7581 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007582 { } /* end */
7583};
7584
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007585static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7586 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007594 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007597 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007599 { } /* end */
7600};
7601
7602static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7603 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7604 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7606 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7607 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7608 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7609 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7610 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007617 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007620 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007621 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007622 { } /* end */
7623};
7624
Jiang zhe17bba1b2008-06-04 12:11:07 +02007625static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7629 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7630 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7631 HDA_OUTPUT),
7632 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7633 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7634 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7645 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007646 { } /* end */
7647};
7648
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007649static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7651 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7653 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7655 HDA_OUTPUT),
7656 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7657 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7658 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7659 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7660 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7662 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7663 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7664 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7670 { } /* end */
7671};
7672
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007673static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007677 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7690 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007692 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007693 { } /* end */
7694};
7695
Sasha Alexandrc2592492009-06-16 14:52:54 -04007696static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7699 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7700 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7701 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7702 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7703 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7704 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7705 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7709 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007711 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007713 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007714};
Kailang Yangccc656c2006-10-17 12:32:26 +02007715
Sasha Alexandrc2592492009-06-16 14:52:54 -04007716static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007717 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7719 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007723 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007725 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7726 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7727 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007728 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007729};
Kailang Yangccc656c2006-10-17 12:32:26 +02007730
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007731static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7732 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7733 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7735 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7738 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007740 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007741};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007742
Kailang Yang272a5272007-05-14 11:00:38 +02007743static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7744 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7745 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7747 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7748 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7751 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7752 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007753 { } /* end */
7754};
7755
7756static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7759 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007766 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007767};
Kailang Yang272a5272007-05-14 11:00:38 +02007768
Tobin Davis2880a862007-08-07 11:50:26 +02007769static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7771 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007778 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007779};
Tobin Davis2880a862007-08-07 11:50:26 +02007780
Tony Vroond2fd4b02009-06-21 00:40:10 +01007781static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7782 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7783 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7784 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7785 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7791 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7793 { } /* end */
7794};
7795
Kailang Yange2757d52008-08-26 13:17:46 +02007796static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7800 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7801 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7802 0x0d, 1, 0x0, HDA_OUTPUT),
7803 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7804 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7805 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7816 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007818 { } /* end */
7819};
7820
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007821static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7822 /* Output mixers */
7823 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7826 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7828 HDA_OUTPUT),
7829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7832 /* Output switches */
7833 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7834 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7835 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7836 /* Boost mixers */
7837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7838 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7839 /* Input mixers */
7840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7844 { } /* end */
7845};
7846
Guido Günther3e1647c2009-06-05 00:47:26 +02007847static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
7848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7854 { } /* end */
7855};
7856
Kailang Yange2757d52008-08-26 13:17:46 +02007857static struct hda_bind_ctls alc883_bind_cap_vol = {
7858 .ops = &snd_hda_bind_vol,
7859 .values = {
7860 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7861 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7862 0
7863 },
7864};
7865
7866static struct hda_bind_ctls alc883_bind_cap_switch = {
7867 .ops = &snd_hda_bind_sw,
7868 .values = {
7869 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7870 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7871 0
7872 },
7873};
7874
7875static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007884 { } /* end */
7885};
7886
7887static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007888 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7889 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7890 {
7891 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7892 /* .name = "Capture Source", */
7893 .name = "Input Source",
7894 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007895 .info = alc_mux_enum_info,
7896 .get = alc_mux_enum_get,
7897 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007898 },
7899 { } /* end */
7900};
7901
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007902static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7903 {
7904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7905 .name = "Channel Mode",
7906 .info = alc_ch_mode_info,
7907 .get = alc_ch_mode_get,
7908 .put = alc_ch_mode_put,
7909 },
7910 { } /* end */
7911};
7912
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007913/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007914static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007915{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007916 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007917
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007918 spec->autocfg.hp_pins[0] = 0x15;
7919 spec->autocfg.speaker_pins[0] = 0x14;
7920 spec->autocfg.speaker_pins[1] = 0x17;
7921 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007922}
7923
7924/* auto-toggle front mic */
7925/*
7926static void alc883_mitac_mic_automute(struct hda_codec *codec)
7927{
7928 unsigned int present;
7929 unsigned char bits;
7930
7931 present = snd_hda_codec_read(codec, 0x18, 0,
7932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7933 bits = present ? HDA_AMP_MUTE : 0;
7934 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7935}
7936*/
7937
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007938static struct hda_verb alc883_mitac_verbs[] = {
7939 /* HP */
7940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7942 /* Subwoofer */
7943 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7944 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7945
7946 /* enable unsolicited event */
7947 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7948 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7949
7950 { } /* end */
7951};
7952
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007953static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007954 /* HP */
7955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7957 /* Int speaker */
7958 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7960
7961 /* enable unsolicited event */
7962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007963 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007964
7965 { } /* end */
7966};
7967
Jiang zhefb97dc62008-03-06 11:07:11 +01007968static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7969 /* HP */
7970 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7972 /* Subwoofer */
7973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7975
7976 /* enable unsolicited event */
7977 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7978
7979 { } /* end */
7980};
7981
Sasha Alexandrc2592492009-06-16 14:52:54 -04007982static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7985
7986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007988
David Heidelberger64a8be72009-06-08 16:15:18 +02007989/* Connect Line-Out side jack (SPDIF) to Side */
7990 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7991 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7992 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7993/* Connect Mic jack to CLFE */
7994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7996 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
7997/* Connect Line-in jack to Surround */
7998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7999 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8000 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8001/* Connect HP out jack to Front */
8002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8004 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008005
8006 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008007
8008 { } /* end */
8009};
8010
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008011static struct hda_verb alc883_lenovo_101e_verbs[] = {
8012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8013 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8014 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8015 { } /* end */
8016};
8017
Kailang Yang272a5272007-05-14 11:00:38 +02008018static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8019 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8021 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8023 { } /* end */
8024};
8025
8026static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8031 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8032 { } /* end */
8033};
8034
Kailang Yang189609a2007-08-20 11:31:23 +02008035static struct hda_verb alc883_haier_w66_verbs[] = {
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8038
8039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8040
8041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8042 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8043 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8045 { } /* end */
8046};
8047
Kailang Yange2757d52008-08-26 13:17:46 +02008048static struct hda_verb alc888_lenovo_sky_verbs[] = {
8049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8055 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8056 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8057 { } /* end */
8058};
8059
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008060static struct hda_verb alc888_6st_dell_verbs[] = {
8061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8062 { }
8063};
8064
Guido Günther3e1647c2009-06-05 00:47:26 +02008065static struct hda_verb alc883_vaiott_verbs[] = {
8066 /* HP */
8067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8069
8070 /* enable unsolicited event */
8071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8072
8073 { } /* end */
8074};
8075
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008076static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008077{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008078 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008079
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008080 spec->autocfg.hp_pins[0] = 0x1b;
8081 spec->autocfg.speaker_pins[0] = 0x14;
8082 spec->autocfg.speaker_pins[1] = 0x16;
8083 spec->autocfg.speaker_pins[2] = 0x18;
8084 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008085}
8086
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008087static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008088 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008089 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8090 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008091 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008092 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008093};
8094
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008095/*
8096 * 2ch mode
8097 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008098static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008099 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8100 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8101 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8102 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008103 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008104};
8105
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008106/*
8107 * 4ch mode
8108 */
8109static struct hda_verb alc888_3st_hp_4ch_init[] = {
8110 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8111 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8112 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8113 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8114 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8115 { } /* end */
8116};
8117
8118/*
8119 * 6ch mode
8120 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008121static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008122 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8123 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008124 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008125 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8126 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008127 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8128 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008129};
8130
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008131static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008132 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008133 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008134 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008135};
8136
Kailang Yang272a5272007-05-14 11:00:38 +02008137/* toggle front-jack and RCA according to the hp-jack state */
8138static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8139{
8140 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008141
Kailang Yang272a5272007-05-14 11:00:38 +02008142 present = snd_hda_codec_read(codec, 0x1b, 0,
8143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008144 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8145 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8146 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8147 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008148}
8149
8150/* toggle RCA according to the front-jack state */
8151static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8152{
8153 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008154
Kailang Yang272a5272007-05-14 11:00:38 +02008155 present = snd_hda_codec_read(codec, 0x14, 0,
8156 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008157 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8158 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008159}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008160
Kailang Yang272a5272007-05-14 11:00:38 +02008161static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8162 unsigned int res)
8163{
8164 if ((res >> 26) == ALC880_HP_EVENT)
8165 alc888_lenovo_ms7195_front_automute(codec);
8166 if ((res >> 26) == ALC880_FRONT_EVENT)
8167 alc888_lenovo_ms7195_rca_automute(codec);
8168}
8169
8170static struct hda_verb alc883_medion_md2_verbs[] = {
8171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8173
8174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8175
8176 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8177 { } /* end */
8178};
8179
8180/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008181static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008182{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008183 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008184
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008185 spec->autocfg.hp_pins[0] = 0x14;
8186 spec->autocfg.speaker_pins[0] = 0x15;
8187 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008188}
8189
Kailang Yangccc656c2006-10-17 12:32:26 +02008190/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008191#define alc883_targa_init_hook alc882_targa_init_hook
8192#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008193
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008194static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8195{
8196 unsigned int present;
8197
8198 present = snd_hda_codec_read(codec, 0x18, 0,
8199 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8200 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8201 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8202}
8203
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008204static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008205{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008206 struct alc_spec *spec = codec->spec;
8207
8208 spec->autocfg.hp_pins[0] = 0x15;
8209 spec->autocfg.speaker_pins[0] = 0x14;
8210 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008211 alc883_clevo_m720_mic_automute(codec);
8212}
8213
8214static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008215 unsigned int res)
8216{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008217 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008218 case ALC880_MIC_EVENT:
8219 alc883_clevo_m720_mic_automute(codec);
8220 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008221 default:
8222 alc_automute_amp_unsol_event(codec, res);
8223 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008224 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008225}
8226
Jiang zhefb97dc62008-03-06 11:07:11 +01008227/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008228static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008229{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008230 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008231
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008232 spec->autocfg.hp_pins[0] = 0x14;
8233 spec->autocfg.speaker_pins[0] = 0x15;
8234 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008235}
8236
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008237static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008238{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008239 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008240
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008241 spec->autocfg.hp_pins[0] = 0x1b;
8242 spec->autocfg.speaker_pins[0] = 0x14;
8243 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008244}
8245
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008246static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8247{
8248 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008249 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008250
David Heidelberger64a8be72009-06-08 16:15:18 +02008251 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8252 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008253 bits = present ? HDA_AMP_MUTE : 0;
8254 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8255 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008256}
8257
8258static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8259{
8260 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008261 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008262
8263 present = snd_hda_codec_read(codec, 0x1b, 0,
8264 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008265 bits = present ? HDA_AMP_MUTE : 0;
8266 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8267 HDA_AMP_MUTE, bits);
8268 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8269 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008270}
8271
8272static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8273 unsigned int res)
8274{
8275 if ((res >> 26) == ALC880_HP_EVENT)
8276 alc883_lenovo_101e_all_automute(codec);
8277 if ((res >> 26) == ALC880_FRONT_EVENT)
8278 alc883_lenovo_101e_ispeaker_automute(codec);
8279}
8280
Takashi Iwai676a9b52007-08-16 15:23:35 +02008281/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008282static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008283{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008284 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008285
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008286 spec->autocfg.hp_pins[0] = 0x14;
8287 spec->autocfg.speaker_pins[0] = 0x15;
8288 spec->autocfg.speaker_pins[1] = 0x16;
8289 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008290}
8291
Kailang Yangd1a991a2007-08-15 16:21:59 +02008292static struct hda_verb alc883_acer_eapd_verbs[] = {
8293 /* HP Pin: output 0 (0x0c) */
8294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8296 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8297 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008300 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008301 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8302 /* eanable EAPD on medion laptop */
8303 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8304 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008305 /* enable unsolicited event */
8306 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008307 { }
8308};
8309
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008310static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008312 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008313
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008314 spec->autocfg.hp_pins[0] = 0x1b;
8315 spec->autocfg.speaker_pins[0] = 0x14;
8316 spec->autocfg.speaker_pins[1] = 0x15;
8317 spec->autocfg.speaker_pins[2] = 0x16;
8318 spec->autocfg.speaker_pins[3] = 0x17;
8319 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008320}
8321
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008322static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008323{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008324 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008325
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008326 spec->autocfg.hp_pins[0] = 0x1b;
8327 spec->autocfg.speaker_pins[0] = 0x14;
8328 spec->autocfg.speaker_pins[1] = 0x15;
8329 spec->autocfg.speaker_pins[2] = 0x16;
8330 spec->autocfg.speaker_pins[3] = 0x17;
8331 spec->autocfg.speaker_pins[4] = 0x1a;
8332 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008333}
8334
Guido Günther3e1647c2009-06-05 00:47:26 +02008335static void alc883_vaiott_init_hook(struct hda_codec *codec)
8336{
8337 struct alc_spec *spec = codec->spec;
8338
8339 spec->autocfg.hp_pins[0] = 0x15;
8340 spec->autocfg.speaker_pins[0] = 0x14;
8341 spec->autocfg.speaker_pins[1] = 0x17;
8342 alc_automute_amp(codec);
8343}
8344
Kailang Yange2757d52008-08-26 13:17:46 +02008345static struct hda_verb alc888_asus_m90v_verbs[] = {
8346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8349 /* enable unsolicited event */
8350 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8351 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8352 { } /* end */
8353};
8354
8355static void alc883_nb_mic_automute(struct hda_codec *codec)
8356{
8357 unsigned int present;
8358
8359 present = snd_hda_codec_read(codec, 0x18, 0,
8360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8361 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8362 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8363 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8364 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8365}
8366
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008367static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008369 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008370
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008371 spec->autocfg.hp_pins[0] = 0x1b;
8372 spec->autocfg.speaker_pins[0] = 0x14;
8373 spec->autocfg.speaker_pins[1] = 0x15;
8374 spec->autocfg.speaker_pins[2] = 0x16;
8375 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008376}
8377
8378static void alc883_mode2_unsol_event(struct hda_codec *codec,
8379 unsigned int res)
8380{
8381 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008382 case ALC880_MIC_EVENT:
8383 alc883_nb_mic_automute(codec);
8384 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008385 default:
8386 alc_sku_unsol_event(codec, res);
8387 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008388 }
8389}
8390
8391static void alc883_mode2_inithook(struct hda_codec *codec)
8392{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008393 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008394 alc883_nb_mic_automute(codec);
8395}
8396
8397static struct hda_verb alc888_asus_eee1601_verbs[] = {
8398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8399 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8403 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8404 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8405 /* enable unsolicited event */
8406 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8407 { } /* end */
8408};
8409
Kailang Yange2757d52008-08-26 13:17:46 +02008410static void alc883_eee1601_inithook(struct hda_codec *codec)
8411{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008412 struct alc_spec *spec = codec->spec;
8413
8414 spec->autocfg.hp_pins[0] = 0x14;
8415 spec->autocfg.speaker_pins[0] = 0x1b;
8416 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008417}
8418
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008419static struct hda_verb alc889A_mb31_verbs[] = {
8420 /* Init rear pin (used as headphone output) */
8421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8423 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8424 /* Init line pin (used as output in 4ch and 6ch mode) */
8425 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8426 /* Init line 2 pin (used as headphone out by default) */
8427 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8428 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8429 { } /* end */
8430};
8431
8432/* Mute speakers according to the headphone jack state */
8433static void alc889A_mb31_automute(struct hda_codec *codec)
8434{
8435 unsigned int present;
8436
8437 /* Mute only in 2ch or 4ch mode */
8438 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8439 == 0x00) {
8440 present = snd_hda_codec_read(codec, 0x15, 0,
8441 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8442 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8443 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8444 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8445 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8446 }
8447}
8448
8449static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8450{
8451 if ((res >> 26) == ALC880_HP_EVENT)
8452 alc889A_mb31_automute(codec);
8453}
8454
Takashi Iwai4953550a2009-06-30 15:28:30 +02008455
Takashi Iwaicb53c622007-08-10 17:21:45 +02008456#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008457#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008458#endif
8459
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008460/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008461#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8462#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8463#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8464#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8465
8466static hda_nid_t alc883_slave_dig_outs[] = {
8467 ALC1200_DIGOUT_NID, 0,
8468};
8469
8470static hda_nid_t alc1200_slave_dig_outs[] = {
8471 ALC883_DIGOUT_NID, 0,
8472};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008473
8474/*
8475 * configuration and preset
8476 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008477static const char *alc882_models[ALC882_MODEL_LAST] = {
8478 [ALC882_3ST_DIG] = "3stack-dig",
8479 [ALC882_6ST_DIG] = "6stack-dig",
8480 [ALC882_ARIMA] = "arima",
8481 [ALC882_W2JC] = "w2jc",
8482 [ALC882_TARGA] = "targa",
8483 [ALC882_ASUS_A7J] = "asus-a7j",
8484 [ALC882_ASUS_A7M] = "asus-a7m",
8485 [ALC885_MACPRO] = "macpro",
8486 [ALC885_MB5] = "mb5",
8487 [ALC885_MBP3] = "mbp3",
8488 [ALC885_IMAC24] = "imac24",
8489 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008490 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8491 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008492 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008493 [ALC883_TARGA_DIG] = "targa-dig",
8494 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008495 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008496 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008497 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008498 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008499 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008500 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008501 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008502 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008503 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008504 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008505 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8506 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008507 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008508 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008509 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008510 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008511 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008512 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008513 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008514 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008515 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008516 [ALC889A_INTEL] = "intel-alc889a",
8517 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008518 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008519 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008520 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008521 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008522};
8523
Takashi Iwai4953550a2009-06-30 15:28:30 +02008524static struct snd_pci_quirk alc882_cfg_tbl[] = {
8525 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8526
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008527 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008528 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008529 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008530 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8531 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008532 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008533 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8534 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008535 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8536 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008537 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8538 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008539 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8540 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008541 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8542 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008543 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008544 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008545 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008546 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008547 /* default Acer -- disabled as it causes more problems.
8548 * model=auto should work fine now
8549 */
8550 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008551
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008552 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008553
Tobin Davisfebe3372007-06-12 11:27:46 +02008554 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008555 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8556 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008557 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008558 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008559 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008560
8561 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8562 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8563 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008564 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008565 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8566 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8567 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008568 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008569 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008570 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008571 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008572
8573 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008574 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008575 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008576 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008577 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8578 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008579 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008580 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008581 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8582
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008583 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8584 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8585 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008586 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008587 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008588 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008589 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008590 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008591 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8592 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8593 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8594 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8595 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8596 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008597 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008598 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8599 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8600 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008601 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008602 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8603 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008604 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008605 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008606 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008607 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008608 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008609 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008610 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008611 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008612
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008613 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008614 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8615 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008616 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008617 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008618 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008619 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008620 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008621 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008622 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008623 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008624 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008625 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008626 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8627 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008628 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008629 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008630 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008631 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008632 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008633
Jiang zhe17bba1b2008-06-04 12:11:07 +02008634 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8635 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008636 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008637 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8638 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8639 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008640 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008641
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008642 {}
8643};
8644
Takashi Iwai4953550a2009-06-30 15:28:30 +02008645/* codec SSID table for Intel Mac */
8646static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8647 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8648 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8649 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8650 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8651 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8652 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8653 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8654 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8655 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8656 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8657 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8658 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8659 * no perfect solution yet
8660 */
8661 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8662 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008663};
8664
Takashi Iwai4953550a2009-06-30 15:28:30 +02008665static struct alc_config_preset alc882_presets[] = {
8666 [ALC882_3ST_DIG] = {
8667 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008668 .init_verbs = { alc882_base_init_verbs,
8669 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008670 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8671 .dac_nids = alc882_dac_nids,
8672 .dig_out_nid = ALC882_DIGOUT_NID,
8673 .dig_in_nid = ALC882_DIGIN_NID,
8674 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8675 .channel_mode = alc882_ch_modes,
8676 .need_dac_fix = 1,
8677 .input_mux = &alc882_capture_source,
8678 },
8679 [ALC882_6ST_DIG] = {
8680 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008681 .init_verbs = { alc882_base_init_verbs,
8682 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008683 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8684 .dac_nids = alc882_dac_nids,
8685 .dig_out_nid = ALC882_DIGOUT_NID,
8686 .dig_in_nid = ALC882_DIGIN_NID,
8687 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8688 .channel_mode = alc882_sixstack_modes,
8689 .input_mux = &alc882_capture_source,
8690 },
8691 [ALC882_ARIMA] = {
8692 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008693 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8694 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008695 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8696 .dac_nids = alc882_dac_nids,
8697 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8698 .channel_mode = alc882_sixstack_modes,
8699 .input_mux = &alc882_capture_source,
8700 },
8701 [ALC882_W2JC] = {
8702 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008703 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8704 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008705 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8706 .dac_nids = alc882_dac_nids,
8707 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8708 .channel_mode = alc880_threestack_modes,
8709 .need_dac_fix = 1,
8710 .input_mux = &alc882_capture_source,
8711 .dig_out_nid = ALC882_DIGOUT_NID,
8712 },
8713 [ALC885_MBP3] = {
8714 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8715 .init_verbs = { alc885_mbp3_init_verbs,
8716 alc880_gpio1_init_verbs },
8717 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8718 .dac_nids = alc882_dac_nids,
8719 .channel_mode = alc885_mbp_6ch_modes,
8720 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8721 .input_mux = &alc882_capture_source,
8722 .dig_out_nid = ALC882_DIGOUT_NID,
8723 .dig_in_nid = ALC882_DIGIN_NID,
8724 .unsol_event = alc_automute_amp_unsol_event,
8725 .init_hook = alc885_mbp3_init_hook,
8726 },
8727 [ALC885_MB5] = {
8728 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8729 .init_verbs = { alc885_mb5_init_verbs,
8730 alc880_gpio1_init_verbs },
8731 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8732 .dac_nids = alc882_dac_nids,
8733 .channel_mode = alc885_mb5_6ch_modes,
8734 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8735 .input_mux = &mb5_capture_source,
8736 .dig_out_nid = ALC882_DIGOUT_NID,
8737 .dig_in_nid = ALC882_DIGIN_NID,
8738 },
8739 [ALC885_MACPRO] = {
8740 .mixers = { alc882_macpro_mixer },
8741 .init_verbs = { alc882_macpro_init_verbs },
8742 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8743 .dac_nids = alc882_dac_nids,
8744 .dig_out_nid = ALC882_DIGOUT_NID,
8745 .dig_in_nid = ALC882_DIGIN_NID,
8746 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8747 .channel_mode = alc882_ch_modes,
8748 .input_mux = &alc882_capture_source,
8749 .init_hook = alc885_macpro_init_hook,
8750 },
8751 [ALC885_IMAC24] = {
8752 .mixers = { alc885_imac24_mixer },
8753 .init_verbs = { alc885_imac24_init_verbs },
8754 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8755 .dac_nids = alc882_dac_nids,
8756 .dig_out_nid = ALC882_DIGOUT_NID,
8757 .dig_in_nid = ALC882_DIGIN_NID,
8758 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8759 .channel_mode = alc882_ch_modes,
8760 .input_mux = &alc882_capture_source,
8761 .unsol_event = alc_automute_amp_unsol_event,
8762 .init_hook = alc885_imac24_init_hook,
8763 },
8764 [ALC882_TARGA] = {
8765 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008766 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008767 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008768 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8769 .dac_nids = alc882_dac_nids,
8770 .dig_out_nid = ALC882_DIGOUT_NID,
8771 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8772 .adc_nids = alc882_adc_nids,
8773 .capsrc_nids = alc882_capsrc_nids,
8774 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8775 .channel_mode = alc882_3ST_6ch_modes,
8776 .need_dac_fix = 1,
8777 .input_mux = &alc882_capture_source,
8778 .unsol_event = alc882_targa_unsol_event,
8779 .init_hook = alc882_targa_init_hook,
8780 },
8781 [ALC882_ASUS_A7J] = {
8782 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008783 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8784 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008785 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8786 .dac_nids = alc882_dac_nids,
8787 .dig_out_nid = ALC882_DIGOUT_NID,
8788 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8789 .adc_nids = alc882_adc_nids,
8790 .capsrc_nids = alc882_capsrc_nids,
8791 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8792 .channel_mode = alc882_3ST_6ch_modes,
8793 .need_dac_fix = 1,
8794 .input_mux = &alc882_capture_source,
8795 },
8796 [ALC882_ASUS_A7M] = {
8797 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008798 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8799 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008800 alc882_asus_a7m_verbs },
8801 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8802 .dac_nids = alc882_dac_nids,
8803 .dig_out_nid = ALC882_DIGOUT_NID,
8804 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8805 .channel_mode = alc880_threestack_modes,
8806 .need_dac_fix = 1,
8807 .input_mux = &alc882_capture_source,
8808 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008809 [ALC883_3ST_2ch_DIG] = {
8810 .mixers = { alc883_3ST_2ch_mixer },
8811 .init_verbs = { alc883_init_verbs },
8812 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8813 .dac_nids = alc883_dac_nids,
8814 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008815 .dig_in_nid = ALC883_DIGIN_NID,
8816 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8817 .channel_mode = alc883_3ST_2ch_modes,
8818 .input_mux = &alc883_capture_source,
8819 },
8820 [ALC883_3ST_6ch_DIG] = {
8821 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8822 .init_verbs = { alc883_init_verbs },
8823 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8824 .dac_nids = alc883_dac_nids,
8825 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008826 .dig_in_nid = ALC883_DIGIN_NID,
8827 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8828 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008829 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008830 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008831 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008832 [ALC883_3ST_6ch] = {
8833 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8834 .init_verbs = { alc883_init_verbs },
8835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8836 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008837 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8838 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008839 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008840 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008841 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008842 [ALC883_3ST_6ch_INTEL] = {
8843 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8844 .init_verbs = { alc883_init_verbs },
8845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8846 .dac_nids = alc883_dac_nids,
8847 .dig_out_nid = ALC883_DIGOUT_NID,
8848 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008849 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008850 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8851 .channel_mode = alc883_3ST_6ch_intel_modes,
8852 .need_dac_fix = 1,
8853 .input_mux = &alc883_3stack_6ch_intel,
8854 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008855 [ALC889A_INTEL] = {
8856 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
8857 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs },
8858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8859 .dac_nids = alc883_dac_nids,
8860 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8861 .adc_nids = alc889_adc_nids,
8862 .dig_out_nid = ALC883_DIGOUT_NID,
8863 .dig_in_nid = ALC883_DIGIN_NID,
8864 .slave_dig_outs = alc883_slave_dig_outs,
8865 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
8866 .channel_mode = alc889_8ch_intel_modes,
8867 .capsrc_nids = alc889_capsrc_nids,
8868 .input_mux = &alc889_capture_source,
8869 .need_dac_fix = 1,
8870 },
8871 [ALC889_INTEL] = {
8872 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
8873 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
8874 alc889_eapd_verbs },
8875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8876 .dac_nids = alc883_dac_nids,
8877 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8878 .adc_nids = alc889_adc_nids,
8879 .dig_out_nid = ALC883_DIGOUT_NID,
8880 .dig_in_nid = ALC883_DIGIN_NID,
8881 .slave_dig_outs = alc883_slave_dig_outs,
8882 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
8883 .channel_mode = alc889_8ch_intel_modes,
8884 .capsrc_nids = alc889_capsrc_nids,
8885 .input_mux = &alc889_capture_source,
8886 .init_hook = alc889_coef_init,
8887 .need_dac_fix = 1,
8888 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008889 [ALC883_6ST_DIG] = {
8890 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8891 .init_verbs = { alc883_init_verbs },
8892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8893 .dac_nids = alc883_dac_nids,
8894 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008895 .dig_in_nid = ALC883_DIGIN_NID,
8896 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8897 .channel_mode = alc883_sixstack_modes,
8898 .input_mux = &alc883_capture_source,
8899 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008900 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008901 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02008902 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8903 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008904 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8905 .dac_nids = alc883_dac_nids,
8906 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008907 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8908 .channel_mode = alc883_3ST_6ch_modes,
8909 .need_dac_fix = 1,
8910 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008911 .unsol_event = alc883_targa_unsol_event,
8912 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008913 },
8914 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04008915 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02008916 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8917 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02008918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8919 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008920 .adc_nids = alc883_adc_nids_alt,
8921 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008922 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008923 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8924 .channel_mode = alc883_3ST_2ch_modes,
8925 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008926 .unsol_event = alc883_targa_unsol_event,
8927 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008928 },
David Heidelberger64a8be72009-06-08 16:15:18 +02008929 [ALC883_TARGA_8ch_DIG] = {
8930 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8931 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008932 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02008933 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8934 .dac_nids = alc883_dac_nids,
8935 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8936 .adc_nids = alc883_adc_nids_rev,
8937 .capsrc_nids = alc883_capsrc_nids_rev,
8938 .dig_out_nid = ALC883_DIGOUT_NID,
8939 .dig_in_nid = ALC883_DIGIN_NID,
8940 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
8941 .channel_mode = alc883_4ST_8ch_modes,
8942 .need_dac_fix = 1,
8943 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04008944 .unsol_event = alc883_targa_unsol_event,
8945 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02008946 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008947 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008948 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008949 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8950 * and the headphone jack. Turn this on and rely on the
8951 * standard mute methods whenever the user wants to turn
8952 * these outputs off.
8953 */
8954 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8955 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8956 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008957 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8958 .channel_mode = alc883_3ST_2ch_modes,
8959 .input_mux = &alc883_capture_source,
8960 },
Tobin Davis2880a862007-08-07 11:50:26 +02008961 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008962 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008963 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8965 .dac_nids = alc883_dac_nids,
8966 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008967 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8968 .channel_mode = alc883_3ST_2ch_modes,
8969 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008970 .unsol_event = alc_automute_amp_unsol_event,
8971 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008972 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008973 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008974 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008975 alc883_chmode_mixer },
8976 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8977 alc888_acer_aspire_4930g_verbs },
8978 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8979 .dac_nids = alc883_dac_nids,
8980 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8981 .adc_nids = alc883_adc_nids_rev,
8982 .capsrc_nids = alc883_capsrc_nids_rev,
8983 .dig_out_nid = ALC883_DIGOUT_NID,
8984 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8985 .channel_mode = alc883_3ST_6ch_modes,
8986 .need_dac_fix = 1,
8987 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008988 ARRAY_SIZE(alc888_2_capture_sources),
8989 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008990 .unsol_event = alc_automute_amp_unsol_event,
8991 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008992 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01008993 [ALC888_ACER_ASPIRE_6530G] = {
8994 .mixers = { alc888_acer_aspire_6530_mixer },
8995 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8996 alc888_acer_aspire_6530g_verbs },
8997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8998 .dac_nids = alc883_dac_nids,
8999 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9000 .adc_nids = alc883_adc_nids_rev,
9001 .capsrc_nids = alc883_capsrc_nids_rev,
9002 .dig_out_nid = ALC883_DIGOUT_NID,
9003 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9004 .channel_mode = alc883_3ST_2ch_modes,
9005 .num_mux_defs =
9006 ARRAY_SIZE(alc888_2_capture_sources),
9007 .input_mux = alc888_acer_aspire_6530_sources,
9008 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009009 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009010 },
Hector Martin3b315d72009-06-02 10:54:19 +02009011 [ALC888_ACER_ASPIRE_8930G] = {
9012 .mixers = { alc888_base_mixer,
9013 alc883_chmode_mixer },
9014 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009015 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009016 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9017 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009018 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9019 .adc_nids = alc889_adc_nids,
9020 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009021 .dig_out_nid = ALC883_DIGOUT_NID,
9022 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9023 .channel_mode = alc883_3ST_6ch_modes,
9024 .need_dac_fix = 1,
9025 .const_channel_count = 6,
9026 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009027 ARRAY_SIZE(alc889_capture_sources),
9028 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009029 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009030 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009031 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009032 [ALC883_MEDION] = {
9033 .mixers = { alc883_fivestack_mixer,
9034 alc883_chmode_mixer },
9035 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009036 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009037 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9038 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009039 .adc_nids = alc883_adc_nids_alt,
9040 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009041 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9042 .channel_mode = alc883_sixstack_modes,
9043 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009044 },
Kailang Yang272a5272007-05-14 11:00:38 +02009045 [ALC883_MEDION_MD2] = {
9046 .mixers = { alc883_medion_md2_mixer},
9047 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9049 .dac_nids = alc883_dac_nids,
9050 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009051 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9052 .channel_mode = alc883_3ST_2ch_modes,
9053 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009054 .unsol_event = alc_automute_amp_unsol_event,
9055 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009056 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009057 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009058 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009059 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9061 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009062 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9063 .channel_mode = alc883_3ST_2ch_modes,
9064 .input_mux = &alc883_capture_source,
9065 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009066 [ALC883_CLEVO_M720] = {
9067 .mixers = { alc883_clevo_m720_mixer },
9068 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9070 .dac_nids = alc883_dac_nids,
9071 .dig_out_nid = ALC883_DIGOUT_NID,
9072 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9073 .channel_mode = alc883_3ST_2ch_modes,
9074 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009075 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009076 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009077 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009078 [ALC883_LENOVO_101E_2ch] = {
9079 .mixers = { alc883_lenovo_101e_2ch_mixer},
9080 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9081 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9082 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009083 .adc_nids = alc883_adc_nids_alt,
9084 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009085 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9086 .channel_mode = alc883_3ST_2ch_modes,
9087 .input_mux = &alc883_lenovo_101e_capture_source,
9088 .unsol_event = alc883_lenovo_101e_unsol_event,
9089 .init_hook = alc883_lenovo_101e_all_automute,
9090 },
Kailang Yang272a5272007-05-14 11:00:38 +02009091 [ALC883_LENOVO_NB0763] = {
9092 .mixers = { alc883_lenovo_nb0763_mixer },
9093 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9095 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9097 .channel_mode = alc883_3ST_2ch_modes,
9098 .need_dac_fix = 1,
9099 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009100 .unsol_event = alc_automute_amp_unsol_event,
9101 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009102 },
9103 [ALC888_LENOVO_MS7195_DIG] = {
9104 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9105 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9107 .dac_nids = alc883_dac_nids,
9108 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009109 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9110 .channel_mode = alc883_3ST_6ch_modes,
9111 .need_dac_fix = 1,
9112 .input_mux = &alc883_capture_source,
9113 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9114 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009115 },
9116 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009117 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009118 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9120 .dac_nids = alc883_dac_nids,
9121 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009122 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9123 .channel_mode = alc883_3ST_2ch_modes,
9124 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009125 .unsol_event = alc_automute_amp_unsol_event,
9126 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009127 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009128 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009129 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009130 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009131 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9132 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009133 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9134 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009135 .need_dac_fix = 1,
9136 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009137 .unsol_event = alc_automute_amp_unsol_event,
9138 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009139 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009140 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009141 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009142 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9143 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9144 .dac_nids = alc883_dac_nids,
9145 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009146 .dig_in_nid = ALC883_DIGIN_NID,
9147 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9148 .channel_mode = alc883_sixstack_modes,
9149 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009150 .unsol_event = alc_automute_amp_unsol_event,
9151 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009152 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009153 [ALC883_MITAC] = {
9154 .mixers = { alc883_mitac_mixer },
9155 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9156 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9157 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009158 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9159 .channel_mode = alc883_3ST_2ch_modes,
9160 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009161 .unsol_event = alc_automute_amp_unsol_event,
9162 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009163 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009164 [ALC883_FUJITSU_PI2515] = {
9165 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9166 .init_verbs = { alc883_init_verbs,
9167 alc883_2ch_fujitsu_pi2515_verbs},
9168 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9169 .dac_nids = alc883_dac_nids,
9170 .dig_out_nid = ALC883_DIGOUT_NID,
9171 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9172 .channel_mode = alc883_3ST_2ch_modes,
9173 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009174 .unsol_event = alc_automute_amp_unsol_event,
9175 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009176 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009177 [ALC888_FUJITSU_XA3530] = {
9178 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9179 .init_verbs = { alc883_init_verbs,
9180 alc888_fujitsu_xa3530_verbs },
9181 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9182 .dac_nids = alc883_dac_nids,
9183 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9184 .adc_nids = alc883_adc_nids_rev,
9185 .capsrc_nids = alc883_capsrc_nids_rev,
9186 .dig_out_nid = ALC883_DIGOUT_NID,
9187 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9188 .channel_mode = alc888_4ST_8ch_intel_modes,
9189 .num_mux_defs =
9190 ARRAY_SIZE(alc888_2_capture_sources),
9191 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009192 .unsol_event = alc_automute_amp_unsol_event,
9193 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009194 },
Kailang Yange2757d52008-08-26 13:17:46 +02009195 [ALC888_LENOVO_SKY] = {
9196 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9197 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9198 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9199 .dac_nids = alc883_dac_nids,
9200 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009201 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9202 .channel_mode = alc883_sixstack_modes,
9203 .need_dac_fix = 1,
9204 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009205 .unsol_event = alc_automute_amp_unsol_event,
9206 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009207 },
9208 [ALC888_ASUS_M90V] = {
9209 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9210 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9212 .dac_nids = alc883_dac_nids,
9213 .dig_out_nid = ALC883_DIGOUT_NID,
9214 .dig_in_nid = ALC883_DIGIN_NID,
9215 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9216 .channel_mode = alc883_3ST_6ch_modes,
9217 .need_dac_fix = 1,
9218 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9219 .unsol_event = alc883_mode2_unsol_event,
9220 .init_hook = alc883_mode2_inithook,
9221 },
9222 [ALC888_ASUS_EEE1601] = {
9223 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009224 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009225 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9226 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9227 .dac_nids = alc883_dac_nids,
9228 .dig_out_nid = ALC883_DIGOUT_NID,
9229 .dig_in_nid = ALC883_DIGIN_NID,
9230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9231 .channel_mode = alc883_3ST_2ch_modes,
9232 .need_dac_fix = 1,
9233 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009234 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009235 .init_hook = alc883_eee1601_inithook,
9236 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009237 [ALC1200_ASUS_P5Q] = {
9238 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9239 .init_verbs = { alc883_init_verbs },
9240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9241 .dac_nids = alc883_dac_nids,
9242 .dig_out_nid = ALC1200_DIGOUT_NID,
9243 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009244 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009245 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9246 .channel_mode = alc883_sixstack_modes,
9247 .input_mux = &alc883_capture_source,
9248 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009249 [ALC889A_MB31] = {
9250 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9251 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9252 alc880_gpio1_init_verbs },
9253 .adc_nids = alc883_adc_nids,
9254 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9255 .dac_nids = alc883_dac_nids,
9256 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9257 .channel_mode = alc889A_mb31_6ch_modes,
9258 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9259 .input_mux = &alc889A_mb31_capture_source,
9260 .dig_out_nid = ALC883_DIGOUT_NID,
9261 .unsol_event = alc889A_mb31_unsol_event,
9262 .init_hook = alc889A_mb31_automute,
9263 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009264 [ALC883_SONY_VAIO_TT] = {
9265 .mixers = { alc883_vaiott_mixer },
9266 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9268 .dac_nids = alc883_dac_nids,
9269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9270 .channel_mode = alc883_3ST_2ch_modes,
9271 .input_mux = &alc883_capture_source,
9272 .unsol_event = alc_automute_amp_unsol_event,
9273 .init_hook = alc883_vaiott_init_hook,
9274 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009275};
9276
9277
9278/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009279 * Pin config fixes
9280 */
9281enum {
9282 PINFIX_ABIT_AW9D_MAX
9283};
9284
9285static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9286 { 0x15, 0x01080104 }, /* side */
9287 { 0x16, 0x01011012 }, /* rear */
9288 { 0x17, 0x01016011 }, /* clfe */
9289 { }
9290};
9291
9292static const struct alc_pincfg *alc882_pin_fixes[] = {
9293 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9294};
9295
9296static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9297 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9298 {}
9299};
9300
9301/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009302 * BIOS auto configuration
9303 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009304static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009305 hda_nid_t nid, int pin_type,
9306 int dac_idx)
9307{
9308 /* set as output */
9309 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009310 int idx;
9311
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009312 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009313 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9314 idx = 4;
9315 else
9316 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009317 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9318
9319}
9320
Takashi Iwai4953550a2009-06-30 15:28:30 +02009321static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009322{
9323 struct alc_spec *spec = codec->spec;
9324 int i;
9325
9326 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009327 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009328 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009329 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009330 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009331 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009332 }
9333}
9334
Takashi Iwai4953550a2009-06-30 15:28:30 +02009335static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009336{
9337 struct alc_spec *spec = codec->spec;
9338 hda_nid_t pin;
9339
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009340 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009341 if (pin) /* connect to front */
9342 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009343 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009344 pin = spec->autocfg.speaker_pins[0];
9345 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009346 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009347}
9348
Takashi Iwai4953550a2009-06-30 15:28:30 +02009349static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009350{
9351 struct alc_spec *spec = codec->spec;
9352 int i;
9353
9354 for (i = 0; i < AUTO_PIN_LAST; i++) {
9355 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009356 if (!nid)
9357 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009358 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009359 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9360 snd_hda_codec_write(codec, nid, 0,
9361 AC_VERB_SET_AMP_GAIN_MUTE,
9362 AMP_OUT_MUTE);
9363 }
9364}
9365
9366static void alc882_auto_init_input_src(struct hda_codec *codec)
9367{
9368 struct alc_spec *spec = codec->spec;
9369 int c;
9370
9371 for (c = 0; c < spec->num_adc_nids; c++) {
9372 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9373 hda_nid_t nid = spec->capsrc_nids[c];
9374 unsigned int mux_idx;
9375 const struct hda_input_mux *imux;
9376 int conns, mute, idx, item;
9377
9378 conns = snd_hda_get_connections(codec, nid, conn_list,
9379 ARRAY_SIZE(conn_list));
9380 if (conns < 0)
9381 continue;
9382 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9383 imux = &spec->input_mux[mux_idx];
9384 for (idx = 0; idx < conns; idx++) {
9385 /* if the current connection is the selected one,
9386 * unmute it as default - otherwise mute it
9387 */
9388 mute = AMP_IN_MUTE(idx);
9389 for (item = 0; item < imux->num_items; item++) {
9390 if (imux->items[item].index == idx) {
9391 if (spec->cur_mux[c] == item)
9392 mute = AMP_IN_UNMUTE(idx);
9393 break;
9394 }
9395 }
9396 /* check if we have a selector or mixer
9397 * we could check for the widget type instead, but
9398 * just check for Amp-In presence (in case of mixer
9399 * without amp-in there is something wrong, this
9400 * function shouldn't be used or capsrc nid is wrong)
9401 */
9402 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009403 snd_hda_codec_write(codec, nid, 0,
9404 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009405 mute);
9406 else if (mute != AMP_IN_MUTE(idx))
9407 snd_hda_codec_write(codec, nid, 0,
9408 AC_VERB_SET_CONNECT_SEL,
9409 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009410 }
9411 }
9412}
9413
Takashi Iwai4953550a2009-06-30 15:28:30 +02009414/* add mic boosts if needed */
9415static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009416{
9417 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009418 int err;
9419 hda_nid_t nid;
9420
9421 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9422 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9423 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9424 "Mic Boost",
9425 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9426 if (err < 0)
9427 return err;
9428 }
9429 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9430 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9431 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9432 "Front Mic Boost",
9433 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9434 if (err < 0)
9435 return err;
9436 }
9437 return 0;
9438}
9439
9440/* almost identical with ALC880 parser... */
9441static int alc882_parse_auto_config(struct hda_codec *codec)
9442{
9443 struct alc_spec *spec = codec->spec;
9444 struct auto_pin_cfg *autocfg = &spec->autocfg;
9445 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009446 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009447 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009448
9449 if (err < 0)
9450 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009451 else if (!err)
9452 return 0; /* no config found */
9453
9454 err = alc_auto_add_mic_boost(codec);
9455 if (err < 0)
9456 return err;
9457
9458 /* hack - override the init verbs */
9459 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009460 /* if ADC 0x07 is available, initialize it, too */
9461 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009462 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009463 if (wcap == AC_WID_AUD_IN)
9464 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009465
Takashi Iwai4953550a2009-06-30 15:28:30 +02009466 /* digital-mic input pin is excluded in alc880_auto_create..()
9467 * because it's under 0x18
9468 */
9469 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9470 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9471 struct hda_input_mux *imux = &spec->private_imux[0];
9472 for (i = 1; i < 3; i++)
9473 memcpy(&spec->private_imux[i],
9474 &spec->private_imux[0],
9475 sizeof(spec->private_imux[0]));
9476 imux->items[imux->num_items].label = "Int DMic";
9477 imux->items[imux->num_items].index = 0x0b;
9478 imux->num_items++;
9479 spec->num_mux_defs = 3;
9480 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009481 }
9482
Takashi Iwai776e1842007-08-29 15:07:11 +02009483 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009484}
9485
9486/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009487static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009488{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009489 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009490 alc882_auto_init_multi_out(codec);
9491 alc882_auto_init_hp_out(codec);
9492 alc882_auto_init_analog_input(codec);
9493 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009494 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009495 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009496}
9497
Takashi Iwai4953550a2009-06-30 15:28:30 +02009498static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499{
9500 struct alc_spec *spec;
9501 int err, board_config;
9502
9503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9504 if (spec == NULL)
9505 return -ENOMEM;
9506
9507 codec->spec = spec;
9508
Takashi Iwai4953550a2009-06-30 15:28:30 +02009509 switch (codec->vendor_id) {
9510 case 0x10ec0882:
9511 case 0x10ec0885:
9512 break;
9513 default:
9514 /* ALC883 and variants */
9515 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9516 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009517 }
9518
Takashi Iwai4953550a2009-06-30 15:28:30 +02009519 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9520 alc882_models,
9521 alc882_cfg_tbl);
9522
9523 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9524 board_config = snd_hda_check_board_codec_sid_config(codec,
9525 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9526
9527 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009528 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009529 codec->chip_name);
9530 board_config = ALC882_AUTO;
9531 }
9532
9533 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9534
9535 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009536 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009537 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009538 if (err < 0) {
9539 alc_free(codec);
9540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009541 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009542 printk(KERN_INFO
9543 "hda_codec: Cannot set up configuration "
9544 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009545 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009546 }
9547 }
9548
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009549 err = snd_hda_attach_beep_device(codec, 0x1);
9550 if (err < 0) {
9551 alc_free(codec);
9552 return err;
9553 }
9554
Takashi Iwai4953550a2009-06-30 15:28:30 +02009555 if (board_config != ALC882_AUTO)
9556 setup_preset(spec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557
Takashi Iwai4953550a2009-06-30 15:28:30 +02009558 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9559 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9560 /* FIXME: setup DAC5 */
9561 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9562 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9563
9564 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9565 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9566
9567 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009568 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009569
9570 if (!spec->adc_nids && spec->input_mux) {
9571 int i;
9572 spec->num_adc_nids = 0;
9573 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9574 hda_nid_t cap;
9575 hda_nid_t nid = alc882_adc_nids[i];
9576 unsigned int wcap = get_wcaps(codec, nid);
9577 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009578 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009579 if (wcap != AC_WID_AUD_IN)
9580 continue;
9581 spec->private_adc_nids[spec->num_adc_nids] = nid;
9582 err = snd_hda_get_connections(codec, nid, &cap, 1);
9583 if (err < 0)
9584 continue;
9585 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9586 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009587 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009588 spec->adc_nids = spec->private_adc_nids;
9589 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009590 }
9591
Takashi Iwai4953550a2009-06-30 15:28:30 +02009592 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009593 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009594
Takashi Iwai2134ea42008-01-10 16:53:55 +01009595 spec->vmaster_nid = 0x0c;
9596
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009597 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009598 if (board_config == ALC882_AUTO)
9599 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009600#ifdef CONFIG_SND_HDA_POWER_SAVE
9601 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009602 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009603#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009604 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009605
9606 return 0;
9607}
9608
Takashi Iwai4953550a2009-06-30 15:28:30 +02009609
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009610/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009611 * ALC262 support
9612 */
9613
9614#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9615#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9616
9617#define alc262_dac_nids alc260_dac_nids
9618#define alc262_adc_nids alc882_adc_nids
9619#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009620#define alc262_capsrc_nids alc882_capsrc_nids
9621#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009622
9623#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009624#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009625
Kailang Yang4e555fe2008-08-26 13:05:55 +02009626static hda_nid_t alc262_dmic_adc_nids[1] = {
9627 /* ADC0 */
9628 0x09
9629};
9630
9631static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9632
Kailang Yangdf694da2005-12-05 19:42:22 +01009633static struct snd_kcontrol_new alc262_base_mixer[] = {
9634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9635 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009642 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009643 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009645 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009646 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9647 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9648 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9649 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009650 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009651};
9652
Takashi Iwaice875f02008-01-28 18:17:43 +01009653/* update HP, line and mono-out pins according to the master switch */
9654static void alc262_hp_master_update(struct hda_codec *codec)
9655{
9656 struct alc_spec *spec = codec->spec;
9657 int val = spec->master_sw;
9658
9659 /* HP & line-out */
9660 snd_hda_codec_write_cache(codec, 0x1b, 0,
9661 AC_VERB_SET_PIN_WIDGET_CONTROL,
9662 val ? PIN_HP : 0);
9663 snd_hda_codec_write_cache(codec, 0x15, 0,
9664 AC_VERB_SET_PIN_WIDGET_CONTROL,
9665 val ? PIN_HP : 0);
9666 /* mono (speaker) depending on the HP jack sense */
9667 val = val && !spec->jack_present;
9668 snd_hda_codec_write_cache(codec, 0x16, 0,
9669 AC_VERB_SET_PIN_WIDGET_CONTROL,
9670 val ? PIN_OUT : 0);
9671}
9672
9673static void alc262_hp_bpc_automute(struct hda_codec *codec)
9674{
9675 struct alc_spec *spec = codec->spec;
9676 unsigned int presence;
9677 presence = snd_hda_codec_read(codec, 0x1b, 0,
9678 AC_VERB_GET_PIN_SENSE, 0);
9679 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9680 alc262_hp_master_update(codec);
9681}
9682
9683static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9684{
9685 if ((res >> 26) != ALC880_HP_EVENT)
9686 return;
9687 alc262_hp_bpc_automute(codec);
9688}
9689
9690static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9691{
9692 struct alc_spec *spec = codec->spec;
9693 unsigned int presence;
9694 presence = snd_hda_codec_read(codec, 0x15, 0,
9695 AC_VERB_GET_PIN_SENSE, 0);
9696 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9697 alc262_hp_master_update(codec);
9698}
9699
9700static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9701 unsigned int res)
9702{
9703 if ((res >> 26) != ALC880_HP_EVENT)
9704 return;
9705 alc262_hp_wildwest_automute(codec);
9706}
9707
Takashi Iwaib72519b2009-05-08 14:31:55 +02009708#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009709
9710static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9711 struct snd_ctl_elem_value *ucontrol)
9712{
9713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9714 struct alc_spec *spec = codec->spec;
9715 int val = !!*ucontrol->value.integer.value;
9716
9717 if (val == spec->master_sw)
9718 return 0;
9719 spec->master_sw = val;
9720 alc262_hp_master_update(codec);
9721 return 1;
9722}
9723
Takashi Iwaib72519b2009-05-08 14:31:55 +02009724#define ALC262_HP_MASTER_SWITCH \
9725 { \
9726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9727 .name = "Master Playback Switch", \
9728 .info = snd_ctl_boolean_mono_info, \
9729 .get = alc262_hp_master_sw_get, \
9730 .put = alc262_hp_master_sw_put, \
9731 }
9732
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009734 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009735 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9736 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009738 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9739 HDA_OUTPUT),
9740 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9741 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009744 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009747 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009748 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9749 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9750 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9751 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009752 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9753 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9754 { } /* end */
9755};
9756
Kailang Yangcd7509a2007-01-26 18:33:17 +01009757static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009758 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9760 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9761 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009763 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9764 HDA_OUTPUT),
9765 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9766 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009769 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009774 { } /* end */
9775};
9776
9777static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9778 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9779 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009780 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009781 { } /* end */
9782};
9783
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009784/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009785static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009786{
9787 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009788
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009789 spec->autocfg.hp_pins[0] = 0x15;
9790 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9791 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009792}
9793
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009794static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009795 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9796 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009797 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9802 { } /* end */
9803};
9804
9805static struct hda_verb alc262_hp_t5735_verbs[] = {
9806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9808
9809 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9810 { }
9811};
9812
Kailang Yang8c427222008-01-10 13:03:59 +01009813static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009814 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009816 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9817 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9820 { } /* end */
9821};
9822
9823static struct hda_verb alc262_hp_rp5700_verbs[] = {
9824 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9828 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9829 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9833 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9834 {}
9835};
9836
9837static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9838 .num_items = 1,
9839 .items = {
9840 { "Line", 0x1 },
9841 },
9842};
9843
Takashi Iwai42171c12009-05-08 14:11:43 +02009844/* bind hp and internal speaker mute (with plug check) as master switch */
9845static void alc262_hippo_master_update(struct hda_codec *codec)
9846{
9847 struct alc_spec *spec = codec->spec;
9848 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9849 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9850 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9851 unsigned int mute;
9852
9853 /* HP */
9854 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9855 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9856 HDA_AMP_MUTE, mute);
9857 /* mute internal speaker per jack sense */
9858 if (spec->jack_present)
9859 mute = HDA_AMP_MUTE;
9860 if (line_nid)
9861 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9862 HDA_AMP_MUTE, mute);
9863 if (speaker_nid && speaker_nid != line_nid)
9864 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9865 HDA_AMP_MUTE, mute);
9866}
9867
9868#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9869
9870static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9871 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009872{
9873 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009874 struct alc_spec *spec = codec->spec;
9875 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009876
Takashi Iwai42171c12009-05-08 14:11:43 +02009877 if (val == spec->master_sw)
9878 return 0;
9879 spec->master_sw = val;
9880 alc262_hippo_master_update(codec);
9881 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009882}
Takashi Iwai5b319542007-07-26 11:49:22 +02009883
Takashi Iwai42171c12009-05-08 14:11:43 +02009884#define ALC262_HIPPO_MASTER_SWITCH \
9885 { \
9886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9887 .name = "Master Playback Switch", \
9888 .info = snd_ctl_boolean_mono_info, \
9889 .get = alc262_hippo_master_sw_get, \
9890 .put = alc262_hippo_master_sw_put, \
9891 }
9892
9893static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9894 ALC262_HIPPO_MASTER_SWITCH,
9895 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9898 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9899 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9902 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9903 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9904 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9905 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9906 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9907 { } /* end */
9908};
9909
9910static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9911 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9912 ALC262_HIPPO_MASTER_SWITCH,
9913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9919 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9921 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9922 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9923 { } /* end */
9924};
9925
9926/* mute/unmute internal speaker according to the hp jack and mute state */
9927static void alc262_hippo_automute(struct hda_codec *codec)
9928{
9929 struct alc_spec *spec = codec->spec;
9930 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9931 unsigned int present;
9932
9933 /* need to execute and sync at first */
9934 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9935 present = snd_hda_codec_read(codec, hp_nid, 0,
9936 AC_VERB_GET_PIN_SENSE, 0);
9937 spec->jack_present = (present & 0x80000000) != 0;
9938 alc262_hippo_master_update(codec);
9939}
9940
9941static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9942{
9943 if ((res >> 26) != ALC880_HP_EVENT)
9944 return;
9945 alc262_hippo_automute(codec);
9946}
9947
9948static void alc262_hippo_init_hook(struct hda_codec *codec)
9949{
9950 struct alc_spec *spec = codec->spec;
9951
9952 spec->autocfg.hp_pins[0] = 0x15;
9953 spec->autocfg.speaker_pins[0] = 0x14;
9954 alc262_hippo_automute(codec);
9955}
9956
9957static void alc262_hippo1_init_hook(struct hda_codec *codec)
9958{
9959 struct alc_spec *spec = codec->spec;
9960
9961 spec->autocfg.hp_pins[0] = 0x1b;
9962 spec->autocfg.speaker_pins[0] = 0x14;
9963 alc262_hippo_automute(codec);
9964}
9965
9966
Kailang Yang272a5272007-05-14 11:00:38 +02009967static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009968 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009969 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9972 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9973 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9974 { } /* end */
9975};
9976
Kailang Yang83c34212007-07-05 11:43:05 +02009977static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009978 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9979 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9983 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9984 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9985 { } /* end */
9986};
Kailang Yang272a5272007-05-14 11:00:38 +02009987
Tony Vroonba340e82009-02-02 19:01:30 +00009988static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9989 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9990 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9991 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9992 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9999 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10001 { } /* end */
10002};
10003
10004static struct hda_verb alc262_tyan_verbs[] = {
10005 /* Headphone automute */
10006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10008 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10009
10010 /* P11 AUX_IN, white 4-pin connector */
10011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10012 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10013 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10014 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10015
10016 {}
10017};
10018
10019/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010020static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010021{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010022 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010023
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010024 spec->autocfg.hp_pins[0] = 0x1b;
10025 spec->autocfg.speaker_pins[0] = 0x15;
10026 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010027}
10028
Tony Vroonba340e82009-02-02 19:01:30 +000010029
Kailang Yangdf694da2005-12-05 19:42:22 +010010030#define alc262_capture_mixer alc882_capture_mixer
10031#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10032
10033/*
10034 * generic initialization of ADC, input mixers and output mixers
10035 */
10036static struct hda_verb alc262_init_verbs[] = {
10037 /*
10038 * Unmute ADC0-2 and set the default input to mic-in
10039 */
10040 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10042 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10044 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10045 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10046
Takashi Iwaicb53c622007-08-10 17:21:45 +020010047 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010048 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010049 * Note: PASD motherboards uses the Line In 2 as the input for
10050 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010051 */
10052 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010058
10059 /*
10060 * Set up output mixers (0x0c - 0x0e)
10061 */
10062 /* set vol=0 to output mixers */
10063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10066 /* set up input amps for analog loopback */
10067 /* Amp Indices: DAC = 0, mixer = 1 */
10068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10074
10075 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10077 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10078 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10080 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10081
10082 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010087
Kailang Yangdf694da2005-12-05 19:42:22 +010010088 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010090
Kailang Yangdf694da2005-12-05 19:42:22 +010010091 /* FIXME: use matrix-type input source selection */
10092 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10093 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10098 /* Input mixer2 */
10099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10103 /* Input mixer3 */
10104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010108
10109 { }
10110};
10111
Kailang Yang4e555fe2008-08-26 13:05:55 +020010112static struct hda_verb alc262_eapd_verbs[] = {
10113 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10114 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10115 { }
10116};
10117
Kailang Yangccc656c2006-10-17 12:32:26 +020010118static struct hda_verb alc262_hippo_unsol_verbs[] = {
10119 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10121 {}
10122};
10123
10124static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10125 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10126 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10128
10129 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10131 {}
10132};
10133
Kailang Yang272a5272007-05-14 11:00:38 +020010134static struct hda_verb alc262_sony_unsol_verbs[] = {
10135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10137 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10138
10139 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010141 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010142};
10143
Kailang Yang4e555fe2008-08-26 13:05:55 +020010144static struct hda_input_mux alc262_dmic_capture_source = {
10145 .num_items = 2,
10146 .items = {
10147 { "Int DMic", 0x9 },
10148 { "Mic", 0x0 },
10149 },
10150};
10151
10152static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10153 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10154 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010158 { } /* end */
10159};
10160
10161static struct hda_verb alc262_toshiba_s06_verbs[] = {
10162 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10166 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10167 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10168 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10170 {}
10171};
10172
10173static void alc262_dmic_automute(struct hda_codec *codec)
10174{
10175 unsigned int present;
10176
10177 present = snd_hda_codec_read(codec, 0x18, 0,
10178 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10179 snd_hda_codec_write(codec, 0x22, 0,
10180 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10181}
10182
Kailang Yang4e555fe2008-08-26 13:05:55 +020010183
10184/* unsolicited event for HP jack sensing */
10185static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10186 unsigned int res)
10187{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010188 if ((res >> 26) == ALC880_MIC_EVENT)
10189 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010190 else
10191 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010192}
10193
10194static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010196 struct alc_spec *spec = codec->spec;
10197
10198 spec->autocfg.hp_pins[0] = 0x15;
10199 spec->autocfg.speaker_pins[0] = 0x14;
10200 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010201 alc262_dmic_automute(codec);
10202}
10203
Takashi Iwai834be882006-03-01 14:16:17 +010010204/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010205 * nec model
10206 * 0x15 = headphone
10207 * 0x16 = internal speaker
10208 * 0x18 = external mic
10209 */
10210
10211static struct snd_kcontrol_new alc262_nec_mixer[] = {
10212 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10213 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10214
10215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10218
10219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10221 { } /* end */
10222};
10223
10224static struct hda_verb alc262_nec_verbs[] = {
10225 /* Unmute Speaker */
10226 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10227
10228 /* Headphone */
10229 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10231
10232 /* External mic to headphone */
10233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10234 /* External mic to speaker */
10235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10236 {}
10237};
10238
10239/*
Takashi Iwai834be882006-03-01 14:16:17 +010010240 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010241 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10242 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010243 */
10244
10245#define ALC_HP_EVENT 0x37
10246
10247static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10248 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010252 {}
10253};
10254
Jiang zhe0e31daf2008-03-20 12:12:39 +010010255static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10258 {}
10259};
10260
Takashi Iwai834be882006-03-01 14:16:17 +010010261static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010262 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010263 .items = {
10264 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010265 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010266 { "CD", 0x4 },
10267 },
10268};
10269
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010270static struct hda_input_mux alc262_HP_capture_source = {
10271 .num_items = 5,
10272 .items = {
10273 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010274 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010275 { "Line", 0x2 },
10276 { "CD", 0x4 },
10277 { "AUX IN", 0x6 },
10278 },
10279};
10280
zhejiangaccbe492007-08-31 12:36:05 +020010281static struct hda_input_mux alc262_HP_D7000_capture_source = {
10282 .num_items = 4,
10283 .items = {
10284 { "Mic", 0x0 },
10285 { "Front Mic", 0x2 },
10286 { "Line", 0x1 },
10287 { "CD", 0x4 },
10288 },
10289};
10290
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010291/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010292static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10293{
10294 struct alc_spec *spec = codec->spec;
10295 unsigned int mute;
10296
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010297 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010298 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010299 /* need to execute and sync at first */
10300 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010301 /* check laptop HP jack */
10302 present = snd_hda_codec_read(codec, 0x14, 0,
10303 AC_VERB_GET_PIN_SENSE, 0);
10304 /* need to execute and sync at first */
10305 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10306 /* check docking HP jack */
10307 present |= snd_hda_codec_read(codec, 0x1b, 0,
10308 AC_VERB_GET_PIN_SENSE, 0);
10309 if (present & AC_PINSENSE_PRESENCE)
10310 spec->jack_present = 1;
10311 else
10312 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010313 spec->sense_updated = 1;
10314 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010315 /* unmute internal speaker only if both HPs are unplugged and
10316 * master switch is on
10317 */
10318 if (spec->jack_present)
10319 mute = HDA_AMP_MUTE;
10320 else
Takashi Iwai834be882006-03-01 14:16:17 +010010321 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010322 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10323 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010324}
10325
10326/* unsolicited event for HP jack sensing */
10327static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10328 unsigned int res)
10329{
10330 if ((res >> 26) != ALC_HP_EVENT)
10331 return;
10332 alc262_fujitsu_automute(codec, 1);
10333}
10334
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010335static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10336{
10337 alc262_fujitsu_automute(codec, 1);
10338}
10339
Takashi Iwai834be882006-03-01 14:16:17 +010010340/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010341static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10342 .ops = &snd_hda_bind_vol,
10343 .values = {
10344 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10345 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10346 0
10347 },
10348};
Takashi Iwai834be882006-03-01 14:16:17 +010010349
Jiang zhe0e31daf2008-03-20 12:12:39 +010010350/* mute/unmute internal speaker according to the hp jack and mute state */
10351static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10352{
10353 struct alc_spec *spec = codec->spec;
10354 unsigned int mute;
10355
10356 if (force || !spec->sense_updated) {
10357 unsigned int present_int_hp;
10358 /* need to execute and sync at first */
10359 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10360 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10361 AC_VERB_GET_PIN_SENSE, 0);
10362 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10363 spec->sense_updated = 1;
10364 }
10365 if (spec->jack_present) {
10366 /* mute internal speaker */
10367 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10368 HDA_AMP_MUTE, HDA_AMP_MUTE);
10369 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10370 HDA_AMP_MUTE, HDA_AMP_MUTE);
10371 } else {
10372 /* unmute internal speaker if necessary */
10373 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10374 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10375 HDA_AMP_MUTE, mute);
10376 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10377 HDA_AMP_MUTE, mute);
10378 }
10379}
10380
10381/* unsolicited event for HP jack sensing */
10382static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10383 unsigned int res)
10384{
10385 if ((res >> 26) != ALC_HP_EVENT)
10386 return;
10387 alc262_lenovo_3000_automute(codec, 1);
10388}
10389
Takashi Iwai8de56b72009-07-24 16:51:47 +020010390static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10391 int dir, int idx, long *valp)
10392{
10393 int i, change = 0;
10394
10395 for (i = 0; i < 2; i++, valp++)
10396 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10397 HDA_AMP_MUTE,
10398 *valp ? 0 : HDA_AMP_MUTE);
10399 return change;
10400}
10401
Takashi Iwai834be882006-03-01 14:16:17 +010010402/* bind hp and internal speaker mute (with plug check) */
10403static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10404 struct snd_ctl_elem_value *ucontrol)
10405{
10406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10407 long *valp = ucontrol->value.integer.value;
10408 int change;
10409
Takashi Iwai8de56b72009-07-24 16:51:47 +020010410 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10411 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010412 if (change)
10413 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010414 return change;
10415}
10416
10417static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010418 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010419 {
10420 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10421 .name = "Master Playback Switch",
10422 .info = snd_hda_mixer_amp_switch_info,
10423 .get = snd_hda_mixer_amp_switch_get,
10424 .put = alc262_fujitsu_master_sw_put,
10425 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10426 },
10427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010432 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10433 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10434 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010435 { } /* end */
10436};
10437
Jiang zhe0e31daf2008-03-20 12:12:39 +010010438/* bind hp and internal speaker mute (with plug check) */
10439static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10440 struct snd_ctl_elem_value *ucontrol)
10441{
10442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10443 long *valp = ucontrol->value.integer.value;
10444 int change;
10445
Takashi Iwai8de56b72009-07-24 16:51:47 +020010446 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010447 if (change)
10448 alc262_lenovo_3000_automute(codec, 0);
10449 return change;
10450}
10451
10452static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10453 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10454 {
10455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10456 .name = "Master Playback Switch",
10457 .info = snd_hda_mixer_amp_switch_info,
10458 .get = snd_hda_mixer_amp_switch_get,
10459 .put = alc262_lenovo_3000_master_sw_put,
10460 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10461 },
10462 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10463 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10464 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10467 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10468 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10469 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10470 { } /* end */
10471};
10472
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010473static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10474 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010475 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10478 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10479 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10480 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10481 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10482 { } /* end */
10483};
10484
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010485/* additional init verbs for Benq laptops */
10486static struct hda_verb alc262_EAPD_verbs[] = {
10487 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10488 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10489 {}
10490};
10491
Kailang Yang83c34212007-07-05 11:43:05 +020010492static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10494 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10495
10496 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10497 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10498 {}
10499};
10500
Tobin Davisf651b502007-10-26 12:40:47 +020010501/* Samsung Q1 Ultra Vista model setup */
10502static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010503 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10504 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10507 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010508 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010509 { } /* end */
10510};
10511
10512static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010513 /* output mixer */
10514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10517 /* speaker */
10518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10521 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10522 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010524 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10527 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10528 /* internal mic */
10529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10531 /* ADC, choose mic */
10532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010542 {}
10543};
10544
Tobin Davisf651b502007-10-26 12:40:47 +020010545/* mute/unmute internal speaker according to the hp jack and mute state */
10546static void alc262_ultra_automute(struct hda_codec *codec)
10547{
10548 struct alc_spec *spec = codec->spec;
10549 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010550
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010551 mute = 0;
10552 /* auto-mute only when HP is used as HP */
10553 if (!spec->cur_mux[0]) {
10554 unsigned int present;
10555 /* need to execute and sync at first */
10556 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10557 present = snd_hda_codec_read(codec, 0x15, 0,
10558 AC_VERB_GET_PIN_SENSE, 0);
10559 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10560 if (spec->jack_present)
10561 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010562 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010563 /* mute/unmute internal speaker */
10564 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10565 HDA_AMP_MUTE, mute);
10566 /* mute/unmute HP */
10567 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10568 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010569}
10570
10571/* unsolicited event for HP jack sensing */
10572static void alc262_ultra_unsol_event(struct hda_codec *codec,
10573 unsigned int res)
10574{
10575 if ((res >> 26) != ALC880_HP_EVENT)
10576 return;
10577 alc262_ultra_automute(codec);
10578}
10579
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010580static struct hda_input_mux alc262_ultra_capture_source = {
10581 .num_items = 2,
10582 .items = {
10583 { "Mic", 0x1 },
10584 { "Headphone", 0x7 },
10585 },
10586};
10587
10588static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10589 struct snd_ctl_elem_value *ucontrol)
10590{
10591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10592 struct alc_spec *spec = codec->spec;
10593 int ret;
10594
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010595 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010596 if (!ret)
10597 return 0;
10598 /* reprogram the HP pin as mic or HP according to the input source */
10599 snd_hda_codec_write_cache(codec, 0x15, 0,
10600 AC_VERB_SET_PIN_WIDGET_CONTROL,
10601 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10602 alc262_ultra_automute(codec); /* mute/unmute HP */
10603 return ret;
10604}
10605
10606static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10607 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10608 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10609 {
10610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10611 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010612 .info = alc_mux_enum_info,
10613 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010614 .put = alc262_ultra_mux_enum_put,
10615 },
10616 { } /* end */
10617};
10618
Kailang Yangdf694da2005-12-05 19:42:22 +010010619/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010620static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10621 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010622{
10623 hda_nid_t nid;
10624 int err;
10625
10626 spec->multiout.num_dacs = 1; /* only use one dac */
10627 spec->multiout.dac_nids = spec->private_dac_nids;
10628 spec->multiout.dac_nids[0] = 2;
10629
10630 nid = cfg->line_out_pins[0];
10631 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010632 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10633 "Front Playback Volume",
10634 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10635 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10638 "Front Playback Switch",
10639 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10640 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010641 return err;
10642 }
10643
Takashi Iwai82bc9552006-03-21 11:24:42 +010010644 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010645 if (nid) {
10646 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010647 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10648 "Speaker Playback Volume",
10649 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10650 HDA_OUTPUT));
10651 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010652 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010653 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10654 "Speaker Playback Switch",
10655 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10656 HDA_OUTPUT));
10657 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010658 return err;
10659 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010660 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10661 "Speaker Playback Switch",
10662 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10663 HDA_OUTPUT));
10664 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010665 return err;
10666 }
10667 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010668 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010669 if (nid) {
10670 /* spec->multiout.hp_nid = 2; */
10671 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010672 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10673 "Headphone Playback Volume",
10674 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10675 HDA_OUTPUT));
10676 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010678 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10679 "Headphone Playback Switch",
10680 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10681 HDA_OUTPUT));
10682 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010683 return err;
10684 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010685 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10686 "Headphone Playback Switch",
10687 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10688 HDA_OUTPUT));
10689 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010690 return err;
10691 }
10692 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010693 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010694}
10695
Takashi Iwai8c927b42009-06-22 10:56:54 +020010696static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10697 const struct auto_pin_cfg *cfg)
10698{
10699 int err;
10700
10701 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10702 if (err < 0)
10703 return err;
10704 /* digital-mic input pin is excluded in alc880_auto_create..()
10705 * because it's under 0x18
10706 */
10707 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10708 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10709 struct hda_input_mux *imux = &spec->private_imux[0];
10710 imux->items[imux->num_items].label = "Int Mic";
10711 imux->items[imux->num_items].index = 0x09;
10712 imux->num_items++;
10713 }
10714 return 0;
10715}
10716
Kailang Yangdf694da2005-12-05 19:42:22 +010010717
10718/*
10719 * generic initialization of ADC, input mixers and output mixers
10720 */
10721static struct hda_verb alc262_volume_init_verbs[] = {
10722 /*
10723 * Unmute ADC0-2 and set the default input to mic-in
10724 */
10725 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10727 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10729 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10731
Takashi Iwaicb53c622007-08-10 17:21:45 +020010732 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010733 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010734 * Note: PASD motherboards uses the Line In 2 as the input for
10735 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010736 */
10737 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010743
10744 /*
10745 * Set up output mixers (0x0c - 0x0f)
10746 */
10747 /* set vol=0 to output mixers */
10748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010751
Kailang Yangdf694da2005-12-05 19:42:22 +010010752 /* set up input amps for analog loopback */
10753 /* Amp Indices: DAC = 0, mixer = 1 */
10754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10756 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10760
10761 /* FIXME: use matrix-type input source selection */
10762 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10763 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10765 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10768 /* Input mixer2 */
10769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10770 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10773 /* Input mixer3 */
10774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10778
10779 { }
10780};
10781
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010782static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10783 /*
10784 * Unmute ADC0-2 and set the default input to mic-in
10785 */
10786 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10788 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10790 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10792
Takashi Iwaicb53c622007-08-10 17:21:45 +020010793 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010794 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010795 * Note: PASD motherboards uses the Line In 2 as the input for
10796 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010797 */
10798 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010806
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010807 /*
10808 * Set up output mixers (0x0c - 0x0e)
10809 */
10810 /* set vol=0 to output mixers */
10811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10814
10815 /* set up input amps for analog loopback */
10816 /* Amp Indices: DAC = 0, mixer = 1 */
10817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10823
Takashi Iwaice875f02008-01-28 18:17:43 +010010824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10827
10828 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10830
10831 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10832 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10833
10834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10835 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10838 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10839
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010844 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10845 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10846
10847
10848 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010849 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10850 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010860 /* Input mixer2 */
10861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010870 /* Input mixer3 */
10871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010880
Takashi Iwaice875f02008-01-28 18:17:43 +010010881 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10882
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010883 { }
10884};
10885
Kailang Yangcd7509a2007-01-26 18:33:17 +010010886static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10887 /*
10888 * Unmute ADC0-2 and set the default input to mic-in
10889 */
10890 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10894 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10895 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10896
Takashi Iwaicb53c622007-08-10 17:21:45 +020010897 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010898 * mixer widget
10899 * Note: PASD motherboards uses the Line In 2 as the input for front
10900 * panel mic (mic 2)
10901 */
10902 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010911 /*
10912 * Set up output mixers (0x0c - 0x0e)
10913 */
10914 /* set vol=0 to output mixers */
10915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10918
10919 /* set up input amps for analog loopback */
10920 /* Amp Indices: DAC = 0, mixer = 1 */
10921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10927
10928
10929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10930 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10931 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10936
10937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10939
10940 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10942
10943 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10945 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10947 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10948 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10949
10950 /* FIXME: use matrix-type input source selection */
10951 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10952 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10954 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10956 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10958 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10960 /* Input mixer2 */
10961 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10966 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10968 /* Input mixer3 */
10969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10974 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10976
Takashi Iwaice875f02008-01-28 18:17:43 +010010977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10978
Kailang Yangcd7509a2007-01-26 18:33:17 +010010979 { }
10980};
10981
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010982static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10983
10984 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10985 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10986 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10987
10988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10989 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10992
10993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10995 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10996 {}
10997};
10998
10999
Takashi Iwaicb53c622007-08-10 17:21:45 +020011000#ifdef CONFIG_SND_HDA_POWER_SAVE
11001#define alc262_loopbacks alc880_loopbacks
11002#endif
11003
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011004/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011005#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11006#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11007#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11008#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11009
11010/*
11011 * BIOS auto configuration
11012 */
11013static int alc262_parse_auto_config(struct hda_codec *codec)
11014{
11015 struct alc_spec *spec = codec->spec;
11016 int err;
11017 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11018
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011019 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11020 alc262_ignore);
11021 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011022 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011023 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011024 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011025 spec->multiout.max_channels = 2;
11026 spec->no_analog = 1;
11027 goto dig_only;
11028 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011029 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011030 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011031 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11032 if (err < 0)
11033 return err;
11034 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11035 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011036 return err;
11037
11038 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11039
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011040 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011041 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011042 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011043 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011044 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011045 if (spec->autocfg.dig_in_pin)
11046 spec->dig_in_nid = ALC262_DIGIN_NID;
11047
Takashi Iwai603c4012008-07-30 15:01:44 +020011048 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011049 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011050
Takashi Iwaid88897e2008-10-31 15:01:37 +010011051 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011052 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011053 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011054
Takashi Iwai776e1842007-08-29 15:07:11 +020011055 err = alc_auto_add_mic_boost(codec);
11056 if (err < 0)
11057 return err;
11058
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011059 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11060
Kailang Yangdf694da2005-12-05 19:42:22 +010011061 return 1;
11062}
11063
11064#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11065#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11066#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011067#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011068
11069
11070/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011071static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011072{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011073 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011074 alc262_auto_init_multi_out(codec);
11075 alc262_auto_init_hp_out(codec);
11076 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011077 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011078 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011079 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011080}
11081
11082/*
11083 * configuration and preset
11084 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011085static const char *alc262_models[ALC262_MODEL_LAST] = {
11086 [ALC262_BASIC] = "basic",
11087 [ALC262_HIPPO] = "hippo",
11088 [ALC262_HIPPO_1] = "hippo_1",
11089 [ALC262_FUJITSU] = "fujitsu",
11090 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011091 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011092 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011093 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011094 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011095 [ALC262_BENQ_T31] = "benq-t31",
11096 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011097 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011098 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011099 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011100 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011101 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011102 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011103 [ALC262_AUTO] = "auto",
11104};
11105
11106static struct snd_pci_quirk alc262_cfg_tbl[] = {
11107 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011108 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011109 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11110 ALC262_HP_BPC),
11111 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11112 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011113 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11114 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011115 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011116 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011117 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011118 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011119 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011120 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011121 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011123 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11124 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11125 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011126 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11127 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011128 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011129 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011130 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011131 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011132 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011133 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011134 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11135 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011136 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011137 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011138 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011139 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011140 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011141 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011142 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11143 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011144 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011145 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011146 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011147 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011148 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011149 {}
11150};
11151
11152static struct alc_config_preset alc262_presets[] = {
11153 [ALC262_BASIC] = {
11154 .mixers = { alc262_base_mixer },
11155 .init_verbs = { alc262_init_verbs },
11156 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11157 .dac_nids = alc262_dac_nids,
11158 .hp_nid = 0x03,
11159 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11160 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011161 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011162 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011163 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011164 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011165 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11166 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11167 .dac_nids = alc262_dac_nids,
11168 .hp_nid = 0x03,
11169 .dig_out_nid = ALC262_DIGOUT_NID,
11170 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11171 .channel_mode = alc262_modes,
11172 .input_mux = &alc262_capture_source,
11173 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011174 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011175 },
11176 [ALC262_HIPPO_1] = {
11177 .mixers = { alc262_hippo1_mixer },
11178 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11179 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11180 .dac_nids = alc262_dac_nids,
11181 .hp_nid = 0x02,
11182 .dig_out_nid = ALC262_DIGOUT_NID,
11183 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11184 .channel_mode = alc262_modes,
11185 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011186 .unsol_event = alc262_hippo_unsol_event,
11187 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011188 },
Takashi Iwai834be882006-03-01 14:16:17 +010011189 [ALC262_FUJITSU] = {
11190 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011191 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11192 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011193 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11194 .dac_nids = alc262_dac_nids,
11195 .hp_nid = 0x03,
11196 .dig_out_nid = ALC262_DIGOUT_NID,
11197 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11198 .channel_mode = alc262_modes,
11199 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011200 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011201 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011202 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011203 [ALC262_HP_BPC] = {
11204 .mixers = { alc262_HP_BPC_mixer },
11205 .init_verbs = { alc262_HP_BPC_init_verbs },
11206 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11207 .dac_nids = alc262_dac_nids,
11208 .hp_nid = 0x03,
11209 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11210 .channel_mode = alc262_modes,
11211 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011212 .unsol_event = alc262_hp_bpc_unsol_event,
11213 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011214 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011215 [ALC262_HP_BPC_D7000_WF] = {
11216 .mixers = { alc262_HP_BPC_WildWest_mixer },
11217 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11218 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11219 .dac_nids = alc262_dac_nids,
11220 .hp_nid = 0x03,
11221 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11222 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011223 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011224 .unsol_event = alc262_hp_wildwest_unsol_event,
11225 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011226 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011227 [ALC262_HP_BPC_D7000_WL] = {
11228 .mixers = { alc262_HP_BPC_WildWest_mixer,
11229 alc262_HP_BPC_WildWest_option_mixer },
11230 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11231 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11232 .dac_nids = alc262_dac_nids,
11233 .hp_nid = 0x03,
11234 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11235 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011236 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011237 .unsol_event = alc262_hp_wildwest_unsol_event,
11238 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011239 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011240 [ALC262_HP_TC_T5735] = {
11241 .mixers = { alc262_hp_t5735_mixer },
11242 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11243 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11244 .dac_nids = alc262_dac_nids,
11245 .hp_nid = 0x03,
11246 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11247 .channel_mode = alc262_modes,
11248 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011249 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011250 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011251 },
11252 [ALC262_HP_RP5700] = {
11253 .mixers = { alc262_hp_rp5700_mixer },
11254 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11255 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11256 .dac_nids = alc262_dac_nids,
11257 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11258 .channel_mode = alc262_modes,
11259 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011260 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011261 [ALC262_BENQ_ED8] = {
11262 .mixers = { alc262_base_mixer },
11263 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11264 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11265 .dac_nids = alc262_dac_nids,
11266 .hp_nid = 0x03,
11267 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11268 .channel_mode = alc262_modes,
11269 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011270 },
Kailang Yang272a5272007-05-14 11:00:38 +020011271 [ALC262_SONY_ASSAMD] = {
11272 .mixers = { alc262_sony_mixer },
11273 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11274 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11275 .dac_nids = alc262_dac_nids,
11276 .hp_nid = 0x02,
11277 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11278 .channel_mode = alc262_modes,
11279 .input_mux = &alc262_capture_source,
11280 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011281 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011282 },
11283 [ALC262_BENQ_T31] = {
11284 .mixers = { alc262_benq_t31_mixer },
11285 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11286 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11287 .dac_nids = alc262_dac_nids,
11288 .hp_nid = 0x03,
11289 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11290 .channel_mode = alc262_modes,
11291 .input_mux = &alc262_capture_source,
11292 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011293 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011294 },
Tobin Davisf651b502007-10-26 12:40:47 +020011295 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011296 .mixers = { alc262_ultra_mixer },
11297 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011298 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011299 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11300 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011301 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11302 .channel_mode = alc262_modes,
11303 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011304 .adc_nids = alc262_adc_nids, /* ADC0 */
11305 .capsrc_nids = alc262_capsrc_nids,
11306 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011307 .unsol_event = alc262_ultra_unsol_event,
11308 .init_hook = alc262_ultra_automute,
11309 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011310 [ALC262_LENOVO_3000] = {
11311 .mixers = { alc262_lenovo_3000_mixer },
11312 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11313 alc262_lenovo_3000_unsol_verbs },
11314 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11315 .dac_nids = alc262_dac_nids,
11316 .hp_nid = 0x03,
11317 .dig_out_nid = ALC262_DIGOUT_NID,
11318 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11319 .channel_mode = alc262_modes,
11320 .input_mux = &alc262_fujitsu_capture_source,
11321 .unsol_event = alc262_lenovo_3000_unsol_event,
11322 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011323 [ALC262_NEC] = {
11324 .mixers = { alc262_nec_mixer },
11325 .init_verbs = { alc262_nec_verbs },
11326 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11327 .dac_nids = alc262_dac_nids,
11328 .hp_nid = 0x03,
11329 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11330 .channel_mode = alc262_modes,
11331 .input_mux = &alc262_capture_source,
11332 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011333 [ALC262_TOSHIBA_S06] = {
11334 .mixers = { alc262_toshiba_s06_mixer },
11335 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11336 alc262_eapd_verbs },
11337 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11338 .capsrc_nids = alc262_dmic_capsrc_nids,
11339 .dac_nids = alc262_dac_nids,
11340 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011341 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011342 .dig_out_nid = ALC262_DIGOUT_NID,
11343 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11344 .channel_mode = alc262_modes,
11345 .input_mux = &alc262_dmic_capture_source,
11346 .unsol_event = alc262_toshiba_s06_unsol_event,
11347 .init_hook = alc262_toshiba_s06_init_hook,
11348 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011349 [ALC262_TOSHIBA_RX1] = {
11350 .mixers = { alc262_toshiba_rx1_mixer },
11351 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11352 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11353 .dac_nids = alc262_dac_nids,
11354 .hp_nid = 0x03,
11355 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11356 .channel_mode = alc262_modes,
11357 .input_mux = &alc262_capture_source,
11358 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011359 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011360 },
Tony Vroonba340e82009-02-02 19:01:30 +000011361 [ALC262_TYAN] = {
11362 .mixers = { alc262_tyan_mixer },
11363 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11364 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11365 .dac_nids = alc262_dac_nids,
11366 .hp_nid = 0x02,
11367 .dig_out_nid = ALC262_DIGOUT_NID,
11368 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11369 .channel_mode = alc262_modes,
11370 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011371 .unsol_event = alc_automute_amp_unsol_event,
11372 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011373 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011374};
11375
11376static int patch_alc262(struct hda_codec *codec)
11377{
11378 struct alc_spec *spec;
11379 int board_config;
11380 int err;
11381
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011382 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011383 if (spec == NULL)
11384 return -ENOMEM;
11385
11386 codec->spec = spec;
11387#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011388 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11389 * under-run
11390 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011391 {
11392 int tmp;
11393 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11394 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11395 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11396 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11397 }
11398#endif
11399
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011400 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11401
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011402 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11403 alc262_models,
11404 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011405
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011406 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011407 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11408 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011409 board_config = ALC262_AUTO;
11410 }
11411
11412 if (board_config == ALC262_AUTO) {
11413 /* automatic parse from the BIOS config */
11414 err = alc262_parse_auto_config(codec);
11415 if (err < 0) {
11416 alc_free(codec);
11417 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011418 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011419 printk(KERN_INFO
11420 "hda_codec: Cannot set up configuration "
11421 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011422 board_config = ALC262_BASIC;
11423 }
11424 }
11425
Takashi Iwai07eba612009-02-19 08:06:35 +010011426 if (!spec->no_analog) {
11427 err = snd_hda_attach_beep_device(codec, 0x1);
11428 if (err < 0) {
11429 alc_free(codec);
11430 return err;
11431 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011432 }
11433
Kailang Yangdf694da2005-12-05 19:42:22 +010011434 if (board_config != ALC262_AUTO)
11435 setup_preset(spec, &alc262_presets[board_config]);
11436
Kailang Yangdf694da2005-12-05 19:42:22 +010011437 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11438 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011439
Kailang Yangdf694da2005-12-05 19:42:22 +010011440 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11441 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11442
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011443 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011444 int i;
11445 /* check whether the digital-mic has to be supported */
11446 for (i = 0; i < spec->input_mux->num_items; i++) {
11447 if (spec->input_mux->items[i].index >= 9)
11448 break;
11449 }
11450 if (i < spec->input_mux->num_items) {
11451 /* use only ADC0 */
11452 spec->adc_nids = alc262_dmic_adc_nids;
11453 spec->num_adc_nids = 1;
11454 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011455 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011456 /* all analog inputs */
11457 /* check whether NID 0x07 is valid */
11458 unsigned int wcap = get_wcaps(codec, 0x07);
11459
11460 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011461 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011462 if (wcap != AC_WID_AUD_IN) {
11463 spec->adc_nids = alc262_adc_nids_alt;
11464 spec->num_adc_nids =
11465 ARRAY_SIZE(alc262_adc_nids_alt);
11466 spec->capsrc_nids = alc262_capsrc_nids_alt;
11467 } else {
11468 spec->adc_nids = alc262_adc_nids;
11469 spec->num_adc_nids =
11470 ARRAY_SIZE(alc262_adc_nids);
11471 spec->capsrc_nids = alc262_capsrc_nids;
11472 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011473 }
11474 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011475 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011476 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011477 if (!spec->no_analog)
11478 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011479
Takashi Iwai2134ea42008-01-10 16:53:55 +010011480 spec->vmaster_nid = 0x0c;
11481
Kailang Yangdf694da2005-12-05 19:42:22 +010011482 codec->patch_ops = alc_patch_ops;
11483 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011484 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011485#ifdef CONFIG_SND_HDA_POWER_SAVE
11486 if (!spec->loopback.amplist)
11487 spec->loopback.amplist = alc262_loopbacks;
11488#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011489 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011490
Kailang Yangdf694da2005-12-05 19:42:22 +010011491 return 0;
11492}
11493
Kailang Yangdf694da2005-12-05 19:42:22 +010011494/*
Kailang Yanga361d842007-06-05 12:30:55 +020011495 * ALC268 channel source setting (2 channel)
11496 */
11497#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11498#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011499
Kailang Yanga361d842007-06-05 12:30:55 +020011500static hda_nid_t alc268_dac_nids[2] = {
11501 /* front, hp */
11502 0x02, 0x03
11503};
11504
11505static hda_nid_t alc268_adc_nids[2] = {
11506 /* ADC0-1 */
11507 0x08, 0x07
11508};
11509
11510static hda_nid_t alc268_adc_nids_alt[1] = {
11511 /* ADC0 */
11512 0x08
11513};
11514
Takashi Iwaie1406342008-02-11 18:32:32 +010011515static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11516
Kailang Yanga361d842007-06-05 12:30:55 +020011517static struct snd_kcontrol_new alc268_base_mixer[] = {
11518 /* output mixer control */
11519 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11520 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011523 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11524 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11525 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011526 { }
11527};
11528
Takashi Iwai42171c12009-05-08 14:11:43 +020011529static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11530 /* output mixer control */
11531 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11532 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11533 ALC262_HIPPO_MASTER_SWITCH,
11534 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11535 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11536 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11537 { }
11538};
11539
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011540/* bind Beep switches of both NID 0x0f and 0x10 */
11541static struct hda_bind_ctls alc268_bind_beep_sw = {
11542 .ops = &snd_hda_bind_sw,
11543 .values = {
11544 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11545 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11546 0
11547 },
11548};
11549
11550static struct snd_kcontrol_new alc268_beep_mixer[] = {
11551 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11552 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11553 { }
11554};
11555
Kailang Yangd1a991a2007-08-15 16:21:59 +020011556static struct hda_verb alc268_eapd_verbs[] = {
11557 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11558 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11559 { }
11560};
11561
Takashi Iwaid2738092007-08-16 14:59:45 +020011562/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011563static struct hda_verb alc268_toshiba_verbs[] = {
11564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11565 { } /* end */
11566};
11567
Kailang Yang8ef355d2008-08-26 13:10:22 +020011568static struct hda_input_mux alc268_acer_lc_capture_source = {
11569 .num_items = 2,
11570 .items = {
11571 { "i-Mic", 0x6 },
11572 { "E-Mic", 0x0 },
11573 },
11574};
11575
Takashi Iwaid2738092007-08-16 14:59:45 +020011576/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011577/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011578static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11579 .ops = &snd_hda_bind_vol,
11580 .values = {
11581 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11582 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11583 0
11584 },
11585};
11586
Takashi Iwai889c4392007-08-23 18:56:52 +020011587/* mute/unmute internal speaker according to the hp jack and mute state */
11588static void alc268_acer_automute(struct hda_codec *codec, int force)
11589{
11590 struct alc_spec *spec = codec->spec;
11591 unsigned int mute;
11592
11593 if (force || !spec->sense_updated) {
11594 unsigned int present;
11595 present = snd_hda_codec_read(codec, 0x14, 0,
11596 AC_VERB_GET_PIN_SENSE, 0);
11597 spec->jack_present = (present & 0x80000000) != 0;
11598 spec->sense_updated = 1;
11599 }
11600 if (spec->jack_present)
11601 mute = HDA_AMP_MUTE; /* mute internal speaker */
11602 else /* unmute internal speaker if necessary */
11603 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11605 HDA_AMP_MUTE, mute);
11606}
11607
11608
11609/* bind hp and internal speaker mute (with plug check) */
11610static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11611 struct snd_ctl_elem_value *ucontrol)
11612{
11613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11614 long *valp = ucontrol->value.integer.value;
11615 int change;
11616
Takashi Iwai8de56b72009-07-24 16:51:47 +020011617 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011618 if (change)
11619 alc268_acer_automute(codec, 0);
11620 return change;
11621}
Takashi Iwaid2738092007-08-16 14:59:45 +020011622
Kailang Yang8ef355d2008-08-26 13:10:22 +020011623static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11624 /* output mixer control */
11625 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11626 {
11627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11628 .name = "Master Playback Switch",
11629 .info = snd_hda_mixer_amp_switch_info,
11630 .get = snd_hda_mixer_amp_switch_get,
11631 .put = alc268_acer_master_sw_put,
11632 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11633 },
11634 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11635 { }
11636};
11637
Takashi Iwaid2738092007-08-16 14:59:45 +020011638static struct snd_kcontrol_new alc268_acer_mixer[] = {
11639 /* output mixer control */
11640 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11641 {
11642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11643 .name = "Master Playback Switch",
11644 .info = snd_hda_mixer_amp_switch_info,
11645 .get = snd_hda_mixer_amp_switch_get,
11646 .put = alc268_acer_master_sw_put,
11647 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11648 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011649 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11650 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11651 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011652 { }
11653};
11654
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011655static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11656 /* output mixer control */
11657 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11658 {
11659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11660 .name = "Master Playback Switch",
11661 .info = snd_hda_mixer_amp_switch_info,
11662 .get = snd_hda_mixer_amp_switch_get,
11663 .put = alc268_acer_master_sw_put,
11664 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11665 },
11666 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11667 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11668 { }
11669};
11670
Kailang Yang8ef355d2008-08-26 13:10:22 +020011671static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11672 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11673 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11675 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11676 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11678 { }
11679};
11680
Takashi Iwaid2738092007-08-16 14:59:45 +020011681static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011682 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11683 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011688 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11689 { }
11690};
11691
11692/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011693#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11694#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011695
11696static void alc268_acer_unsol_event(struct hda_codec *codec,
11697 unsigned int res)
11698{
Takashi Iwai889c4392007-08-23 18:56:52 +020011699 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011700 return;
11701 alc268_acer_automute(codec, 1);
11702}
11703
Takashi Iwai889c4392007-08-23 18:56:52 +020011704static void alc268_acer_init_hook(struct hda_codec *codec)
11705{
11706 alc268_acer_automute(codec, 1);
11707}
11708
Kailang Yang8ef355d2008-08-26 13:10:22 +020011709/* toggle speaker-output according to the hp-jack state */
11710static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11711{
11712 unsigned int present;
11713 unsigned char bits;
11714
11715 present = snd_hda_codec_read(codec, 0x15, 0,
11716 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11717 bits = present ? AMP_IN_MUTE(0) : 0;
11718 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11719 AMP_IN_MUTE(0), bits);
11720 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11721 AMP_IN_MUTE(0), bits);
11722}
11723
11724
11725static void alc268_acer_mic_automute(struct hda_codec *codec)
11726{
11727 unsigned int present;
11728
11729 present = snd_hda_codec_read(codec, 0x18, 0,
11730 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11731 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11732 present ? 0x0 : 0x6);
11733}
11734
11735static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11736 unsigned int res)
11737{
11738 if ((res >> 26) == ALC880_HP_EVENT)
11739 alc268_aspire_one_speaker_automute(codec);
11740 if ((res >> 26) == ALC880_MIC_EVENT)
11741 alc268_acer_mic_automute(codec);
11742}
11743
11744static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11745{
11746 alc268_aspire_one_speaker_automute(codec);
11747 alc268_acer_mic_automute(codec);
11748}
11749
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011750static struct snd_kcontrol_new alc268_dell_mixer[] = {
11751 /* output mixer control */
11752 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11753 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11754 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11757 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11758 { }
11759};
11760
11761static struct hda_verb alc268_dell_verbs[] = {
11762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11763 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11764 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11765 { }
11766};
11767
11768/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011769static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011771 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011772
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011773 spec->autocfg.hp_pins[0] = 0x15;
11774 spec->autocfg.speaker_pins[0] = 0x14;
11775 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011776}
11777
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011778static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11779 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11780 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11781 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11783 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11784 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11785 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11787 { }
11788};
11789
11790static struct hda_verb alc267_quanta_il1_verbs[] = {
11791 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11792 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11793 { }
11794};
11795
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011796static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11797{
11798 unsigned int present;
11799
11800 present = snd_hda_codec_read(codec, 0x18, 0,
11801 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11802 snd_hda_codec_write(codec, 0x23, 0,
11803 AC_VERB_SET_CONNECT_SEL,
11804 present ? 0x00 : 0x01);
11805}
11806
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011807static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011808{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011809 struct alc_spec *spec = codec->spec;
11810
11811 spec->autocfg.hp_pins[0] = 0x15;
11812 spec->autocfg.speaker_pins[0] = 0x14;
11813 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011814 alc267_quanta_il1_mic_automute(codec);
11815}
11816
11817static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11818 unsigned int res)
11819{
11820 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011821 case ALC880_MIC_EVENT:
11822 alc267_quanta_il1_mic_automute(codec);
11823 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011824 default:
11825 alc_sku_unsol_event(codec, res);
11826 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011827 }
11828}
11829
Kailang Yanga361d842007-06-05 12:30:55 +020011830/*
11831 * generic initialization of ADC, input mixers and output mixers
11832 */
11833static struct hda_verb alc268_base_init_verbs[] = {
11834 /* Unmute DAC0-1 and set vol = 0 */
11835 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011836 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011837
11838 /*
11839 * Set up output mixers (0x0c - 0x0e)
11840 */
11841 /* set vol=0 to output mixers */
11842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011843 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11844
11845 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11847
11848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11854 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11855 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11856
11857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11859 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11860 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011862
11863 /* set PCBEEP vol = 0, mute connections */
11864 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11865 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11866 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011867
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011868 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011869
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011870 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11872 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011874
Kailang Yanga361d842007-06-05 12:30:55 +020011875 { }
11876};
11877
11878/*
11879 * generic initialization of ADC, input mixers and output mixers
11880 */
11881static struct hda_verb alc268_volume_init_verbs[] = {
11882 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011883 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11884 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011885
11886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11888 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11890 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11891
Kailang Yanga361d842007-06-05 12:30:55 +020011892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11894 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11895
11896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011898
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011899 /* set PCBEEP vol = 0, mute connections */
11900 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11902 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011903
11904 { }
11905};
11906
Kailang Yanga361d842007-06-05 12:30:55 +020011907static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11908 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11909 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11910 {
11911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11912 /* The multiple "Capture Source" controls confuse alsamixer
11913 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011914 */
11915 /* .name = "Capture Source", */
11916 .name = "Input Source",
11917 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011918 .info = alc_mux_enum_info,
11919 .get = alc_mux_enum_get,
11920 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011921 },
11922 { } /* end */
11923};
11924
11925static struct snd_kcontrol_new alc268_capture_mixer[] = {
11926 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11927 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11928 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11929 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11930 {
11931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11932 /* The multiple "Capture Source" controls confuse alsamixer
11933 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011934 */
11935 /* .name = "Capture Source", */
11936 .name = "Input Source",
11937 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011938 .info = alc_mux_enum_info,
11939 .get = alc_mux_enum_get,
11940 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011941 },
11942 { } /* end */
11943};
11944
11945static struct hda_input_mux alc268_capture_source = {
11946 .num_items = 4,
11947 .items = {
11948 { "Mic", 0x0 },
11949 { "Front Mic", 0x1 },
11950 { "Line", 0x2 },
11951 { "CD", 0x3 },
11952 },
11953};
11954
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011955static struct hda_input_mux alc268_acer_capture_source = {
11956 .num_items = 3,
11957 .items = {
11958 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011959 { "Internal Mic", 0x1 },
11960 { "Line", 0x2 },
11961 },
11962};
11963
11964static struct hda_input_mux alc268_acer_dmic_capture_source = {
11965 .num_items = 3,
11966 .items = {
11967 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011968 { "Internal Mic", 0x6 },
11969 { "Line", 0x2 },
11970 },
11971};
11972
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011973#ifdef CONFIG_SND_DEBUG
11974static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011975 /* Volume widgets */
11976 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11977 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11978 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11979 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11980 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11981 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11982 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11983 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11984 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11985 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11986 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11987 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11988 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011989 /* The below appears problematic on some hardwares */
11990 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011991 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11992 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11993 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11994 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11995
11996 /* Modes for retasking pin widgets */
11997 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11998 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11999 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12000 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12001
12002 /* Controls for GPIO pins, assuming they are configured as outputs */
12003 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12004 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12005 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12006 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12007
12008 /* Switches to allow the digital SPDIF output pin to be enabled.
12009 * The ALC268 does not have an SPDIF input.
12010 */
12011 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12012
12013 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12014 * this output to turn on an external amplifier.
12015 */
12016 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12017 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12018
12019 { } /* end */
12020};
12021#endif
12022
Kailang Yanga361d842007-06-05 12:30:55 +020012023/* create input playback/capture controls for the given pin */
12024static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12025 const char *ctlname, int idx)
12026{
12027 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012028 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012029 int err;
12030
12031 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012032 switch (nid) {
12033 case 0x14:
12034 case 0x16:
12035 dac = 0x02;
12036 break;
12037 case 0x15:
12038 dac = 0x03;
12039 break;
12040 default:
12041 return 0;
12042 }
12043 if (spec->multiout.dac_nids[0] != dac &&
12044 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012045 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012046 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012047 HDA_OUTPUT));
12048 if (err < 0)
12049 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012050 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12051 }
12052
Kailang Yanga361d842007-06-05 12:30:55 +020012053 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012054 if (nid != 0x16)
12055 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012056 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012057 else /* mono */
12058 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12059 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012060 if (err < 0)
12061 return err;
12062 return 0;
12063}
12064
12065/* add playback controls from the parsed DAC table */
12066static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12067 const struct auto_pin_cfg *cfg)
12068{
12069 hda_nid_t nid;
12070 int err;
12071
Kailang Yanga361d842007-06-05 12:30:55 +020012072 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012073
12074 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012075 if (nid) {
12076 const char *name;
12077 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12078 name = "Speaker";
12079 else
12080 name = "Front";
12081 err = alc268_new_analog_output(spec, nid, name, 0);
12082 if (err < 0)
12083 return err;
12084 }
Kailang Yanga361d842007-06-05 12:30:55 +020012085
12086 nid = cfg->speaker_pins[0];
12087 if (nid == 0x1d) {
12088 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12089 "Speaker Playback Volume",
12090 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12091 if (err < 0)
12092 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012093 } else {
12094 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12095 if (err < 0)
12096 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012097 }
12098 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012099 if (nid) {
12100 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12101 if (err < 0)
12102 return err;
12103 }
Kailang Yanga361d842007-06-05 12:30:55 +020012104
12105 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12106 if (nid == 0x16) {
12107 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12108 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012109 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012110 if (err < 0)
12111 return err;
12112 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012113 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012114}
12115
12116/* create playback/capture controls for input pins */
12117static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12118 const struct auto_pin_cfg *cfg)
12119{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012120 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012121 int i, idx1;
12122
12123 for (i = 0; i < AUTO_PIN_LAST; i++) {
12124 switch(cfg->input_pins[i]) {
12125 case 0x18:
12126 idx1 = 0; /* Mic 1 */
12127 break;
12128 case 0x19:
12129 idx1 = 1; /* Mic 2 */
12130 break;
12131 case 0x1a:
12132 idx1 = 2; /* Line In */
12133 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012134 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012135 idx1 = 3; /* CD */
12136 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012137 case 0x12:
12138 case 0x13:
12139 idx1 = 6; /* digital mics */
12140 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012141 default:
12142 continue;
12143 }
12144 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12145 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012146 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012147 }
12148 return 0;
12149}
12150
12151static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12152{
12153 struct alc_spec *spec = codec->spec;
12154 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12155 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12156 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12157 unsigned int dac_vol1, dac_vol2;
12158
12159 if (speaker_nid) {
12160 snd_hda_codec_write(codec, speaker_nid, 0,
12161 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12162 snd_hda_codec_write(codec, 0x0f, 0,
12163 AC_VERB_SET_AMP_GAIN_MUTE,
12164 AMP_IN_UNMUTE(1));
12165 snd_hda_codec_write(codec, 0x10, 0,
12166 AC_VERB_SET_AMP_GAIN_MUTE,
12167 AMP_IN_UNMUTE(1));
12168 } else {
12169 snd_hda_codec_write(codec, 0x0f, 0,
12170 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12171 snd_hda_codec_write(codec, 0x10, 0,
12172 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12173 }
12174
12175 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012176 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012177 dac_vol2 = AMP_OUT_ZERO;
12178 else if (line_nid == 0x15)
12179 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012180 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012181 dac_vol2 = AMP_OUT_ZERO;
12182 else if (hp_nid == 0x15)
12183 dac_vol1 = AMP_OUT_ZERO;
12184 if (line_nid != 0x16 || hp_nid != 0x16 ||
12185 spec->autocfg.line_out_pins[1] != 0x16 ||
12186 spec->autocfg.line_out_pins[2] != 0x16)
12187 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12188
12189 snd_hda_codec_write(codec, 0x02, 0,
12190 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12191 snd_hda_codec_write(codec, 0x03, 0,
12192 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12193}
12194
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012195/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012196#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12197#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012198#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012199#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12200
12201/*
12202 * BIOS auto configuration
12203 */
12204static int alc268_parse_auto_config(struct hda_codec *codec)
12205{
12206 struct alc_spec *spec = codec->spec;
12207 int err;
12208 static hda_nid_t alc268_ignore[] = { 0 };
12209
12210 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12211 alc268_ignore);
12212 if (err < 0)
12213 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012214 if (!spec->autocfg.line_outs) {
12215 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12216 spec->multiout.max_channels = 2;
12217 spec->no_analog = 1;
12218 goto dig_only;
12219 }
Kailang Yanga361d842007-06-05 12:30:55 +020012220 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012221 }
Kailang Yanga361d842007-06-05 12:30:55 +020012222 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12223 if (err < 0)
12224 return err;
12225 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12226 if (err < 0)
12227 return err;
12228
12229 spec->multiout.max_channels = 2;
12230
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012231 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012232 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012233 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012234 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012235 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12236 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012237 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012238 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012239
Takashi Iwai892981f2009-03-02 08:04:35 +010012240 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012241 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012242
Takashi Iwaid88897e2008-10-31 15:01:37 +010012243 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012244 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012245 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012246
Takashi Iwai776e1842007-08-29 15:07:11 +020012247 err = alc_auto_add_mic_boost(codec);
12248 if (err < 0)
12249 return err;
12250
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012251 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12252
Kailang Yanga361d842007-06-05 12:30:55 +020012253 return 1;
12254}
12255
12256#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12257#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12258#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12259
12260/* init callback for auto-configuration model -- overriding the default init */
12261static void alc268_auto_init(struct hda_codec *codec)
12262{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012263 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012264 alc268_auto_init_multi_out(codec);
12265 alc268_auto_init_hp_out(codec);
12266 alc268_auto_init_mono_speaker_out(codec);
12267 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012268 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012269 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012270}
12271
12272/*
12273 * configuration and preset
12274 */
12275static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012276 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012277 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012278 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012279 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012280 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012281 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012282 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012283 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012284#ifdef CONFIG_SND_DEBUG
12285 [ALC268_TEST] = "test",
12286#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012287 [ALC268_AUTO] = "auto",
12288};
12289
12290static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012291 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012292 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012293 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012294 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012295 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012296 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12297 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012298 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012299 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012300 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12301 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012302 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012303 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12304 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12305 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012306 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012307 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012308 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012309 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012310 {}
12311};
12312
12313static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012314 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012315 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012316 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12317 alc267_quanta_il1_verbs },
12318 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12319 .dac_nids = alc268_dac_nids,
12320 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12321 .adc_nids = alc268_adc_nids_alt,
12322 .hp_nid = 0x03,
12323 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12324 .channel_mode = alc268_modes,
12325 .input_mux = &alc268_capture_source,
12326 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012327 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012328 },
Kailang Yanga361d842007-06-05 12:30:55 +020012329 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012330 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12331 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012332 .init_verbs = { alc268_base_init_verbs },
12333 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12334 .dac_nids = alc268_dac_nids,
12335 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12336 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012337 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012338 .hp_nid = 0x03,
12339 .dig_out_nid = ALC268_DIGOUT_NID,
12340 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12341 .channel_mode = alc268_modes,
12342 .input_mux = &alc268_capture_source,
12343 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012344 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012345 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012346 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012347 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12348 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012349 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12350 .dac_nids = alc268_dac_nids,
12351 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12352 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012353 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012354 .hp_nid = 0x03,
12355 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12356 .channel_mode = alc268_modes,
12357 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012358 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012359 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012360 },
12361 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012362 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12363 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012364 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12365 alc268_acer_verbs },
12366 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12367 .dac_nids = alc268_dac_nids,
12368 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12369 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012370 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012371 .hp_nid = 0x02,
12372 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12373 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012374 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012375 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012376 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012377 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012378 [ALC268_ACER_DMIC] = {
12379 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12380 alc268_beep_mixer },
12381 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12382 alc268_acer_verbs },
12383 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12384 .dac_nids = alc268_dac_nids,
12385 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12386 .adc_nids = alc268_adc_nids_alt,
12387 .capsrc_nids = alc268_capsrc_nids,
12388 .hp_nid = 0x02,
12389 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12390 .channel_mode = alc268_modes,
12391 .input_mux = &alc268_acer_dmic_capture_source,
12392 .unsol_event = alc268_acer_unsol_event,
12393 .init_hook = alc268_acer_init_hook,
12394 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012395 [ALC268_ACER_ASPIRE_ONE] = {
12396 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012397 alc268_beep_mixer,
12398 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012399 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12400 alc268_acer_aspire_one_verbs },
12401 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12402 .dac_nids = alc268_dac_nids,
12403 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12404 .adc_nids = alc268_adc_nids_alt,
12405 .capsrc_nids = alc268_capsrc_nids,
12406 .hp_nid = 0x03,
12407 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12408 .channel_mode = alc268_modes,
12409 .input_mux = &alc268_acer_lc_capture_source,
12410 .unsol_event = alc268_acer_lc_unsol_event,
12411 .init_hook = alc268_acer_lc_init_hook,
12412 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012413 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012414 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012415 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12416 alc268_dell_verbs },
12417 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12418 .dac_nids = alc268_dac_nids,
12419 .hp_nid = 0x02,
12420 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12421 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012422 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012423 .init_hook = alc268_dell_init_hook,
12424 .input_mux = &alc268_capture_source,
12425 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012426 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012427 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12428 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012429 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12430 alc268_toshiba_verbs },
12431 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12432 .dac_nids = alc268_dac_nids,
12433 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12434 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012435 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012436 .hp_nid = 0x03,
12437 .dig_out_nid = ALC268_DIGOUT_NID,
12438 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12439 .channel_mode = alc268_modes,
12440 .input_mux = &alc268_capture_source,
12441 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012442 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012443 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012444#ifdef CONFIG_SND_DEBUG
12445 [ALC268_TEST] = {
12446 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12447 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12448 alc268_volume_init_verbs },
12449 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12450 .dac_nids = alc268_dac_nids,
12451 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12452 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012453 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012454 .hp_nid = 0x03,
12455 .dig_out_nid = ALC268_DIGOUT_NID,
12456 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12457 .channel_mode = alc268_modes,
12458 .input_mux = &alc268_capture_source,
12459 },
12460#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012461};
12462
12463static int patch_alc268(struct hda_codec *codec)
12464{
12465 struct alc_spec *spec;
12466 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012467 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012468
12469 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12470 if (spec == NULL)
12471 return -ENOMEM;
12472
12473 codec->spec = spec;
12474
12475 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12476 alc268_models,
12477 alc268_cfg_tbl);
12478
12479 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012480 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12481 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012482 board_config = ALC268_AUTO;
12483 }
12484
12485 if (board_config == ALC268_AUTO) {
12486 /* automatic parse from the BIOS config */
12487 err = alc268_parse_auto_config(codec);
12488 if (err < 0) {
12489 alc_free(codec);
12490 return err;
12491 } else if (!err) {
12492 printk(KERN_INFO
12493 "hda_codec: Cannot set up configuration "
12494 "from BIOS. Using base mode...\n");
12495 board_config = ALC268_3ST;
12496 }
12497 }
12498
12499 if (board_config != ALC268_AUTO)
12500 setup_preset(spec, &alc268_presets[board_config]);
12501
Kailang Yanga361d842007-06-05 12:30:55 +020012502 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12503 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012504 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012505
Kailang Yanga361d842007-06-05 12:30:55 +020012506 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12507
Takashi Iwai22971e32009-02-10 11:56:44 +010012508 has_beep = 0;
12509 for (i = 0; i < spec->num_mixers; i++) {
12510 if (spec->mixers[i] == alc268_beep_mixer) {
12511 has_beep = 1;
12512 break;
12513 }
12514 }
12515
12516 if (has_beep) {
12517 err = snd_hda_attach_beep_device(codec, 0x1);
12518 if (err < 0) {
12519 alc_free(codec);
12520 return err;
12521 }
12522 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12523 /* override the amp caps for beep generator */
12524 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012525 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12526 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12527 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12528 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012529 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012530
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012531 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012532 /* check whether NID 0x07 is valid */
12533 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012534 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012535
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012536 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012537 wcap = get_wcaps_type(wcap);
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012538 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012539 spec->adc_nids = alc268_adc_nids_alt;
12540 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012541 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012542 } else {
12543 spec->adc_nids = alc268_adc_nids;
12544 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012545 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012546 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012547 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012548 /* set default input source */
12549 for (i = 0; i < spec->num_adc_nids; i++)
12550 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12551 0, AC_VERB_SET_CONNECT_SEL,
12552 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012553 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012554
12555 spec->vmaster_nid = 0x02;
12556
Kailang Yanga361d842007-06-05 12:30:55 +020012557 codec->patch_ops = alc_patch_ops;
12558 if (board_config == ALC268_AUTO)
12559 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012560
Takashi Iwaidaead532008-11-28 12:55:36 +010012561 codec->proc_widget_hook = print_realtek_coef;
12562
Kailang Yanga361d842007-06-05 12:30:55 +020012563 return 0;
12564}
12565
12566/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012567 * ALC269 channel source setting (2 channel)
12568 */
12569#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12570
12571#define alc269_dac_nids alc260_dac_nids
12572
12573static hda_nid_t alc269_adc_nids[1] = {
12574 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012575 0x08,
12576};
12577
Takashi Iwaie01bf502008-08-21 16:25:07 +020012578static hda_nid_t alc269_capsrc_nids[1] = {
12579 0x23,
12580};
12581
12582/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12583 * not a mux!
12584 */
12585
Kailang Yangf53281e2008-07-18 12:36:43 +020012586static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12587 .num_items = 2,
12588 .items = {
12589 { "i-Mic", 0x5 },
12590 { "e-Mic", 0x0 },
12591 },
12592};
12593
12594static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12595 .num_items = 2,
12596 .items = {
12597 { "i-Mic", 0x1 },
12598 { "e-Mic", 0x0 },
12599 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012600};
12601
12602#define alc269_modes alc260_modes
12603#define alc269_capture_source alc880_lg_lw_capture_source
12604
12605static struct snd_kcontrol_new alc269_base_mixer[] = {
12606 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12607 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12612 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12613 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12615 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12617 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12618 { } /* end */
12619};
12620
Kailang Yang60db6b52008-08-26 13:13:00 +020012621static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12622 /* output mixer control */
12623 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12624 {
12625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12626 .name = "Master Playback Switch",
12627 .info = snd_hda_mixer_amp_switch_info,
12628 .get = snd_hda_mixer_amp_switch_get,
12629 .put = alc268_acer_master_sw_put,
12630 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12631 },
12632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12635 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12636 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12637 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012638 { }
12639};
12640
Tony Vroon64154832008-11-06 15:08:49 +000012641static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12642 /* output mixer control */
12643 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12644 {
12645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12646 .name = "Master Playback Switch",
12647 .info = snd_hda_mixer_amp_switch_info,
12648 .get = snd_hda_mixer_amp_switch_get,
12649 .put = alc268_acer_master_sw_put,
12650 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12651 },
12652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12654 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12655 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12656 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12657 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12658 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12659 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12660 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012661 { }
12662};
12663
Kailang Yangf53281e2008-07-18 12:36:43 +020012664static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012665 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012666 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012668 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012669 { } /* end */
12670};
12671
Kailang Yangf6a92242007-12-13 16:52:54 +010012672/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012673static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12674 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12675 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012676 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12677 { } /* end */
12678};
12679
12680/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012681#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012682
Kailang Yang60db6b52008-08-26 13:13:00 +020012683static struct hda_verb alc269_quanta_fl1_verbs[] = {
12684 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12685 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12688 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12689 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12690 { }
12691};
12692
Tony Vroon64154832008-11-06 15:08:49 +000012693static struct hda_verb alc269_lifebook_verbs[] = {
12694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12695 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12696 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12698 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12700 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12701 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12702 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12703 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12704 { }
12705};
12706
Kailang Yang60db6b52008-08-26 13:13:00 +020012707/* toggle speaker-output according to the hp-jack state */
12708static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12709{
12710 unsigned int present;
12711 unsigned char bits;
12712
12713 present = snd_hda_codec_read(codec, 0x15, 0,
12714 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12715 bits = present ? AMP_IN_MUTE(0) : 0;
12716 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12717 AMP_IN_MUTE(0), bits);
12718 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12719 AMP_IN_MUTE(0), bits);
12720
12721 snd_hda_codec_write(codec, 0x20, 0,
12722 AC_VERB_SET_COEF_INDEX, 0x0c);
12723 snd_hda_codec_write(codec, 0x20, 0,
12724 AC_VERB_SET_PROC_COEF, 0x680);
12725
12726 snd_hda_codec_write(codec, 0x20, 0,
12727 AC_VERB_SET_COEF_INDEX, 0x0c);
12728 snd_hda_codec_write(codec, 0x20, 0,
12729 AC_VERB_SET_PROC_COEF, 0x480);
12730}
12731
Tony Vroon64154832008-11-06 15:08:49 +000012732/* toggle speaker-output according to the hp-jacks state */
12733static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12734{
12735 unsigned int present;
12736 unsigned char bits;
12737
12738 /* Check laptop headphone socket */
12739 present = snd_hda_codec_read(codec, 0x15, 0,
12740 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12741
12742 /* Check port replicator headphone socket */
12743 present |= snd_hda_codec_read(codec, 0x1a, 0,
12744 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12745
12746 bits = present ? AMP_IN_MUTE(0) : 0;
12747 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12748 AMP_IN_MUTE(0), bits);
12749 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12750 AMP_IN_MUTE(0), bits);
12751
12752 snd_hda_codec_write(codec, 0x20, 0,
12753 AC_VERB_SET_COEF_INDEX, 0x0c);
12754 snd_hda_codec_write(codec, 0x20, 0,
12755 AC_VERB_SET_PROC_COEF, 0x680);
12756
12757 snd_hda_codec_write(codec, 0x20, 0,
12758 AC_VERB_SET_COEF_INDEX, 0x0c);
12759 snd_hda_codec_write(codec, 0x20, 0,
12760 AC_VERB_SET_PROC_COEF, 0x480);
12761}
12762
Kailang Yang60db6b52008-08-26 13:13:00 +020012763static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12764{
12765 unsigned int present;
12766
12767 present = snd_hda_codec_read(codec, 0x18, 0,
12768 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12769 snd_hda_codec_write(codec, 0x23, 0,
12770 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12771}
12772
Tony Vroon64154832008-11-06 15:08:49 +000012773static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12774{
12775 unsigned int present_laptop;
12776 unsigned int present_dock;
12777
12778 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12779 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12780
12781 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12783
12784 /* Laptop mic port overrides dock mic port, design decision */
12785 if (present_dock)
12786 snd_hda_codec_write(codec, 0x23, 0,
12787 AC_VERB_SET_CONNECT_SEL, 0x3);
12788 if (present_laptop)
12789 snd_hda_codec_write(codec, 0x23, 0,
12790 AC_VERB_SET_CONNECT_SEL, 0x0);
12791 if (!present_dock && !present_laptop)
12792 snd_hda_codec_write(codec, 0x23, 0,
12793 AC_VERB_SET_CONNECT_SEL, 0x1);
12794}
12795
Kailang Yang60db6b52008-08-26 13:13:00 +020012796static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12797 unsigned int res)
12798{
12799 if ((res >> 26) == ALC880_HP_EVENT)
12800 alc269_quanta_fl1_speaker_automute(codec);
12801 if ((res >> 26) == ALC880_MIC_EVENT)
12802 alc269_quanta_fl1_mic_automute(codec);
12803}
12804
Tony Vroon64154832008-11-06 15:08:49 +000012805static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12806 unsigned int res)
12807{
12808 if ((res >> 26) == ALC880_HP_EVENT)
12809 alc269_lifebook_speaker_automute(codec);
12810 if ((res >> 26) == ALC880_MIC_EVENT)
12811 alc269_lifebook_mic_autoswitch(codec);
12812}
12813
Kailang Yang60db6b52008-08-26 13:13:00 +020012814static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12815{
12816 alc269_quanta_fl1_speaker_automute(codec);
12817 alc269_quanta_fl1_mic_automute(codec);
12818}
12819
Tony Vroon64154832008-11-06 15:08:49 +000012820static void alc269_lifebook_init_hook(struct hda_codec *codec)
12821{
12822 alc269_lifebook_speaker_automute(codec);
12823 alc269_lifebook_mic_autoswitch(codec);
12824}
12825
Kailang Yang60db6b52008-08-26 13:13:00 +020012826static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12828 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12829 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12831 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12832 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12833 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12834 {}
12835};
12836
12837static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12839 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12840 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12842 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12843 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12844 {}
12845};
12846
12847/* toggle speaker-output according to the hp-jack state */
12848static void alc269_speaker_automute(struct hda_codec *codec)
12849{
12850 unsigned int present;
12851 unsigned char bits;
12852
12853 present = snd_hda_codec_read(codec, 0x15, 0,
12854 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12855 bits = present ? AMP_IN_MUTE(0) : 0;
12856 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12857 AMP_IN_MUTE(0), bits);
12858 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12859 AMP_IN_MUTE(0), bits);
12860}
12861
12862static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12863{
12864 unsigned int present;
12865
12866 present = snd_hda_codec_read(codec, 0x18, 0,
12867 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12868 snd_hda_codec_write(codec, 0x23, 0,
12869 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12870}
12871
12872static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12873{
12874 unsigned int present;
12875
12876 present = snd_hda_codec_read(codec, 0x18, 0,
12877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12878 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12879 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12880 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12881 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12882}
12883
12884/* unsolicited event for HP jack sensing */
12885static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12886 unsigned int res)
12887{
12888 if ((res >> 26) == ALC880_HP_EVENT)
12889 alc269_speaker_automute(codec);
12890
12891 if ((res >> 26) == ALC880_MIC_EVENT)
12892 alc269_eeepc_dmic_automute(codec);
12893}
12894
12895static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12896{
12897 alc269_speaker_automute(codec);
12898 alc269_eeepc_dmic_automute(codec);
12899}
12900
12901/* unsolicited event for HP jack sensing */
12902static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12903 unsigned int res)
12904{
12905 if ((res >> 26) == ALC880_HP_EVENT)
12906 alc269_speaker_automute(codec);
12907
12908 if ((res >> 26) == ALC880_MIC_EVENT)
12909 alc269_eeepc_amic_automute(codec);
12910}
12911
12912static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12913{
12914 alc269_speaker_automute(codec);
12915 alc269_eeepc_amic_automute(codec);
12916}
12917
Kailang Yangf6a92242007-12-13 16:52:54 +010012918/*
12919 * generic initialization of ADC, input mixers and output mixers
12920 */
12921static struct hda_verb alc269_init_verbs[] = {
12922 /*
12923 * Unmute ADC0 and set the default input to mic-in
12924 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012925 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012926
12927 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12928 * analog-loopback mixer widget
12929 * Note: PASD motherboards uses the Line In 2 as the input for
12930 * front panel mic (mic 2)
12931 */
12932 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12938
12939 /*
12940 * Set up output mixers (0x0c - 0x0e)
12941 */
12942 /* set vol=0 to output mixers */
12943 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12944 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12945
12946 /* set up input amps for analog loopback */
12947 /* Amp Indices: DAC = 0, mixer = 1 */
12948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12954
12955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12958 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12962
12963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12967 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12968 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12969 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12970
12971 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12973
12974 /* FIXME: use matrix-type input source selection */
12975 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12976 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12980 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12981
12982 /* set EAPD */
12983 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12984 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12985 { }
12986};
12987
12988/* add playback controls from the parsed DAC table */
12989static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12990 const struct auto_pin_cfg *cfg)
12991{
12992 hda_nid_t nid;
12993 int err;
12994
12995 spec->multiout.num_dacs = 1; /* only use one dac */
12996 spec->multiout.dac_nids = spec->private_dac_nids;
12997 spec->multiout.dac_nids[0] = 2;
12998
12999 nid = cfg->line_out_pins[0];
13000 if (nid) {
13001 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13002 "Front Playback Volume",
13003 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13004 if (err < 0)
13005 return err;
13006 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13007 "Front Playback Switch",
13008 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13009 if (err < 0)
13010 return err;
13011 }
13012
13013 nid = cfg->speaker_pins[0];
13014 if (nid) {
13015 if (!cfg->line_out_pins[0]) {
13016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13017 "Speaker Playback Volume",
13018 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13019 HDA_OUTPUT));
13020 if (err < 0)
13021 return err;
13022 }
13023 if (nid == 0x16) {
13024 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13025 "Speaker Playback Switch",
13026 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13027 HDA_OUTPUT));
13028 if (err < 0)
13029 return err;
13030 } else {
13031 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13032 "Speaker Playback Switch",
13033 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13034 HDA_OUTPUT));
13035 if (err < 0)
13036 return err;
13037 }
13038 }
13039 nid = cfg->hp_pins[0];
13040 if (nid) {
13041 /* spec->multiout.hp_nid = 2; */
13042 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13043 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13044 "Headphone Playback Volume",
13045 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13046 HDA_OUTPUT));
13047 if (err < 0)
13048 return err;
13049 }
13050 if (nid == 0x16) {
13051 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13052 "Headphone Playback Switch",
13053 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13054 HDA_OUTPUT));
13055 if (err < 0)
13056 return err;
13057 } else {
13058 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13059 "Headphone Playback Switch",
13060 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13061 HDA_OUTPUT));
13062 if (err < 0)
13063 return err;
13064 }
13065 }
13066 return 0;
13067}
13068
Takashi Iwai8c927b42009-06-22 10:56:54 +020013069#define alc269_auto_create_analog_input_ctls \
13070 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013071
13072#ifdef CONFIG_SND_HDA_POWER_SAVE
13073#define alc269_loopbacks alc880_loopbacks
13074#endif
13075
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013076/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013077#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13078#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13079#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13080#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13081
Takashi Iwaif03d3112009-03-05 14:18:16 +010013082static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13083 .substreams = 1,
13084 .channels_min = 2,
13085 .channels_max = 8,
13086 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13087 /* NID is set in alc_build_pcms */
13088 .ops = {
13089 .open = alc880_playback_pcm_open,
13090 .prepare = alc880_playback_pcm_prepare,
13091 .cleanup = alc880_playback_pcm_cleanup
13092 },
13093};
13094
13095static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13096 .substreams = 1,
13097 .channels_min = 2,
13098 .channels_max = 2,
13099 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13100 /* NID is set in alc_build_pcms */
13101};
13102
Kailang Yangf6a92242007-12-13 16:52:54 +010013103/*
13104 * BIOS auto configuration
13105 */
13106static int alc269_parse_auto_config(struct hda_codec *codec)
13107{
13108 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013109 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013110 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13111
13112 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13113 alc269_ignore);
13114 if (err < 0)
13115 return err;
13116
13117 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13118 if (err < 0)
13119 return err;
13120 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13121 if (err < 0)
13122 return err;
13123
13124 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13125
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013126 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013127 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13128
Takashi Iwai603c4012008-07-30 15:01:44 +020013129 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013130 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013131
Takashi Iwaid88897e2008-10-31 15:01:37 +010013132 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013133 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013134 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013135 /* set default input source */
13136 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13137 0, AC_VERB_SET_CONNECT_SEL,
13138 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013139
13140 err = alc_auto_add_mic_boost(codec);
13141 if (err < 0)
13142 return err;
13143
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013144 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013145 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013146
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013147 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13148
Kailang Yangf6a92242007-12-13 16:52:54 +010013149 return 1;
13150}
13151
13152#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13153#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13154#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13155
13156
13157/* init callback for auto-configuration model -- overriding the default init */
13158static void alc269_auto_init(struct hda_codec *codec)
13159{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013160 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013161 alc269_auto_init_multi_out(codec);
13162 alc269_auto_init_hp_out(codec);
13163 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013164 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013165 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013166}
13167
13168/*
13169 * configuration and preset
13170 */
13171static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013172 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013173 [ALC269_QUANTA_FL1] = "quanta",
13174 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013175 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013176 [ALC269_FUJITSU] = "fujitsu",
13177 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013178};
13179
13180static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013181 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013182 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13183 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013184 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13185 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13186 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13187 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13188 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13189 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013190 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13191 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013192 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13193 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013194 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013195 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013196 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013197 {}
13198};
13199
13200static struct alc_config_preset alc269_presets[] = {
13201 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013202 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013203 .init_verbs = { alc269_init_verbs },
13204 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13205 .dac_nids = alc269_dac_nids,
13206 .hp_nid = 0x03,
13207 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13208 .channel_mode = alc269_modes,
13209 .input_mux = &alc269_capture_source,
13210 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013211 [ALC269_QUANTA_FL1] = {
13212 .mixers = { alc269_quanta_fl1_mixer },
13213 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13214 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13215 .dac_nids = alc269_dac_nids,
13216 .hp_nid = 0x03,
13217 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13218 .channel_mode = alc269_modes,
13219 .input_mux = &alc269_capture_source,
13220 .unsol_event = alc269_quanta_fl1_unsol_event,
13221 .init_hook = alc269_quanta_fl1_init_hook,
13222 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013223 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013224 .mixers = { alc269_eeepc_mixer },
13225 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013226 .init_verbs = { alc269_init_verbs,
13227 alc269_eeepc_amic_init_verbs },
13228 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13229 .dac_nids = alc269_dac_nids,
13230 .hp_nid = 0x03,
13231 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13232 .channel_mode = alc269_modes,
13233 .input_mux = &alc269_eeepc_amic_capture_source,
13234 .unsol_event = alc269_eeepc_amic_unsol_event,
13235 .init_hook = alc269_eeepc_amic_inithook,
13236 },
13237 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013238 .mixers = { alc269_eeepc_mixer },
13239 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013240 .init_verbs = { alc269_init_verbs,
13241 alc269_eeepc_dmic_init_verbs },
13242 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13243 .dac_nids = alc269_dac_nids,
13244 .hp_nid = 0x03,
13245 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13246 .channel_mode = alc269_modes,
13247 .input_mux = &alc269_eeepc_dmic_capture_source,
13248 .unsol_event = alc269_eeepc_dmic_unsol_event,
13249 .init_hook = alc269_eeepc_dmic_inithook,
13250 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013251 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013252 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013253 .cap_mixer = alc269_epc_capture_mixer,
13254 .init_verbs = { alc269_init_verbs,
13255 alc269_eeepc_dmic_init_verbs },
13256 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13257 .dac_nids = alc269_dac_nids,
13258 .hp_nid = 0x03,
13259 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13260 .channel_mode = alc269_modes,
13261 .input_mux = &alc269_eeepc_dmic_capture_source,
13262 .unsol_event = alc269_eeepc_dmic_unsol_event,
13263 .init_hook = alc269_eeepc_dmic_inithook,
13264 },
Tony Vroon64154832008-11-06 15:08:49 +000013265 [ALC269_LIFEBOOK] = {
13266 .mixers = { alc269_lifebook_mixer },
13267 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13268 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13269 .dac_nids = alc269_dac_nids,
13270 .hp_nid = 0x03,
13271 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13272 .channel_mode = alc269_modes,
13273 .input_mux = &alc269_capture_source,
13274 .unsol_event = alc269_lifebook_unsol_event,
13275 .init_hook = alc269_lifebook_init_hook,
13276 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013277};
13278
13279static int patch_alc269(struct hda_codec *codec)
13280{
13281 struct alc_spec *spec;
13282 int board_config;
13283 int err;
13284
13285 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13286 if (spec == NULL)
13287 return -ENOMEM;
13288
13289 codec->spec = spec;
13290
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013291 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13292
Kailang Yangf6a92242007-12-13 16:52:54 +010013293 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13294 alc269_models,
13295 alc269_cfg_tbl);
13296
13297 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013298 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13299 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013300 board_config = ALC269_AUTO;
13301 }
13302
13303 if (board_config == ALC269_AUTO) {
13304 /* automatic parse from the BIOS config */
13305 err = alc269_parse_auto_config(codec);
13306 if (err < 0) {
13307 alc_free(codec);
13308 return err;
13309 } else if (!err) {
13310 printk(KERN_INFO
13311 "hda_codec: Cannot set up configuration "
13312 "from BIOS. Using base mode...\n");
13313 board_config = ALC269_BASIC;
13314 }
13315 }
13316
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013317 err = snd_hda_attach_beep_device(codec, 0x1);
13318 if (err < 0) {
13319 alc_free(codec);
13320 return err;
13321 }
13322
Kailang Yangf6a92242007-12-13 16:52:54 +010013323 if (board_config != ALC269_AUTO)
13324 setup_preset(spec, &alc269_presets[board_config]);
13325
Takashi Iwaif03d3112009-03-05 14:18:16 +010013326 if (codec->subsystem_id == 0x17aa3bf8) {
13327 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13328 * fix the sample rate of analog I/O to 44.1kHz
13329 */
13330 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13331 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13332 } else {
13333 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13334 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13335 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013336 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13337 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13338
13339 spec->adc_nids = alc269_adc_nids;
13340 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013341 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013342 if (!spec->cap_mixer)
13343 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013344 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013345
13346 codec->patch_ops = alc_patch_ops;
13347 if (board_config == ALC269_AUTO)
13348 spec->init_hook = alc269_auto_init;
13349#ifdef CONFIG_SND_HDA_POWER_SAVE
13350 if (!spec->loopback.amplist)
13351 spec->loopback.amplist = alc269_loopbacks;
13352#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013353 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013354
13355 return 0;
13356}
13357
13358/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013359 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13360 */
13361
13362/*
13363 * set the path ways for 2 channel output
13364 * need to set the codec line out and mic 1 pin widgets to inputs
13365 */
13366static struct hda_verb alc861_threestack_ch2_init[] = {
13367 /* set pin widget 1Ah (line in) for input */
13368 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013369 /* set pin widget 18h (mic1/2) for input, for mic also enable
13370 * the vref
13371 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013372 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13373
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13375#if 0
13376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13378#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013379 { } /* end */
13380};
13381/*
13382 * 6ch mode
13383 * need to set the codec line out and mic 1 pin widgets to outputs
13384 */
13385static struct hda_verb alc861_threestack_ch6_init[] = {
13386 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13387 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13388 /* set pin widget 18h (mic1) for output (CLFE)*/
13389 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13390
13391 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013392 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013393
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013394 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13395#if 0
13396 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13397 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13398#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013399 { } /* end */
13400};
13401
13402static struct hda_channel_mode alc861_threestack_modes[2] = {
13403 { 2, alc861_threestack_ch2_init },
13404 { 6, alc861_threestack_ch6_init },
13405};
Takashi Iwai22309c32006-08-09 16:57:28 +020013406/* Set mic1 as input and unmute the mixer */
13407static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13408 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13409 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13410 { } /* end */
13411};
13412/* Set mic1 as output and mute mixer */
13413static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13416 { } /* end */
13417};
13418
13419static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13420 { 2, alc861_uniwill_m31_ch2_init },
13421 { 4, alc861_uniwill_m31_ch4_init },
13422};
Kailang Yangdf694da2005-12-05 19:42:22 +010013423
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013424/* Set mic1 and line-in as input and unmute the mixer */
13425static struct hda_verb alc861_asus_ch2_init[] = {
13426 /* set pin widget 1Ah (line in) for input */
13427 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013428 /* set pin widget 18h (mic1/2) for input, for mic also enable
13429 * the vref
13430 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013431 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13432
13433 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13434#if 0
13435 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13436 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13437#endif
13438 { } /* end */
13439};
13440/* Set mic1 nad line-in as output and mute mixer */
13441static struct hda_verb alc861_asus_ch6_init[] = {
13442 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13443 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13444 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13445 /* set pin widget 18h (mic1) for output (CLFE)*/
13446 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13447 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13448 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13449 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13450
13451 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13452#if 0
13453 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13454 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13455#endif
13456 { } /* end */
13457};
13458
13459static struct hda_channel_mode alc861_asus_modes[2] = {
13460 { 2, alc861_asus_ch2_init },
13461 { 6, alc861_asus_ch6_init },
13462};
13463
Kailang Yangdf694da2005-12-05 19:42:22 +010013464/* patch-ALC861 */
13465
13466static struct snd_kcontrol_new alc861_base_mixer[] = {
13467 /* output mixer control */
13468 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13469 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13470 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13471 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13472 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13473
13474 /*Input mixer control */
13475 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13476 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13477 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13478 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13479 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13480 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13482 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013485
Kailang Yangdf694da2005-12-05 19:42:22 +010013486 { } /* end */
13487};
13488
13489static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13490 /* output mixer control */
13491 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13492 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13493 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13494 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13495 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13496
13497 /* Input mixer control */
13498 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13499 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13500 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13501 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13502 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13503 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13505 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013508
Kailang Yangdf694da2005-12-05 19:42:22 +010013509 {
13510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13511 .name = "Channel Mode",
13512 .info = alc_ch_mode_info,
13513 .get = alc_ch_mode_get,
13514 .put = alc_ch_mode_put,
13515 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13516 },
13517 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013518};
13519
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013520static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013521 /* output mixer control */
13522 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13524 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013525
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013526 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013527};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013528
Takashi Iwai22309c32006-08-09 16:57:28 +020013529static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13530 /* output mixer control */
13531 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13532 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13533 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13534 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13535 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13536
13537 /* Input mixer control */
13538 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13539 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13540 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13541 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13542 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13543 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13545 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013548
Takashi Iwai22309c32006-08-09 16:57:28 +020013549 {
13550 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13551 .name = "Channel Mode",
13552 .info = alc_ch_mode_info,
13553 .get = alc_ch_mode_get,
13554 .put = alc_ch_mode_put,
13555 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13556 },
13557 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013558};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013559
13560static struct snd_kcontrol_new alc861_asus_mixer[] = {
13561 /* output mixer control */
13562 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13563 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13564 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13565 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13566 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13567
13568 /* Input mixer control */
13569 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13570 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13571 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13572 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13573 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13574 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13576 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13577 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13579
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013580 {
13581 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13582 .name = "Channel Mode",
13583 .info = alc_ch_mode_info,
13584 .get = alc_ch_mode_get,
13585 .put = alc_ch_mode_put,
13586 .private_value = ARRAY_SIZE(alc861_asus_modes),
13587 },
13588 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013589};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013590
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013591/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013592static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013593 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13594 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013595 { }
13596};
13597
Kailang Yangdf694da2005-12-05 19:42:22 +010013598/*
13599 * generic initialization of ADC, input mixers and output mixers
13600 */
13601static struct hda_verb alc861_base_init_verbs[] = {
13602 /*
13603 * Unmute ADC0 and set the default input to mic-in
13604 */
13605 /* port-A for surround (rear panel) */
13606 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13607 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13608 /* port-B for mic-in (rear panel) with vref */
13609 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13610 /* port-C for line-in (rear panel) */
13611 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13612 /* port-D for Front */
13613 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13614 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13615 /* port-E for HP out (front panel) */
13616 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13617 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013618 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013619 /* port-F for mic-in (front panel) with vref */
13620 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13621 /* port-G for CLFE (rear panel) */
13622 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13623 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13624 /* port-H for side (rear panel) */
13625 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13626 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13627 /* CD-in */
13628 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13629 /* route front mic to ADC1*/
13630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013632
Kailang Yangdf694da2005-12-05 19:42:22 +010013633 /* Unmute DAC0~3 & spdif out*/
13634 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13635 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13636 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13637 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013639
Kailang Yangdf694da2005-12-05 19:42:22 +010013640 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13641 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13642 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13643 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13644 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013645
Kailang Yangdf694da2005-12-05 19:42:22 +010013646 /* Unmute Stereo Mixer 15 */
13647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013651
13652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13655 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013660 /* hp used DAC 3 (Front) */
13661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13663
13664 { }
13665};
13666
13667static struct hda_verb alc861_threestack_init_verbs[] = {
13668 /*
13669 * Unmute ADC0 and set the default input to mic-in
13670 */
13671 /* port-A for surround (rear panel) */
13672 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13673 /* port-B for mic-in (rear panel) with vref */
13674 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13675 /* port-C for line-in (rear panel) */
13676 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13677 /* port-D for Front */
13678 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13679 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13680 /* port-E for HP out (front panel) */
13681 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13682 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013683 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013684 /* port-F for mic-in (front panel) with vref */
13685 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13686 /* port-G for CLFE (rear panel) */
13687 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13688 /* port-H for side (rear panel) */
13689 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13690 /* CD-in */
13691 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13692 /* route front mic to ADC1*/
13693 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13695 /* Unmute DAC0~3 & spdif out*/
13696 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13697 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13698 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13699 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013701
Kailang Yangdf694da2005-12-05 19:42:22 +010013702 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13703 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13704 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13705 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13706 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013707
Kailang Yangdf694da2005-12-05 19:42:22 +010013708 /* Unmute Stereo Mixer 15 */
13709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013713
13714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722 /* hp used DAC 3 (Front) */
13723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13725 { }
13726};
Takashi Iwai22309c32006-08-09 16:57:28 +020013727
13728static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13729 /*
13730 * Unmute ADC0 and set the default input to mic-in
13731 */
13732 /* port-A for surround (rear panel) */
13733 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13734 /* port-B for mic-in (rear panel) with vref */
13735 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13736 /* port-C for line-in (rear panel) */
13737 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13738 /* port-D for Front */
13739 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13740 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13741 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742 /* this has to be set to VREF80 */
13743 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013744 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013745 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013746 /* port-F for mic-in (front panel) with vref */
13747 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13748 /* port-G for CLFE (rear panel) */
13749 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13750 /* port-H for side (rear panel) */
13751 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13752 /* CD-in */
13753 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13754 /* route front mic to ADC1*/
13755 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13757 /* Unmute DAC0~3 & spdif out*/
13758 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13759 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13760 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13761 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013763
Takashi Iwai22309c32006-08-09 16:57:28 +020013764 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13765 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13766 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13767 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13768 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013769
Takashi Iwai22309c32006-08-09 16:57:28 +020013770 /* Unmute Stereo Mixer 15 */
13771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013775
13776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13777 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13778 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13779 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13781 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13782 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013784 /* hp used DAC 3 (Front) */
13785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13787 { }
13788};
13789
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013790static struct hda_verb alc861_asus_init_verbs[] = {
13791 /*
13792 * Unmute ADC0 and set the default input to mic-in
13793 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013794 /* port-A for surround (rear panel)
13795 * according to codec#0 this is the HP jack
13796 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013797 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13798 /* route front PCM to HP */
13799 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13800 /* port-B for mic-in (rear panel) with vref */
13801 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13802 /* port-C for line-in (rear panel) */
13803 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13804 /* port-D for Front */
13805 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13807 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013808 /* this has to be set to VREF80 */
13809 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013810 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013811 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013812 /* port-F for mic-in (front panel) with vref */
13813 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13814 /* port-G for CLFE (rear panel) */
13815 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13816 /* port-H for side (rear panel) */
13817 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13818 /* CD-in */
13819 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13820 /* route front mic to ADC1*/
13821 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13823 /* Unmute DAC0~3 & spdif out*/
13824 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13825 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13826 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13827 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13829 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13830 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13831 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13832 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13833 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013834
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013835 /* Unmute Stereo Mixer 15 */
13836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013840
13841 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13843 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13845 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13846 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013849 /* hp used DAC 3 (Front) */
13850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13852 { }
13853};
13854
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013855/* additional init verbs for ASUS laptops */
13856static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13857 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13859 { }
13860};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013861
Kailang Yangdf694da2005-12-05 19:42:22 +010013862/*
13863 * generic initialization of ADC, input mixers and output mixers
13864 */
13865static struct hda_verb alc861_auto_init_verbs[] = {
13866 /*
13867 * Unmute ADC0 and set the default input to mic-in
13868 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013869 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013870 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013871
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 /* Unmute DAC0~3 & spdif out*/
13873 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13874 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13875 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13876 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013878
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13880 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13881 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13882 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13883 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013884
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 /* Unmute Stereo Mixer 15 */
13886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13890
Takashi Iwai1c209302009-07-22 15:17:45 +020013891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13892 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13895 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13898 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013899
13900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013902 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13905 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013906 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13907 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013908
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013909 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013910
13911 { }
13912};
13913
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013914static struct hda_verb alc861_toshiba_init_verbs[] = {
13915 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013916
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013917 { }
13918};
13919
13920/* toggle speaker-output according to the hp-jack state */
13921static void alc861_toshiba_automute(struct hda_codec *codec)
13922{
13923 unsigned int present;
13924
13925 present = snd_hda_codec_read(codec, 0x0f, 0,
13926 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013927 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13928 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13929 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13930 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013931}
13932
13933static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13934 unsigned int res)
13935{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013936 if ((res >> 26) == ALC880_HP_EVENT)
13937 alc861_toshiba_automute(codec);
13938}
13939
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013940/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013941#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13942#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13943#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13944#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13945
13946
13947#define ALC861_DIGOUT_NID 0x07
13948
13949static struct hda_channel_mode alc861_8ch_modes[1] = {
13950 { 8, NULL }
13951};
13952
13953static hda_nid_t alc861_dac_nids[4] = {
13954 /* front, surround, clfe, side */
13955 0x03, 0x06, 0x05, 0x04
13956};
13957
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013958static hda_nid_t alc660_dac_nids[3] = {
13959 /* front, clfe, surround */
13960 0x03, 0x05, 0x06
13961};
13962
Kailang Yangdf694da2005-12-05 19:42:22 +010013963static hda_nid_t alc861_adc_nids[1] = {
13964 /* ADC0-2 */
13965 0x08,
13966};
13967
13968static struct hda_input_mux alc861_capture_source = {
13969 .num_items = 5,
13970 .items = {
13971 { "Mic", 0x0 },
13972 { "Front Mic", 0x3 },
13973 { "Line", 0x1 },
13974 { "CD", 0x4 },
13975 { "Mixer", 0x5 },
13976 },
13977};
13978
Takashi Iwai1c209302009-07-22 15:17:45 +020013979static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
13980{
13981 struct alc_spec *spec = codec->spec;
13982 hda_nid_t mix, srcs[5];
13983 int i, j, num;
13984
13985 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
13986 return 0;
13987 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
13988 if (num < 0)
13989 return 0;
13990 for (i = 0; i < num; i++) {
13991 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020013992 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020013993 if (type != AC_WID_AUD_OUT)
13994 continue;
13995 for (j = 0; j < spec->multiout.num_dacs; j++)
13996 if (spec->multiout.dac_nids[j] == srcs[i])
13997 break;
13998 if (j >= spec->multiout.num_dacs)
13999 return srcs[i];
14000 }
14001 return 0;
14002}
14003
Kailang Yangdf694da2005-12-05 19:42:22 +010014004/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014005static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014006 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014007{
Takashi Iwai1c209302009-07-22 15:17:45 +020014008 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014009 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014010 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014011
14012 spec->multiout.dac_nids = spec->private_dac_nids;
14013 for (i = 0; i < cfg->line_outs; i++) {
14014 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014015 dac = alc861_look_for_dac(codec, nid);
14016 if (!dac)
14017 continue;
14018 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014019 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014020 return 0;
14021}
14022
Takashi Iwai1c209302009-07-22 15:17:45 +020014023static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14024 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014025{
14026 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014027 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14028 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14029 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14030}
14031
14032/* add playback controls from the parsed DAC table */
14033static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14034 const struct auto_pin_cfg *cfg)
14035{
14036 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014037 static const char *chname[4] = {
14038 "Front", "Surround", NULL /*CLFE*/, "Side"
14039 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014040 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014041 int i, err;
14042
14043 if (cfg->line_outs == 1) {
14044 const char *pfx = NULL;
14045 if (!cfg->hp_outs)
14046 pfx = "Master";
14047 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14048 pfx = "Speaker";
14049 if (pfx) {
14050 nid = spec->multiout.dac_nids[0];
14051 return alc861_create_out_sw(codec, pfx, nid, 3);
14052 }
14053 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014054
14055 for (i = 0; i < cfg->line_outs; i++) {
14056 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014057 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014058 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014059 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014060 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014061 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014062 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014063 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014064 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014065 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014066 return err;
14067 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014068 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014069 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014070 return err;
14071 }
14072 }
14073 return 0;
14074}
14075
Takashi Iwai1c209302009-07-22 15:17:45 +020014076static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014077{
Takashi Iwai1c209302009-07-22 15:17:45 +020014078 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014079 int err;
14080 hda_nid_t nid;
14081
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014083 return 0;
14084
14085 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014086 nid = alc861_look_for_dac(codec, pin);
14087 if (nid) {
14088 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14089 if (err < 0)
14090 return err;
14091 spec->multiout.hp_nid = nid;
14092 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014093 }
14094 return 0;
14095}
14096
14097/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014098static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014099 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014100{
Takashi Iwai1c209302009-07-22 15:17:45 +020014101 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014102 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 int i, err, idx, idx1;
14104
14105 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014106 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014107 case 0x0c:
14108 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014109 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014110 break;
14111 case 0x0f:
14112 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014113 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014114 break;
14115 case 0x0d:
14116 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014117 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014118 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014119 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014120 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014121 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014122 break;
14123 case 0x11:
14124 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014125 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014126 break;
14127 default:
14128 continue;
14129 }
14130
Takashi Iwai4a471b72005-12-07 13:56:29 +010014131 err = new_analog_input(spec, cfg->input_pins[i],
14132 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014133 if (err < 0)
14134 return err;
14135
Takashi Iwai4a471b72005-12-07 13:56:29 +010014136 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014137 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014138 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014139 }
14140 return 0;
14141}
14142
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014143static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14144 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014145 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014146{
Takashi Iwai1c209302009-07-22 15:17:45 +020014147 hda_nid_t mix, srcs[5];
14148 int i, num;
14149
Jacek Luczak564c5be2008-05-03 18:41:23 +020014150 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14151 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014152 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014153 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014154 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14155 return;
14156 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14157 if (num < 0)
14158 return;
14159 for (i = 0; i < num; i++) {
14160 unsigned int mute;
14161 if (srcs[i] == dac || srcs[i] == 0x15)
14162 mute = AMP_IN_UNMUTE(i);
14163 else
14164 mute = AMP_IN_MUTE(i);
14165 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14166 mute);
14167 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014168}
14169
14170static void alc861_auto_init_multi_out(struct hda_codec *codec)
14171{
14172 struct alc_spec *spec = codec->spec;
14173 int i;
14174
14175 for (i = 0; i < spec->autocfg.line_outs; i++) {
14176 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014177 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014178 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014179 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014180 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014181 }
14182}
14183
14184static void alc861_auto_init_hp_out(struct hda_codec *codec)
14185{
14186 struct alc_spec *spec = codec->spec;
14187 hda_nid_t pin;
14188
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014189 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014190 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014191 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014192 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014193 pin = spec->autocfg.speaker_pins[0];
14194 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014195 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14196 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014197}
14198
14199static void alc861_auto_init_analog_input(struct hda_codec *codec)
14200{
14201 struct alc_spec *spec = codec->spec;
14202 int i;
14203
14204 for (i = 0; i < AUTO_PIN_LAST; i++) {
14205 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014206 if (nid >= 0x0c && nid <= 0x11)
14207 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014208 }
14209}
14210
14211/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212/* return 1 if successful, 0 if the proper config is not found,
14213 * or a negative error code
14214 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014215static int alc861_parse_auto_config(struct hda_codec *codec)
14216{
14217 struct alc_spec *spec = codec->spec;
14218 int err;
14219 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014221 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14222 alc861_ignore);
14223 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014224 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014225 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 return 0; /* can't find valid BIOS pin config */
14227
Takashi Iwai1c209302009-07-22 15:17:45 +020014228 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014229 if (err < 0)
14230 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014231 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014232 if (err < 0)
14233 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014234 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
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_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 return err;
14240
14241 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14242
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014243 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014244 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14245
Takashi Iwai603c4012008-07-30 15:01:44 +020014246 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014247 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014248
Takashi Iwaid88897e2008-10-31 15:01:37 +010014249 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014250
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014251 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014252 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014253
14254 spec->adc_nids = alc861_adc_nids;
14255 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014256 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014257
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014258 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14259
Kailang Yangdf694da2005-12-05 19:42:22 +010014260 return 1;
14261}
14262
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014263/* additional initialization for auto-configuration model */
14264static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014265{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014266 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014267 alc861_auto_init_multi_out(codec);
14268 alc861_auto_init_hp_out(codec);
14269 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014270 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014271 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014272}
14273
Takashi Iwaicb53c622007-08-10 17:21:45 +020014274#ifdef CONFIG_SND_HDA_POWER_SAVE
14275static struct hda_amp_list alc861_loopbacks[] = {
14276 { 0x15, HDA_INPUT, 0 },
14277 { 0x15, HDA_INPUT, 1 },
14278 { 0x15, HDA_INPUT, 2 },
14279 { 0x15, HDA_INPUT, 3 },
14280 { } /* end */
14281};
14282#endif
14283
Kailang Yangdf694da2005-12-05 19:42:22 +010014284
14285/*
14286 * configuration and preset
14287 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014288static const char *alc861_models[ALC861_MODEL_LAST] = {
14289 [ALC861_3ST] = "3stack",
14290 [ALC660_3ST] = "3stack-660",
14291 [ALC861_3ST_DIG] = "3stack-dig",
14292 [ALC861_6ST_DIG] = "6stack-dig",
14293 [ALC861_UNIWILL_M31] = "uniwill-m31",
14294 [ALC861_TOSHIBA] = "toshiba",
14295 [ALC861_ASUS] = "asus",
14296 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14297 [ALC861_AUTO] = "auto",
14298};
14299
14300static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014301 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014302 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14303 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14304 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014305 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014306 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014307 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014308 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14309 * Any other models that need this preset?
14310 */
14311 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014312 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14313 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014314 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14315 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14316 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14317 /* FIXME: the below seems conflict */
14318 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14319 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14320 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014321 {}
14322};
14323
14324static struct alc_config_preset alc861_presets[] = {
14325 [ALC861_3ST] = {
14326 .mixers = { alc861_3ST_mixer },
14327 .init_verbs = { alc861_threestack_init_verbs },
14328 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14329 .dac_nids = alc861_dac_nids,
14330 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14331 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014332 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014333 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14334 .adc_nids = alc861_adc_nids,
14335 .input_mux = &alc861_capture_source,
14336 },
14337 [ALC861_3ST_DIG] = {
14338 .mixers = { alc861_base_mixer },
14339 .init_verbs = { alc861_threestack_init_verbs },
14340 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14341 .dac_nids = alc861_dac_nids,
14342 .dig_out_nid = ALC861_DIGOUT_NID,
14343 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14344 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014345 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014346 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14347 .adc_nids = alc861_adc_nids,
14348 .input_mux = &alc861_capture_source,
14349 },
14350 [ALC861_6ST_DIG] = {
14351 .mixers = { alc861_base_mixer },
14352 .init_verbs = { alc861_base_init_verbs },
14353 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14354 .dac_nids = alc861_dac_nids,
14355 .dig_out_nid = ALC861_DIGOUT_NID,
14356 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14357 .channel_mode = alc861_8ch_modes,
14358 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14359 .adc_nids = alc861_adc_nids,
14360 .input_mux = &alc861_capture_source,
14361 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014362 [ALC660_3ST] = {
14363 .mixers = { alc861_3ST_mixer },
14364 .init_verbs = { alc861_threestack_init_verbs },
14365 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14366 .dac_nids = alc660_dac_nids,
14367 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14368 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014369 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014370 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14371 .adc_nids = alc861_adc_nids,
14372 .input_mux = &alc861_capture_source,
14373 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014374 [ALC861_UNIWILL_M31] = {
14375 .mixers = { alc861_uniwill_m31_mixer },
14376 .init_verbs = { alc861_uniwill_m31_init_verbs },
14377 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14378 .dac_nids = alc861_dac_nids,
14379 .dig_out_nid = ALC861_DIGOUT_NID,
14380 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14381 .channel_mode = alc861_uniwill_m31_modes,
14382 .need_dac_fix = 1,
14383 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14384 .adc_nids = alc861_adc_nids,
14385 .input_mux = &alc861_capture_source,
14386 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014387 [ALC861_TOSHIBA] = {
14388 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014389 .init_verbs = { alc861_base_init_verbs,
14390 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014391 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14392 .dac_nids = alc861_dac_nids,
14393 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14394 .channel_mode = alc883_3ST_2ch_modes,
14395 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14396 .adc_nids = alc861_adc_nids,
14397 .input_mux = &alc861_capture_source,
14398 .unsol_event = alc861_toshiba_unsol_event,
14399 .init_hook = alc861_toshiba_automute,
14400 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014401 [ALC861_ASUS] = {
14402 .mixers = { alc861_asus_mixer },
14403 .init_verbs = { alc861_asus_init_verbs },
14404 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14405 .dac_nids = alc861_dac_nids,
14406 .dig_out_nid = ALC861_DIGOUT_NID,
14407 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14408 .channel_mode = alc861_asus_modes,
14409 .need_dac_fix = 1,
14410 .hp_nid = 0x06,
14411 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14412 .adc_nids = alc861_adc_nids,
14413 .input_mux = &alc861_capture_source,
14414 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014415 [ALC861_ASUS_LAPTOP] = {
14416 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14417 .init_verbs = { alc861_asus_init_verbs,
14418 alc861_asus_laptop_init_verbs },
14419 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14420 .dac_nids = alc861_dac_nids,
14421 .dig_out_nid = ALC861_DIGOUT_NID,
14422 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14423 .channel_mode = alc883_3ST_2ch_modes,
14424 .need_dac_fix = 1,
14425 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14426 .adc_nids = alc861_adc_nids,
14427 .input_mux = &alc861_capture_source,
14428 },
14429};
Kailang Yangdf694da2005-12-05 19:42:22 +010014430
14431
14432static int patch_alc861(struct hda_codec *codec)
14433{
14434 struct alc_spec *spec;
14435 int board_config;
14436 int err;
14437
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014438 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014439 if (spec == NULL)
14440 return -ENOMEM;
14441
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014442 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014443
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014444 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14445 alc861_models,
14446 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014447
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014448 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014449 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14450 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014451 board_config = ALC861_AUTO;
14452 }
14453
14454 if (board_config == ALC861_AUTO) {
14455 /* automatic parse from the BIOS config */
14456 err = alc861_parse_auto_config(codec);
14457 if (err < 0) {
14458 alc_free(codec);
14459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014460 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014461 printk(KERN_INFO
14462 "hda_codec: Cannot set up configuration "
14463 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 board_config = ALC861_3ST_DIG;
14465 }
14466 }
14467
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014468 err = snd_hda_attach_beep_device(codec, 0x23);
14469 if (err < 0) {
14470 alc_free(codec);
14471 return err;
14472 }
14473
Kailang Yangdf694da2005-12-05 19:42:22 +010014474 if (board_config != ALC861_AUTO)
14475 setup_preset(spec, &alc861_presets[board_config]);
14476
Kailang Yangdf694da2005-12-05 19:42:22 +010014477 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14478 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14479
Kailang Yangdf694da2005-12-05 19:42:22 +010014480 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14481 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14482
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014483 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14484
Takashi Iwai2134ea42008-01-10 16:53:55 +010014485 spec->vmaster_nid = 0x03;
14486
Kailang Yangdf694da2005-12-05 19:42:22 +010014487 codec->patch_ops = alc_patch_ops;
14488 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014489 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014490#ifdef CONFIG_SND_HDA_POWER_SAVE
14491 if (!spec->loopback.amplist)
14492 spec->loopback.amplist = alc861_loopbacks;
14493#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014494 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014495
Kailang Yangdf694da2005-12-05 19:42:22 +010014496 return 0;
14497}
14498
14499/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014500 * ALC861-VD support
14501 *
14502 * Based on ALC882
14503 *
14504 * In addition, an independent DAC
14505 */
14506#define ALC861VD_DIGOUT_NID 0x06
14507
14508static hda_nid_t alc861vd_dac_nids[4] = {
14509 /* front, surr, clfe, side surr */
14510 0x02, 0x03, 0x04, 0x05
14511};
14512
14513/* dac_nids for ALC660vd are in a different order - according to
14514 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014515 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014516 * of ALC660vd codecs, but for now there is only 3stack mixer
14517 * - and it is the same as in 861vd.
14518 * adc_nids in ALC660vd are (is) the same as in 861vd
14519 */
14520static hda_nid_t alc660vd_dac_nids[3] = {
14521 /* front, rear, clfe, rear_surr */
14522 0x02, 0x04, 0x03
14523};
14524
14525static hda_nid_t alc861vd_adc_nids[1] = {
14526 /* ADC0 */
14527 0x09,
14528};
14529
Takashi Iwaie1406342008-02-11 18:32:32 +010014530static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14531
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014532/* input MUX */
14533/* FIXME: should be a matrix-type input source selection */
14534static struct hda_input_mux alc861vd_capture_source = {
14535 .num_items = 4,
14536 .items = {
14537 { "Mic", 0x0 },
14538 { "Front Mic", 0x1 },
14539 { "Line", 0x2 },
14540 { "CD", 0x4 },
14541 },
14542};
14543
Kailang Yang272a5272007-05-14 11:00:38 +020014544static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014545 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014546 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014547 { "Ext Mic", 0x0 },
14548 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014549 },
14550};
14551
Kailang Yangd1a991a2007-08-15 16:21:59 +020014552static struct hda_input_mux alc861vd_hp_capture_source = {
14553 .num_items = 2,
14554 .items = {
14555 { "Front Mic", 0x0 },
14556 { "ATAPI Mic", 0x1 },
14557 },
14558};
14559
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014560/*
14561 * 2ch mode
14562 */
14563static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14564 { 2, NULL }
14565};
14566
14567/*
14568 * 6ch mode
14569 */
14570static struct hda_verb alc861vd_6stack_ch6_init[] = {
14571 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14572 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14573 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14574 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14575 { } /* end */
14576};
14577
14578/*
14579 * 8ch mode
14580 */
14581static struct hda_verb alc861vd_6stack_ch8_init[] = {
14582 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14583 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14584 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14585 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14586 { } /* end */
14587};
14588
14589static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14590 { 6, alc861vd_6stack_ch6_init },
14591 { 8, alc861vd_6stack_ch8_init },
14592};
14593
14594static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14595 {
14596 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14597 .name = "Channel Mode",
14598 .info = alc_ch_mode_info,
14599 .get = alc_ch_mode_get,
14600 .put = alc_ch_mode_put,
14601 },
14602 { } /* end */
14603};
14604
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014605/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14606 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14607 */
14608static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14609 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14610 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14611
14612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14613 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14614
14615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14616 HDA_OUTPUT),
14617 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14618 HDA_OUTPUT),
14619 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14620 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14621
14622 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14623 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14624
14625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14626
14627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14630
14631 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14632 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14633 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14634
14635 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14636 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14637
14638 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14639 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14640
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014641 { } /* end */
14642};
14643
14644static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14645 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14647
14648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14649
14650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14653
14654 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14655 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14656 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14657
14658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14660
14661 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14662 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14663
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014664 { } /* end */
14665};
14666
Kailang Yangbdd148a2007-05-08 15:19:08 +020014667static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14668 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14669 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14670 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14671
14672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14673
14674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14676 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14677
14678 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14681
14682 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14683 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14684
14685 { } /* end */
14686};
14687
Tobin Davisb419f342008-03-07 11:57:51 +010014688/* Pin assignment: Speaker=0x14, HP = 0x15,
14689 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014690 */
14691static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014692 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14693 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14695 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014696 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14697 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14698 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14699 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14700 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14701 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014702 { } /* end */
14703};
14704
Kailang Yangd1a991a2007-08-15 16:21:59 +020014705/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14706 * Front Mic=0x18, ATAPI Mic = 0x19,
14707 */
14708static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14709 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14710 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14712 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14713 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14714 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14715 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14716 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014717
Kailang Yangd1a991a2007-08-15 16:21:59 +020014718 { } /* end */
14719};
14720
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014721/*
14722 * generic initialization of ADC, input mixers and output mixers
14723 */
14724static struct hda_verb alc861vd_volume_init_verbs[] = {
14725 /*
14726 * Unmute ADC0 and set the default input to mic-in
14727 */
14728 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14730
14731 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14732 * the analog-loopback mixer widget
14733 */
14734 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014740
14741 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746
14747 /*
14748 * Set up output mixers (0x02 - 0x05)
14749 */
14750 /* set vol=0 to output mixers */
14751 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14752 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14753 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14754 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14755
14756 /* set up input amps for analog loopback */
14757 /* Amp Indices: DAC = 0, mixer = 1 */
14758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14766
14767 { }
14768};
14769
14770/*
14771 * 3-stack pin configuration:
14772 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14773 */
14774static struct hda_verb alc861vd_3stack_init_verbs[] = {
14775 /*
14776 * Set pin mode and muting
14777 */
14778 /* set front pin widgets 0x14 for output */
14779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14780 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14781 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14782
14783 /* Mic (rear) pin: input vref at 80% */
14784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14785 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14786 /* Front Mic pin: input vref at 80% */
14787 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14789 /* Line In pin: input */
14790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14792 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14793 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14794 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14795 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14796 /* CD pin widget for input */
14797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14798
14799 { }
14800};
14801
14802/*
14803 * 6-stack pin configuration:
14804 */
14805static struct hda_verb alc861vd_6stack_init_verbs[] = {
14806 /*
14807 * Set pin mode and muting
14808 */
14809 /* set front pin widgets 0x14 for output */
14810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14812 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14813
14814 /* Rear Pin: output 1 (0x0d) */
14815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14818 /* CLFE Pin: output 2 (0x0e) */
14819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14821 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14822 /* Side Pin: output 3 (0x0f) */
14823 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14825 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14826
14827 /* Mic (rear) pin: input vref at 80% */
14828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14830 /* Front Mic pin: input vref at 80% */
14831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14833 /* Line In pin: input */
14834 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14836 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14837 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14838 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14839 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14840 /* CD pin widget for input */
14841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14842
14843 { }
14844};
14845
Kailang Yangbdd148a2007-05-08 15:19:08 +020014846static struct hda_verb alc861vd_eapd_verbs[] = {
14847 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14848 { }
14849};
14850
Kailang Yangf9423e72008-05-27 12:32:25 +020014851static struct hda_verb alc660vd_eapd_verbs[] = {
14852 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14853 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14854 { }
14855};
14856
Kailang Yangbdd148a2007-05-08 15:19:08 +020014857static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14861 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014863 {}
14864};
14865
Kailang Yangbdd148a2007-05-08 15:19:08 +020014866static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14867{
14868 unsigned int present;
14869 unsigned char bits;
14870
14871 present = snd_hda_codec_read(codec, 0x18, 0,
14872 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014873 bits = present ? HDA_AMP_MUTE : 0;
14874 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14875 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014876}
14877
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014878static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014879{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014880 struct alc_spec *spec = codec->spec;
14881
14882 spec->autocfg.hp_pins[0] = 0x1b;
14883 spec->autocfg.speaker_pins[0] = 0x14;
14884 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014885 alc861vd_lenovo_mic_automute(codec);
14886}
14887
14888static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14889 unsigned int res)
14890{
14891 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014892 case ALC880_MIC_EVENT:
14893 alc861vd_lenovo_mic_automute(codec);
14894 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014895 default:
14896 alc_automute_amp_unsol_event(codec, res);
14897 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014898 }
14899}
14900
Kailang Yang272a5272007-05-14 11:00:38 +020014901static struct hda_verb alc861vd_dallas_verbs[] = {
14902 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14903 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14904 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14905 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14906
14907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14912 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14913 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14914 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014915
Kailang Yang272a5272007-05-14 11:00:38 +020014916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14922 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14924
14925 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14927 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14931 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14932 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14933
14934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14938
14939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014940 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014941 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14942
14943 { } /* end */
14944};
14945
14946/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014947static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014948{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014949 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014950
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014951 spec->autocfg.hp_pins[0] = 0x15;
14952 spec->autocfg.speaker_pins[0] = 0x14;
14953 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014954}
14955
Takashi Iwaicb53c622007-08-10 17:21:45 +020014956#ifdef CONFIG_SND_HDA_POWER_SAVE
14957#define alc861vd_loopbacks alc880_loopbacks
14958#endif
14959
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014960/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014961#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14962#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14963#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14964#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14965
14966/*
14967 * configuration and preset
14968 */
14969static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14970 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014971 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014972 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014973 [ALC861VD_3ST] = "3stack",
14974 [ALC861VD_3ST_DIG] = "3stack-digout",
14975 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014976 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014977 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014978 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014979 [ALC861VD_AUTO] = "auto",
14980};
14981
14982static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014983 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14984 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014985 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014986 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014987 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014988 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014989 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014990 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014991 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014992 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014993 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014994 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014995 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014996 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014997 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014998 {}
14999};
15000
15001static struct alc_config_preset alc861vd_presets[] = {
15002 [ALC660VD_3ST] = {
15003 .mixers = { alc861vd_3st_mixer },
15004 .init_verbs = { alc861vd_volume_init_verbs,
15005 alc861vd_3stack_init_verbs },
15006 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15007 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015008 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15009 .channel_mode = alc861vd_3stack_2ch_modes,
15010 .input_mux = &alc861vd_capture_source,
15011 },
Mike Crash6963f842007-06-25 12:12:51 +020015012 [ALC660VD_3ST_DIG] = {
15013 .mixers = { alc861vd_3st_mixer },
15014 .init_verbs = { alc861vd_volume_init_verbs,
15015 alc861vd_3stack_init_verbs },
15016 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15017 .dac_nids = alc660vd_dac_nids,
15018 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015019 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15020 .channel_mode = alc861vd_3stack_2ch_modes,
15021 .input_mux = &alc861vd_capture_source,
15022 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015023 [ALC861VD_3ST] = {
15024 .mixers = { alc861vd_3st_mixer },
15025 .init_verbs = { alc861vd_volume_init_verbs,
15026 alc861vd_3stack_init_verbs },
15027 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15028 .dac_nids = alc861vd_dac_nids,
15029 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15030 .channel_mode = alc861vd_3stack_2ch_modes,
15031 .input_mux = &alc861vd_capture_source,
15032 },
15033 [ALC861VD_3ST_DIG] = {
15034 .mixers = { alc861vd_3st_mixer },
15035 .init_verbs = { alc861vd_volume_init_verbs,
15036 alc861vd_3stack_init_verbs },
15037 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15038 .dac_nids = alc861vd_dac_nids,
15039 .dig_out_nid = ALC861VD_DIGOUT_NID,
15040 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15041 .channel_mode = alc861vd_3stack_2ch_modes,
15042 .input_mux = &alc861vd_capture_source,
15043 },
15044 [ALC861VD_6ST_DIG] = {
15045 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15046 .init_verbs = { alc861vd_volume_init_verbs,
15047 alc861vd_6stack_init_verbs },
15048 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15049 .dac_nids = alc861vd_dac_nids,
15050 .dig_out_nid = ALC861VD_DIGOUT_NID,
15051 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15052 .channel_mode = alc861vd_6stack_modes,
15053 .input_mux = &alc861vd_capture_source,
15054 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015055 [ALC861VD_LENOVO] = {
15056 .mixers = { alc861vd_lenovo_mixer },
15057 .init_verbs = { alc861vd_volume_init_verbs,
15058 alc861vd_3stack_init_verbs,
15059 alc861vd_eapd_verbs,
15060 alc861vd_lenovo_unsol_verbs },
15061 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15062 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015063 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15064 .channel_mode = alc861vd_3stack_2ch_modes,
15065 .input_mux = &alc861vd_capture_source,
15066 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015067 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015068 },
Kailang Yang272a5272007-05-14 11:00:38 +020015069 [ALC861VD_DALLAS] = {
15070 .mixers = { alc861vd_dallas_mixer },
15071 .init_verbs = { alc861vd_dallas_verbs },
15072 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15073 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015074 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15075 .channel_mode = alc861vd_3stack_2ch_modes,
15076 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015077 .unsol_event = alc_automute_amp_unsol_event,
15078 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015079 },
15080 [ALC861VD_HP] = {
15081 .mixers = { alc861vd_hp_mixer },
15082 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15083 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15084 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015085 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015086 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15087 .channel_mode = alc861vd_3stack_2ch_modes,
15088 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015089 .unsol_event = alc_automute_amp_unsol_event,
15090 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015091 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015092 [ALC660VD_ASUS_V1S] = {
15093 .mixers = { alc861vd_lenovo_mixer },
15094 .init_verbs = { alc861vd_volume_init_verbs,
15095 alc861vd_3stack_init_verbs,
15096 alc861vd_eapd_verbs,
15097 alc861vd_lenovo_unsol_verbs },
15098 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15099 .dac_nids = alc660vd_dac_nids,
15100 .dig_out_nid = ALC861VD_DIGOUT_NID,
15101 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15102 .channel_mode = alc861vd_3stack_2ch_modes,
15103 .input_mux = &alc861vd_capture_source,
15104 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015105 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015106 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015107};
15108
15109/*
15110 * BIOS auto configuration
15111 */
15112static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15113 hda_nid_t nid, int pin_type, int dac_idx)
15114{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015115 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015116}
15117
15118static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15119{
15120 struct alc_spec *spec = codec->spec;
15121 int i;
15122
15123 for (i = 0; i <= HDA_SIDE; i++) {
15124 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015125 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015126 if (nid)
15127 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015128 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 }
15130}
15131
15132
15133static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15134{
15135 struct alc_spec *spec = codec->spec;
15136 hda_nid_t pin;
15137
15138 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015139 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015140 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015141 pin = spec->autocfg.speaker_pins[0];
15142 if (pin)
15143 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015144}
15145
15146#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15147#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15148
15149static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15150{
15151 struct alc_spec *spec = codec->spec;
15152 int i;
15153
15154 for (i = 0; i < AUTO_PIN_LAST; i++) {
15155 hda_nid_t nid = spec->autocfg.input_pins[i];
15156 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015157 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015158 if (nid != ALC861VD_PIN_CD_NID &&
15159 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 snd_hda_codec_write(codec, nid, 0,
15161 AC_VERB_SET_AMP_GAIN_MUTE,
15162 AMP_OUT_MUTE);
15163 }
15164 }
15165}
15166
Takashi Iwaif511b012008-08-15 16:46:42 +020015167#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15168
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015169#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15170#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15171
15172/* add playback controls from the parsed DAC table */
15173/* Based on ALC880 version. But ALC861VD has separate,
15174 * different NIDs for mute/unmute switch and volume control */
15175static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15176 const struct auto_pin_cfg *cfg)
15177{
15178 char name[32];
15179 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15180 hda_nid_t nid_v, nid_s;
15181 int i, err;
15182
15183 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015184 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015185 continue;
15186 nid_v = alc861vd_idx_to_mixer_vol(
15187 alc880_dac_to_idx(
15188 spec->multiout.dac_nids[i]));
15189 nid_s = alc861vd_idx_to_mixer_switch(
15190 alc880_dac_to_idx(
15191 spec->multiout.dac_nids[i]));
15192
15193 if (i == 2) {
15194 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015195 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15196 "Center Playback Volume",
15197 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15198 HDA_OUTPUT));
15199 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015200 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015201 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15202 "LFE Playback Volume",
15203 HDA_COMPOSE_AMP_VAL(nid_v, 2, 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_BIND_MUTE,
15208 "Center Playback Switch",
15209 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15210 HDA_INPUT));
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 "LFE Playback Switch",
15215 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15216 HDA_INPUT));
15217 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015218 return err;
15219 } else {
15220 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015221 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15222 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15223 HDA_OUTPUT));
15224 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015225 return err;
15226 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015227 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015228 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015229 HDA_INPUT));
15230 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015231 return err;
15232 }
15233 }
15234 return 0;
15235}
15236
15237/* add playback controls for speaker and HP outputs */
15238/* Based on ALC880 version. But ALC861VD has separate,
15239 * different NIDs for mute/unmute switch and volume control */
15240static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15241 hda_nid_t pin, const char *pfx)
15242{
15243 hda_nid_t nid_v, nid_s;
15244 int err;
15245 char name[32];
15246
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015247 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015248 return 0;
15249
15250 if (alc880_is_fixed_pin(pin)) {
15251 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15252 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015253 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015254 spec->multiout.hp_nid = nid_v;
15255 else
15256 spec->multiout.extra_out_nid[0] = nid_v;
15257 /* control HP volume/switch on the output mixer amp */
15258 nid_v = alc861vd_idx_to_mixer_vol(
15259 alc880_fixed_pin_idx(pin));
15260 nid_s = alc861vd_idx_to_mixer_switch(
15261 alc880_fixed_pin_idx(pin));
15262
15263 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015264 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15265 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15266 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015267 return err;
15268 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015269 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15270 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15271 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015272 return err;
15273 } else if (alc880_is_multi_pin(pin)) {
15274 /* set manual connection */
15275 /* we have only a switch on HP-out PIN */
15276 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015277 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15278 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15279 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015280 return err;
15281 }
15282 return 0;
15283}
15284
15285/* parse the BIOS configuration and set up the alc_spec
15286 * return 1 if successful, 0 if the proper config is not found,
15287 * or a negative error code
15288 * Based on ALC880 version - had to change it to override
15289 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15290static int alc861vd_parse_auto_config(struct hda_codec *codec)
15291{
15292 struct alc_spec *spec = codec->spec;
15293 int err;
15294 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15295
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015296 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15297 alc861vd_ignore);
15298 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015299 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015300 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015301 return 0; /* can't find valid BIOS pin config */
15302
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015303 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15304 if (err < 0)
15305 return err;
15306 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15307 if (err < 0)
15308 return err;
15309 err = alc861vd_auto_create_extra_out(spec,
15310 spec->autocfg.speaker_pins[0],
15311 "Speaker");
15312 if (err < 0)
15313 return err;
15314 err = alc861vd_auto_create_extra_out(spec,
15315 spec->autocfg.hp_pins[0],
15316 "Headphone");
15317 if (err < 0)
15318 return err;
15319 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15320 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015321 return err;
15322
15323 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15324
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015325 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015326 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15327
Takashi Iwai603c4012008-07-30 15:01:44 +020015328 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015329 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330
Takashi Iwaid88897e2008-10-31 15:01:37 +010015331 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332
15333 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015334 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015335
Takashi Iwai776e1842007-08-29 15:07:11 +020015336 err = alc_auto_add_mic_boost(codec);
15337 if (err < 0)
15338 return err;
15339
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015340 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15341
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015342 return 1;
15343}
15344
15345/* additional initialization for auto-configuration model */
15346static void alc861vd_auto_init(struct hda_codec *codec)
15347{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015348 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 alc861vd_auto_init_multi_out(codec);
15350 alc861vd_auto_init_hp_out(codec);
15351 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015352 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015353 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015354 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355}
15356
15357static int patch_alc861vd(struct hda_codec *codec)
15358{
15359 struct alc_spec *spec;
15360 int err, board_config;
15361
15362 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15363 if (spec == NULL)
15364 return -ENOMEM;
15365
15366 codec->spec = spec;
15367
15368 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15369 alc861vd_models,
15370 alc861vd_cfg_tbl);
15371
15372 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015373 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15374 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015375 board_config = ALC861VD_AUTO;
15376 }
15377
15378 if (board_config == ALC861VD_AUTO) {
15379 /* automatic parse from the BIOS config */
15380 err = alc861vd_parse_auto_config(codec);
15381 if (err < 0) {
15382 alc_free(codec);
15383 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015384 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015385 printk(KERN_INFO
15386 "hda_codec: Cannot set up configuration "
15387 "from BIOS. Using base mode...\n");
15388 board_config = ALC861VD_3ST;
15389 }
15390 }
15391
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015392 err = snd_hda_attach_beep_device(codec, 0x23);
15393 if (err < 0) {
15394 alc_free(codec);
15395 return err;
15396 }
15397
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015398 if (board_config != ALC861VD_AUTO)
15399 setup_preset(spec, &alc861vd_presets[board_config]);
15400
Kailang Yang2f893282008-05-27 12:14:47 +020015401 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015402 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015403 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015404 }
15405
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015406 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15407 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15408
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015409 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15410 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15411
15412 spec->adc_nids = alc861vd_adc_nids;
15413 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015414 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015416 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015417 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015418
Takashi Iwai2134ea42008-01-10 16:53:55 +010015419 spec->vmaster_nid = 0x02;
15420
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015421 codec->patch_ops = alc_patch_ops;
15422
15423 if (board_config == ALC861VD_AUTO)
15424 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015425#ifdef CONFIG_SND_HDA_POWER_SAVE
15426 if (!spec->loopback.amplist)
15427 spec->loopback.amplist = alc861vd_loopbacks;
15428#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015429 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015430
15431 return 0;
15432}
15433
15434/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015435 * ALC662 support
15436 *
15437 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15438 * configuration. Each pin widget can choose any input DACs and a mixer.
15439 * Each ADC is connected from a mixer of all inputs. This makes possible
15440 * 6-channel independent captures.
15441 *
15442 * In addition, an independent DAC for the multi-playback (not used in this
15443 * driver yet).
15444 */
15445#define ALC662_DIGOUT_NID 0x06
15446#define ALC662_DIGIN_NID 0x0a
15447
15448static hda_nid_t alc662_dac_nids[4] = {
15449 /* front, rear, clfe, rear_surr */
15450 0x02, 0x03, 0x04
15451};
15452
Kailang Yang622e84c2009-04-21 07:39:04 +020015453static hda_nid_t alc272_dac_nids[2] = {
15454 0x02, 0x03
15455};
15456
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015457static hda_nid_t alc662_adc_nids[1] = {
15458 /* ADC1-2 */
15459 0x09,
15460};
Takashi Iwaie1406342008-02-11 18:32:32 +010015461
Kailang Yang622e84c2009-04-21 07:39:04 +020015462static hda_nid_t alc272_adc_nids[1] = {
15463 /* ADC1-2 */
15464 0x08,
15465};
15466
Kailang Yang77a261b2008-02-19 11:38:05 +010015467static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015468static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15469
Takashi Iwaie1406342008-02-11 18:32:32 +010015470
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015471/* input MUX */
15472/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015473static struct hda_input_mux alc662_capture_source = {
15474 .num_items = 4,
15475 .items = {
15476 { "Mic", 0x0 },
15477 { "Front Mic", 0x1 },
15478 { "Line", 0x2 },
15479 { "CD", 0x4 },
15480 },
15481};
15482
15483static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15484 .num_items = 2,
15485 .items = {
15486 { "Mic", 0x1 },
15487 { "Line", 0x2 },
15488 },
15489};
Kailang Yang291702f2007-10-16 14:28:03 +020015490
15491static struct hda_input_mux alc662_eeepc_capture_source = {
15492 .num_items = 2,
15493 .items = {
15494 { "i-Mic", 0x1 },
15495 { "e-Mic", 0x0 },
15496 },
15497};
15498
Kailang Yang6dda9f42008-05-27 12:05:31 +020015499static struct hda_input_mux alc663_capture_source = {
15500 .num_items = 3,
15501 .items = {
15502 { "Mic", 0x0 },
15503 { "Front Mic", 0x1 },
15504 { "Line", 0x2 },
15505 },
15506};
15507
15508static struct hda_input_mux alc663_m51va_capture_source = {
15509 .num_items = 2,
15510 .items = {
15511 { "Ext-Mic", 0x0 },
15512 { "D-Mic", 0x9 },
15513 },
15514};
15515
Chris Pockelé9541ba12009-05-12 08:08:53 +020015516#if 1 /* set to 0 for testing other input sources below */
15517static struct hda_input_mux alc272_nc10_capture_source = {
15518 .num_items = 2,
15519 .items = {
15520 { "Autoselect Mic", 0x0 },
15521 { "Internal Mic", 0x1 },
15522 },
15523};
15524#else
15525static struct hda_input_mux alc272_nc10_capture_source = {
15526 .num_items = 16,
15527 .items = {
15528 { "Autoselect Mic", 0x0 },
15529 { "Internal Mic", 0x1 },
15530 { "In-0x02", 0x2 },
15531 { "In-0x03", 0x3 },
15532 { "In-0x04", 0x4 },
15533 { "In-0x05", 0x5 },
15534 { "In-0x06", 0x6 },
15535 { "In-0x07", 0x7 },
15536 { "In-0x08", 0x8 },
15537 { "In-0x09", 0x9 },
15538 { "In-0x0a", 0x0a },
15539 { "In-0x0b", 0x0b },
15540 { "In-0x0c", 0x0c },
15541 { "In-0x0d", 0x0d },
15542 { "In-0x0e", 0x0e },
15543 { "In-0x0f", 0x0f },
15544 },
15545};
15546#endif
15547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015548/*
15549 * 2ch mode
15550 */
15551static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15552 { 2, NULL }
15553};
15554
15555/*
15556 * 2ch mode
15557 */
15558static struct hda_verb alc662_3ST_ch2_init[] = {
15559 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15560 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15563 { } /* end */
15564};
15565
15566/*
15567 * 6ch mode
15568 */
15569static struct hda_verb alc662_3ST_ch6_init[] = {
15570 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15571 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15572 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15576 { } /* end */
15577};
15578
15579static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15580 { 2, alc662_3ST_ch2_init },
15581 { 6, alc662_3ST_ch6_init },
15582};
15583
15584/*
15585 * 2ch mode
15586 */
15587static struct hda_verb alc662_sixstack_ch6_init[] = {
15588 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15589 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15591 { } /* end */
15592};
15593
15594/*
15595 * 6ch mode
15596 */
15597static struct hda_verb alc662_sixstack_ch8_init[] = {
15598 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15599 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15600 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15601 { } /* end */
15602};
15603
15604static struct hda_channel_mode alc662_5stack_modes[2] = {
15605 { 2, alc662_sixstack_ch6_init },
15606 { 6, alc662_sixstack_ch8_init },
15607};
15608
15609/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15610 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15611 */
15612
15613static struct snd_kcontrol_new alc662_base_mixer[] = {
15614 /* output mixer control */
15615 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015616 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015617 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015618 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015619 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15620 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015621 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15622 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15624
15625 /*Input mixer control */
15626 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15627 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15628 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15629 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15630 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15631 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15632 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15633 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015634 { } /* end */
15635};
15636
15637static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15638 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015639 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15641 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15642 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15643 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15644 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15647 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15648 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015649 { } /* end */
15650};
15651
15652static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15653 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015654 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015655 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015656 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015657 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15658 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015659 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15660 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15668 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015670 { } /* end */
15671};
15672
15673static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15674 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15675 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015676 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15677 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15679 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15680 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015683 { } /* end */
15684};
15685
Kailang Yang291702f2007-10-16 14:28:03 +020015686static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015687 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15688 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015689
15690 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15691 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15692 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15693
15694 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15695 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15696 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15697 { } /* end */
15698};
15699
Kailang Yang8c427222008-01-10 13:03:59 +010015700static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015701 ALC262_HIPPO_MASTER_SWITCH,
15702 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015703 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015704 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15705 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015706 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15711 { } /* end */
15712};
15713
Kailang Yangf1d4e282008-08-26 14:03:29 +020015714static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15715 .ops = &snd_hda_bind_vol,
15716 .values = {
15717 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15718 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15719 0
15720 },
15721};
15722
15723static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15724 .ops = &snd_hda_bind_sw,
15725 .values = {
15726 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15727 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15728 0
15729 },
15730};
15731
Kailang Yang6dda9f42008-05-27 12:05:31 +020015732static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015733 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15734 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15737 { } /* end */
15738};
15739
15740static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15741 .ops = &snd_hda_bind_sw,
15742 .values = {
15743 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15744 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15745 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15746 0
15747 },
15748};
15749
15750static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15751 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15752 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15755 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15756 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15757
15758 { } /* end */
15759};
15760
15761static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15762 .ops = &snd_hda_bind_sw,
15763 .values = {
15764 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15765 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15766 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15767 0
15768 },
15769};
15770
15771static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15772 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15773 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15776 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15777 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15778 { } /* end */
15779};
15780
15781static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015782 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15783 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15787 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15788 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15789 { } /* end */
15790};
15791
15792static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15793 .ops = &snd_hda_bind_vol,
15794 .values = {
15795 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15796 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15797 0
15798 },
15799};
15800
15801static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15802 .ops = &snd_hda_bind_sw,
15803 .values = {
15804 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15805 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15806 0
15807 },
15808};
15809
15810static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15811 HDA_BIND_VOL("Master Playback Volume",
15812 &alc663_asus_two_bind_master_vol),
15813 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15814 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015818 { } /* end */
15819};
15820
15821static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15822 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15823 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015828 { } /* end */
15829};
15830
15831static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15832 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15833 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15834 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15835 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15837
15838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15840 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15841 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15842 { } /* end */
15843};
15844
15845static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15846 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15847 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15848 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15849
15850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15852 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15853 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15856 { } /* end */
15857};
15858
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015859static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15860 {
15861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15862 .name = "Channel Mode",
15863 .info = alc_ch_mode_info,
15864 .get = alc_ch_mode_get,
15865 .put = alc_ch_mode_put,
15866 },
15867 { } /* end */
15868};
15869
15870static struct hda_verb alc662_init_verbs[] = {
15871 /* ADC: mute amp left and right */
15872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15873 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15874 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15875
Takashi Iwaicb53c622007-08-10 17:21:45 +020015876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015881
Kailang Yangb60dd392007-09-20 12:50:29 +020015882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015888
15889 /* Front Pin: output 0 (0x0c) */
15890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15892
15893 /* Rear Pin: output 1 (0x0d) */
15894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15896
15897 /* CLFE Pin: output 2 (0x0e) */
15898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15900
15901 /* Mic (rear) pin: input vref at 80% */
15902 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15904 /* Front Mic pin: input vref at 80% */
15905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15906 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15907 /* Line In pin: input */
15908 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15909 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15910 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15911 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15913 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15914 /* CD pin widget for input */
15915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15916
15917 /* FIXME: use matrix-type input source selection */
15918 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15919 /* Input mixer */
15920 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015921 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015922
15923 /* always trun on EAPD */
15924 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15925 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15926
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015927 { }
15928};
15929
15930static struct hda_verb alc662_sue_init_verbs[] = {
15931 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15932 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015933 {}
15934};
15935
15936static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15937 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15939 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015940};
15941
Kailang Yang8c427222008-01-10 13:03:59 +010015942/* Set Unsolicited Event*/
15943static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15945 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15946 {}
15947};
15948
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015949/*
15950 * generic initialization of ADC, input mixers and output mixers
15951 */
15952static struct hda_verb alc662_auto_init_verbs[] = {
15953 /*
15954 * Unmute ADC and set the default input to mic-in
15955 */
15956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15958
15959 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15960 * mixer widget
15961 * Note: PASD motherboards uses the Line In 2 as the input for front
15962 * panel mic (mic 2)
15963 */
15964 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015970
15971 /*
15972 * Set up output mixers (0x0c - 0x0f)
15973 */
15974 /* set vol=0 to output mixers */
15975 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15976 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15977 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15978
15979 /* set up input amps for analog loopback */
15980 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15983 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15985 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15986 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015987
15988
15989 /* FIXME: use matrix-type input source selection */
15990 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15991 /* Input mixer */
15992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015994 { }
15995};
15996
Takashi Iwai24fb9172008-09-02 14:48:20 +020015997/* additional verbs for ALC663 */
15998static struct hda_verb alc663_auto_init_verbs[] = {
15999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16001 { }
16002};
16003
Kailang Yang6dda9f42008-05-27 12:05:31 +020016004static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016007 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16008 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016009 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016012 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16013 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16014 {}
16015};
16016
Kailang Yangf1d4e282008-08-26 14:03:29 +020016017static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16018 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16019 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16020 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16023 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16024 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16025 {}
16026};
16027
16028static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16031 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16032 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16035 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16036 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16037 {}
16038};
16039
16040static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16043 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16046 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16048 {}
16049};
16050
16051static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16052 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16053 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16054 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16055 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16058 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16061 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16062 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16063 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16064 {}
16065};
16066
16067static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16068 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16071 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16077 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16078 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16079 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16080 {}
16081};
16082
Kailang Yang6dda9f42008-05-27 12:05:31 +020016083static struct hda_verb alc663_g71v_init_verbs[] = {
16084 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16085 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16086 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16087
16088 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16089 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16090 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16091
16092 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16093 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16094 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16095 {}
16096};
16097
16098static struct hda_verb alc663_g50v_init_verbs[] = {
16099 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16100 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16101 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16102
16103 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16104 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16105 {}
16106};
16107
Kailang Yangf1d4e282008-08-26 14:03:29 +020016108static struct hda_verb alc662_ecs_init_verbs[] = {
16109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16112 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16113 {}
16114};
16115
Kailang Yang622e84c2009-04-21 07:39:04 +020016116static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16117 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16118 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16121 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16122 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16123 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16126 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16127 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16128 {}
16129};
16130
16131static struct hda_verb alc272_dell_init_verbs[] = {
16132 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16133 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16136 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16137 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16138 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16141 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16142 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16143 {}
16144};
16145
Kailang Yangf1d4e282008-08-26 14:03:29 +020016146static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16147 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16148 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16149 { } /* end */
16150};
16151
Kailang Yang622e84c2009-04-21 07:39:04 +020016152static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16153 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16154 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16155 { } /* end */
16156};
16157
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016158static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16159{
16160 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016161 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016162
16163 present = snd_hda_codec_read(codec, 0x14, 0,
16164 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016165 bits = present ? HDA_AMP_MUTE : 0;
16166 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16167 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016168}
16169
16170static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16171{
16172 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016173 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016174
16175 present = snd_hda_codec_read(codec, 0x1b, 0,
16176 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016177 bits = present ? HDA_AMP_MUTE : 0;
16178 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16179 HDA_AMP_MUTE, bits);
16180 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16181 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016182}
16183
16184static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16185 unsigned int res)
16186{
16187 if ((res >> 26) == ALC880_HP_EVENT)
16188 alc662_lenovo_101e_all_automute(codec);
16189 if ((res >> 26) == ALC880_FRONT_EVENT)
16190 alc662_lenovo_101e_ispeaker_automute(codec);
16191}
16192
Kailang Yang291702f2007-10-16 14:28:03 +020016193static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16194{
16195 unsigned int present;
16196
16197 present = snd_hda_codec_read(codec, 0x18, 0,
16198 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16199 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16200 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16201 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16202 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16203 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16204 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16205 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16206 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16207}
16208
16209/* unsolicited event for HP jack sensing */
16210static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16211 unsigned int res)
16212{
Kailang Yang291702f2007-10-16 14:28:03 +020016213 if ((res >> 26) == ALC880_MIC_EVENT)
16214 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016215 else
16216 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016217}
16218
16219static void alc662_eeepc_inithook(struct hda_codec *codec)
16220{
Takashi Iwai42171c12009-05-08 14:11:43 +020016221 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016222 alc662_eeepc_mic_automute(codec);
16223}
16224
Kailang Yang8c427222008-01-10 13:03:59 +010016225static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16226{
Takashi Iwai42171c12009-05-08 14:11:43 +020016227 struct alc_spec *spec = codec->spec;
16228
16229 spec->autocfg.hp_pins[0] = 0x14;
16230 spec->autocfg.speaker_pins[0] = 0x1b;
16231 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016232}
16233
Kailang Yang6dda9f42008-05-27 12:05:31 +020016234static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16235{
16236 unsigned int present;
16237 unsigned char bits;
16238
16239 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016240 AC_VERB_GET_PIN_SENSE, 0)
16241 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016242 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016243 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16244 AMP_IN_MUTE(0), bits);
16245 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16246 AMP_IN_MUTE(0), bits);
16247}
16248
16249static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16250{
16251 unsigned int present;
16252 unsigned char bits;
16253
16254 present = snd_hda_codec_read(codec, 0x21, 0,
16255 AC_VERB_GET_PIN_SENSE, 0)
16256 & AC_PINSENSE_PRESENCE;
16257 bits = present ? HDA_AMP_MUTE : 0;
16258 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16259 AMP_IN_MUTE(0), bits);
16260 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16261 AMP_IN_MUTE(0), bits);
16262 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16263 AMP_IN_MUTE(0), bits);
16264 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16265 AMP_IN_MUTE(0), bits);
16266}
16267
16268static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16269{
16270 unsigned int present;
16271 unsigned char bits;
16272
16273 present = snd_hda_codec_read(codec, 0x15, 0,
16274 AC_VERB_GET_PIN_SENSE, 0)
16275 & AC_PINSENSE_PRESENCE;
16276 bits = present ? HDA_AMP_MUTE : 0;
16277 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16278 AMP_IN_MUTE(0), bits);
16279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16280 AMP_IN_MUTE(0), bits);
16281 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16282 AMP_IN_MUTE(0), bits);
16283 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16284 AMP_IN_MUTE(0), bits);
16285}
16286
16287static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16288{
16289 unsigned int present;
16290 unsigned char bits;
16291
16292 present = snd_hda_codec_read(codec, 0x1b, 0,
16293 AC_VERB_GET_PIN_SENSE, 0)
16294 & AC_PINSENSE_PRESENCE;
16295 bits = present ? 0 : PIN_OUT;
16296 snd_hda_codec_write(codec, 0x14, 0,
16297 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16298}
16299
16300static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16301{
16302 unsigned int present1, present2;
16303
16304 present1 = snd_hda_codec_read(codec, 0x21, 0,
16305 AC_VERB_GET_PIN_SENSE, 0)
16306 & AC_PINSENSE_PRESENCE;
16307 present2 = snd_hda_codec_read(codec, 0x15, 0,
16308 AC_VERB_GET_PIN_SENSE, 0)
16309 & AC_PINSENSE_PRESENCE;
16310
16311 if (present1 || present2) {
16312 snd_hda_codec_write_cache(codec, 0x14, 0,
16313 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16314 } else {
16315 snd_hda_codec_write_cache(codec, 0x14, 0,
16316 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16317 }
16318}
16319
16320static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16321{
16322 unsigned int present1, present2;
16323
16324 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16325 AC_VERB_GET_PIN_SENSE, 0)
16326 & AC_PINSENSE_PRESENCE;
16327 present2 = snd_hda_codec_read(codec, 0x15, 0,
16328 AC_VERB_GET_PIN_SENSE, 0)
16329 & AC_PINSENSE_PRESENCE;
16330
16331 if (present1 || present2) {
16332 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16333 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16334 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16335 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16336 } else {
16337 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16338 AMP_IN_MUTE(0), 0);
16339 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16340 AMP_IN_MUTE(0), 0);
16341 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016342}
16343
16344static void alc663_m51va_mic_automute(struct hda_codec *codec)
16345{
16346 unsigned int present;
16347
16348 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016349 AC_VERB_GET_PIN_SENSE, 0)
16350 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016351 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016352 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016353 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016354 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016355 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016356 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016357 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016358 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016359}
16360
16361static void alc663_m51va_unsol_event(struct hda_codec *codec,
16362 unsigned int res)
16363{
16364 switch (res >> 26) {
16365 case ALC880_HP_EVENT:
16366 alc663_m51va_speaker_automute(codec);
16367 break;
16368 case ALC880_MIC_EVENT:
16369 alc663_m51va_mic_automute(codec);
16370 break;
16371 }
16372}
16373
16374static void alc663_m51va_inithook(struct hda_codec *codec)
16375{
16376 alc663_m51va_speaker_automute(codec);
16377 alc663_m51va_mic_automute(codec);
16378}
16379
Kailang Yangf1d4e282008-08-26 14:03:29 +020016380/* ***************** Mode1 ******************************/
16381static void alc663_mode1_unsol_event(struct hda_codec *codec,
16382 unsigned int res)
16383{
16384 switch (res >> 26) {
16385 case ALC880_HP_EVENT:
16386 alc663_m51va_speaker_automute(codec);
16387 break;
16388 case ALC880_MIC_EVENT:
16389 alc662_eeepc_mic_automute(codec);
16390 break;
16391 }
16392}
16393
16394static void alc663_mode1_inithook(struct hda_codec *codec)
16395{
16396 alc663_m51va_speaker_automute(codec);
16397 alc662_eeepc_mic_automute(codec);
16398}
16399/* ***************** Mode2 ******************************/
16400static void alc662_mode2_unsol_event(struct hda_codec *codec,
16401 unsigned int res)
16402{
16403 switch (res >> 26) {
16404 case ALC880_HP_EVENT:
16405 alc662_f5z_speaker_automute(codec);
16406 break;
16407 case ALC880_MIC_EVENT:
16408 alc662_eeepc_mic_automute(codec);
16409 break;
16410 }
16411}
16412
16413static void alc662_mode2_inithook(struct hda_codec *codec)
16414{
16415 alc662_f5z_speaker_automute(codec);
16416 alc662_eeepc_mic_automute(codec);
16417}
16418/* ***************** Mode3 ******************************/
16419static void alc663_mode3_unsol_event(struct hda_codec *codec,
16420 unsigned int res)
16421{
16422 switch (res >> 26) {
16423 case ALC880_HP_EVENT:
16424 alc663_two_hp_m1_speaker_automute(codec);
16425 break;
16426 case ALC880_MIC_EVENT:
16427 alc662_eeepc_mic_automute(codec);
16428 break;
16429 }
16430}
16431
16432static void alc663_mode3_inithook(struct hda_codec *codec)
16433{
16434 alc663_two_hp_m1_speaker_automute(codec);
16435 alc662_eeepc_mic_automute(codec);
16436}
16437/* ***************** Mode4 ******************************/
16438static void alc663_mode4_unsol_event(struct hda_codec *codec,
16439 unsigned int res)
16440{
16441 switch (res >> 26) {
16442 case ALC880_HP_EVENT:
16443 alc663_21jd_two_speaker_automute(codec);
16444 break;
16445 case ALC880_MIC_EVENT:
16446 alc662_eeepc_mic_automute(codec);
16447 break;
16448 }
16449}
16450
16451static void alc663_mode4_inithook(struct hda_codec *codec)
16452{
16453 alc663_21jd_two_speaker_automute(codec);
16454 alc662_eeepc_mic_automute(codec);
16455}
16456/* ***************** Mode5 ******************************/
16457static void alc663_mode5_unsol_event(struct hda_codec *codec,
16458 unsigned int res)
16459{
16460 switch (res >> 26) {
16461 case ALC880_HP_EVENT:
16462 alc663_15jd_two_speaker_automute(codec);
16463 break;
16464 case ALC880_MIC_EVENT:
16465 alc662_eeepc_mic_automute(codec);
16466 break;
16467 }
16468}
16469
16470static void alc663_mode5_inithook(struct hda_codec *codec)
16471{
16472 alc663_15jd_two_speaker_automute(codec);
16473 alc662_eeepc_mic_automute(codec);
16474}
16475/* ***************** Mode6 ******************************/
16476static void alc663_mode6_unsol_event(struct hda_codec *codec,
16477 unsigned int res)
16478{
16479 switch (res >> 26) {
16480 case ALC880_HP_EVENT:
16481 alc663_two_hp_m2_speaker_automute(codec);
16482 break;
16483 case ALC880_MIC_EVENT:
16484 alc662_eeepc_mic_automute(codec);
16485 break;
16486 }
16487}
16488
16489static void alc663_mode6_inithook(struct hda_codec *codec)
16490{
16491 alc663_two_hp_m2_speaker_automute(codec);
16492 alc662_eeepc_mic_automute(codec);
16493}
16494
Kailang Yang6dda9f42008-05-27 12:05:31 +020016495static void alc663_g71v_hp_automute(struct hda_codec *codec)
16496{
16497 unsigned int present;
16498 unsigned char bits;
16499
16500 present = snd_hda_codec_read(codec, 0x21, 0,
16501 AC_VERB_GET_PIN_SENSE, 0)
16502 & AC_PINSENSE_PRESENCE;
16503 bits = present ? HDA_AMP_MUTE : 0;
16504 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16505 HDA_AMP_MUTE, bits);
16506 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16507 HDA_AMP_MUTE, bits);
16508}
16509
16510static void alc663_g71v_front_automute(struct hda_codec *codec)
16511{
16512 unsigned int present;
16513 unsigned char bits;
16514
16515 present = snd_hda_codec_read(codec, 0x15, 0,
16516 AC_VERB_GET_PIN_SENSE, 0)
16517 & AC_PINSENSE_PRESENCE;
16518 bits = present ? HDA_AMP_MUTE : 0;
16519 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16520 HDA_AMP_MUTE, bits);
16521}
16522
16523static void alc663_g71v_unsol_event(struct hda_codec *codec,
16524 unsigned int res)
16525{
16526 switch (res >> 26) {
16527 case ALC880_HP_EVENT:
16528 alc663_g71v_hp_automute(codec);
16529 break;
16530 case ALC880_FRONT_EVENT:
16531 alc663_g71v_front_automute(codec);
16532 break;
16533 case ALC880_MIC_EVENT:
16534 alc662_eeepc_mic_automute(codec);
16535 break;
16536 }
16537}
16538
16539static void alc663_g71v_inithook(struct hda_codec *codec)
16540{
16541 alc663_g71v_front_automute(codec);
16542 alc663_g71v_hp_automute(codec);
16543 alc662_eeepc_mic_automute(codec);
16544}
16545
16546static void alc663_g50v_unsol_event(struct hda_codec *codec,
16547 unsigned int res)
16548{
16549 switch (res >> 26) {
16550 case ALC880_HP_EVENT:
16551 alc663_m51va_speaker_automute(codec);
16552 break;
16553 case ALC880_MIC_EVENT:
16554 alc662_eeepc_mic_automute(codec);
16555 break;
16556 }
16557}
16558
16559static void alc663_g50v_inithook(struct hda_codec *codec)
16560{
16561 alc663_m51va_speaker_automute(codec);
16562 alc662_eeepc_mic_automute(codec);
16563}
16564
Kailang Yangf1d4e282008-08-26 14:03:29 +020016565static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16566 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016567 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016568
16569 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16570 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16571 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16572
16573 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16574 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16575 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16576 { } /* end */
16577};
16578
Chris Pockelé9541ba12009-05-12 08:08:53 +020016579static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16580 /* Master Playback automatically created from Speaker and Headphone */
16581 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16582 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16583 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16585
16586 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16587 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16588 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16589
16590 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16591 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16592 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16593 { } /* end */
16594};
16595
Takashi Iwaicb53c622007-08-10 17:21:45 +020016596#ifdef CONFIG_SND_HDA_POWER_SAVE
16597#define alc662_loopbacks alc880_loopbacks
16598#endif
16599
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016601/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016602#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16603#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16604#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16605#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16606
16607/*
16608 * configuration and preset
16609 */
16610static const char *alc662_models[ALC662_MODEL_LAST] = {
16611 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16612 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16613 [ALC662_3ST_6ch] = "3stack-6ch",
16614 [ALC662_5ST_DIG] = "6stack-dig",
16615 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016616 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016617 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016618 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016619 [ALC663_ASUS_M51VA] = "m51va",
16620 [ALC663_ASUS_G71V] = "g71v",
16621 [ALC663_ASUS_H13] = "h13",
16622 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016623 [ALC663_ASUS_MODE1] = "asus-mode1",
16624 [ALC662_ASUS_MODE2] = "asus-mode2",
16625 [ALC663_ASUS_MODE3] = "asus-mode3",
16626 [ALC663_ASUS_MODE4] = "asus-mode4",
16627 [ALC663_ASUS_MODE5] = "asus-mode5",
16628 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016629 [ALC272_DELL] = "dell",
16630 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016631 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016632 [ALC662_AUTO] = "auto",
16633};
16634
16635static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016636 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016637 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16638 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016639 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16640 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16641 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16642 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16643 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16644 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16645 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16646 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16647 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16648 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16649 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16650 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016651 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16652 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16653 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016654 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16655 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16656 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16657 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016658 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016659 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16660 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016661 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016662 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16663 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16664 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016665 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16666 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16667 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016668 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16669 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16670 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016671 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016672 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16673 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016674 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016675 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016676 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016677 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16678 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16679 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016680 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016681 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16682 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016683 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016684 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016685 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016686 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016687 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16688 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016689 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016690 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16691 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016692 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016693 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016694 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016695 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016696 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016697 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16698 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016699 {}
16700};
16701
16702static struct alc_config_preset alc662_presets[] = {
16703 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016704 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016705 .init_verbs = { alc662_init_verbs },
16706 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16707 .dac_nids = alc662_dac_nids,
16708 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016709 .dig_in_nid = ALC662_DIGIN_NID,
16710 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16711 .channel_mode = alc662_3ST_2ch_modes,
16712 .input_mux = &alc662_capture_source,
16713 },
16714 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016715 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716 .init_verbs = { alc662_init_verbs },
16717 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16718 .dac_nids = alc662_dac_nids,
16719 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016720 .dig_in_nid = ALC662_DIGIN_NID,
16721 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16722 .channel_mode = alc662_3ST_6ch_modes,
16723 .need_dac_fix = 1,
16724 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016725 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016726 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016727 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728 .init_verbs = { alc662_init_verbs },
16729 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16730 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016731 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16732 .channel_mode = alc662_3ST_6ch_modes,
16733 .need_dac_fix = 1,
16734 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016735 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016736 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016737 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016738 .init_verbs = { alc662_init_verbs },
16739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16740 .dac_nids = alc662_dac_nids,
16741 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742 .dig_in_nid = ALC662_DIGIN_NID,
16743 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16744 .channel_mode = alc662_5stack_modes,
16745 .input_mux = &alc662_capture_source,
16746 },
16747 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016748 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16750 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16751 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16753 .channel_mode = alc662_3ST_2ch_modes,
16754 .input_mux = &alc662_lenovo_101e_capture_source,
16755 .unsol_event = alc662_lenovo_101e_unsol_event,
16756 .init_hook = alc662_lenovo_101e_all_automute,
16757 },
Kailang Yang291702f2007-10-16 14:28:03 +020016758 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016759 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016760 .init_verbs = { alc662_init_verbs,
16761 alc662_eeepc_sue_init_verbs },
16762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16763 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16765 .channel_mode = alc662_3ST_2ch_modes,
16766 .input_mux = &alc662_eeepc_capture_source,
16767 .unsol_event = alc662_eeepc_unsol_event,
16768 .init_hook = alc662_eeepc_inithook,
16769 },
Kailang Yang8c427222008-01-10 13:03:59 +010016770 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016771 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016772 alc662_chmode_mixer },
16773 .init_verbs = { alc662_init_verbs,
16774 alc662_eeepc_ep20_sue_init_verbs },
16775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16776 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16778 .channel_mode = alc662_3ST_6ch_modes,
16779 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016780 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016781 .init_hook = alc662_eeepc_ep20_inithook,
16782 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016783 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016784 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016785 .init_verbs = { alc662_init_verbs,
16786 alc662_ecs_init_verbs },
16787 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16788 .dac_nids = alc662_dac_nids,
16789 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16790 .channel_mode = alc662_3ST_2ch_modes,
16791 .input_mux = &alc662_eeepc_capture_source,
16792 .unsol_event = alc662_eeepc_unsol_event,
16793 .init_hook = alc662_eeepc_inithook,
16794 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016795 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016796 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016797 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16799 .dac_nids = alc662_dac_nids,
16800 .dig_out_nid = ALC662_DIGOUT_NID,
16801 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16802 .channel_mode = alc662_3ST_2ch_modes,
16803 .input_mux = &alc663_m51va_capture_source,
16804 .unsol_event = alc663_m51va_unsol_event,
16805 .init_hook = alc663_m51va_inithook,
16806 },
16807 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016808 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016809 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16810 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16811 .dac_nids = alc662_dac_nids,
16812 .dig_out_nid = ALC662_DIGOUT_NID,
16813 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16814 .channel_mode = alc662_3ST_2ch_modes,
16815 .input_mux = &alc662_eeepc_capture_source,
16816 .unsol_event = alc663_g71v_unsol_event,
16817 .init_hook = alc663_g71v_inithook,
16818 },
16819 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016820 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016821 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16823 .dac_nids = alc662_dac_nids,
16824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16825 .channel_mode = alc662_3ST_2ch_modes,
16826 .input_mux = &alc663_m51va_capture_source,
16827 .unsol_event = alc663_m51va_unsol_event,
16828 .init_hook = alc663_m51va_inithook,
16829 },
16830 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016831 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016832 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16834 .dac_nids = alc662_dac_nids,
16835 .dig_out_nid = ALC662_DIGOUT_NID,
16836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16837 .channel_mode = alc662_3ST_6ch_modes,
16838 .input_mux = &alc663_capture_source,
16839 .unsol_event = alc663_g50v_unsol_event,
16840 .init_hook = alc663_g50v_inithook,
16841 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016842 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016843 .mixers = { alc663_m51va_mixer },
16844 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016845 .init_verbs = { alc662_init_verbs,
16846 alc663_21jd_amic_init_verbs },
16847 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16848 .hp_nid = 0x03,
16849 .dac_nids = alc662_dac_nids,
16850 .dig_out_nid = ALC662_DIGOUT_NID,
16851 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16852 .channel_mode = alc662_3ST_2ch_modes,
16853 .input_mux = &alc662_eeepc_capture_source,
16854 .unsol_event = alc663_mode1_unsol_event,
16855 .init_hook = alc663_mode1_inithook,
16856 },
16857 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016858 .mixers = { alc662_1bjd_mixer },
16859 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016860 .init_verbs = { alc662_init_verbs,
16861 alc662_1bjd_amic_init_verbs },
16862 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16863 .dac_nids = alc662_dac_nids,
16864 .dig_out_nid = ALC662_DIGOUT_NID,
16865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16866 .channel_mode = alc662_3ST_2ch_modes,
16867 .input_mux = &alc662_eeepc_capture_source,
16868 .unsol_event = alc662_mode2_unsol_event,
16869 .init_hook = alc662_mode2_inithook,
16870 },
16871 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016872 .mixers = { alc663_two_hp_m1_mixer },
16873 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016874 .init_verbs = { alc662_init_verbs,
16875 alc663_two_hp_amic_m1_init_verbs },
16876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16877 .hp_nid = 0x03,
16878 .dac_nids = alc662_dac_nids,
16879 .dig_out_nid = ALC662_DIGOUT_NID,
16880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16881 .channel_mode = alc662_3ST_2ch_modes,
16882 .input_mux = &alc662_eeepc_capture_source,
16883 .unsol_event = alc663_mode3_unsol_event,
16884 .init_hook = alc663_mode3_inithook,
16885 },
16886 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016887 .mixers = { alc663_asus_21jd_clfe_mixer },
16888 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016889 .init_verbs = { alc662_init_verbs,
16890 alc663_21jd_amic_init_verbs},
16891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16892 .hp_nid = 0x03,
16893 .dac_nids = alc662_dac_nids,
16894 .dig_out_nid = ALC662_DIGOUT_NID,
16895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16896 .channel_mode = alc662_3ST_2ch_modes,
16897 .input_mux = &alc662_eeepc_capture_source,
16898 .unsol_event = alc663_mode4_unsol_event,
16899 .init_hook = alc663_mode4_inithook,
16900 },
16901 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016902 .mixers = { alc663_asus_15jd_clfe_mixer },
16903 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016904 .init_verbs = { alc662_init_verbs,
16905 alc663_15jd_amic_init_verbs },
16906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16907 .hp_nid = 0x03,
16908 .dac_nids = alc662_dac_nids,
16909 .dig_out_nid = ALC662_DIGOUT_NID,
16910 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16911 .channel_mode = alc662_3ST_2ch_modes,
16912 .input_mux = &alc662_eeepc_capture_source,
16913 .unsol_event = alc663_mode5_unsol_event,
16914 .init_hook = alc663_mode5_inithook,
16915 },
16916 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016917 .mixers = { alc663_two_hp_m2_mixer },
16918 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016919 .init_verbs = { alc662_init_verbs,
16920 alc663_two_hp_amic_m2_init_verbs },
16921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16922 .hp_nid = 0x03,
16923 .dac_nids = alc662_dac_nids,
16924 .dig_out_nid = ALC662_DIGOUT_NID,
16925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16926 .channel_mode = alc662_3ST_2ch_modes,
16927 .input_mux = &alc662_eeepc_capture_source,
16928 .unsol_event = alc663_mode6_unsol_event,
16929 .init_hook = alc663_mode6_inithook,
16930 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016931 [ALC272_DELL] = {
16932 .mixers = { alc663_m51va_mixer },
16933 .cap_mixer = alc272_auto_capture_mixer,
16934 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16935 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16936 .dac_nids = alc662_dac_nids,
16937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16938 .adc_nids = alc272_adc_nids,
16939 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16940 .capsrc_nids = alc272_capsrc_nids,
16941 .channel_mode = alc662_3ST_2ch_modes,
16942 .input_mux = &alc663_m51va_capture_source,
16943 .unsol_event = alc663_m51va_unsol_event,
16944 .init_hook = alc663_m51va_inithook,
16945 },
16946 [ALC272_DELL_ZM1] = {
16947 .mixers = { alc663_m51va_mixer },
16948 .cap_mixer = alc662_auto_capture_mixer,
16949 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16950 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16951 .dac_nids = alc662_dac_nids,
16952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16953 .adc_nids = alc662_adc_nids,
16954 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16955 .capsrc_nids = alc662_capsrc_nids,
16956 .channel_mode = alc662_3ST_2ch_modes,
16957 .input_mux = &alc663_m51va_capture_source,
16958 .unsol_event = alc663_m51va_unsol_event,
16959 .init_hook = alc663_m51va_inithook,
16960 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016961 [ALC272_SAMSUNG_NC10] = {
16962 .mixers = { alc272_nc10_mixer },
16963 .init_verbs = { alc662_init_verbs,
16964 alc663_21jd_amic_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16966 .dac_nids = alc272_dac_nids,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .input_mux = &alc272_nc10_capture_source,
16970 .unsol_event = alc663_mode4_unsol_event,
16971 .init_hook = alc663_mode4_inithook,
16972 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016973};
16974
16975
16976/*
16977 * BIOS auto configuration
16978 */
16979
16980/* add playback controls from the parsed DAC table */
16981static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16982 const struct auto_pin_cfg *cfg)
16983{
16984 char name[32];
16985 static const char *chname[4] = {
16986 "Front", "Surround", NULL /*CLFE*/, "Side"
16987 };
16988 hda_nid_t nid;
16989 int i, err;
16990
16991 for (i = 0; i < cfg->line_outs; i++) {
16992 if (!spec->multiout.dac_nids[i])
16993 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016994 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016995 if (i == 2) {
16996 /* Center/LFE */
16997 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16998 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016999 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17000 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017001 if (err < 0)
17002 return err;
17003 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17004 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017005 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17006 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007 if (err < 0)
17008 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017009 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017010 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017011 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017012 HDA_INPUT));
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 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017017 HDA_COMPOSE_AMP_VAL(0x0e, 2, 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;
17021 } else {
17022 sprintf(name, "%s Playback Volume", chname[i]);
17023 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017024 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17025 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017026 if (err < 0)
17027 return err;
17028 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017029 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17030 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17031 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017032 if (err < 0)
17033 return err;
17034 }
17035 }
17036 return 0;
17037}
17038
17039/* add playback controls for speaker and HP outputs */
17040static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17041 const char *pfx)
17042{
17043 hda_nid_t nid;
17044 int err;
17045 char name[32];
17046
17047 if (!pin)
17048 return 0;
17049
Takashi Iwai24fb9172008-09-02 14:48:20 +020017050 if (pin == 0x17) {
17051 /* ALC663 has a mono output pin on 0x17 */
17052 sprintf(name, "%s Playback Switch", pfx);
17053 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17054 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17055 return err;
17056 }
17057
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017058 if (alc880_is_fixed_pin(pin)) {
17059 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017060 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017061 /* specify the DAC as the extra output */
17062 if (!spec->multiout.hp_nid)
17063 spec->multiout.hp_nid = nid;
17064 else
17065 spec->multiout.extra_out_nid[0] = nid;
17066 /* control HP volume/switch on the output mixer amp */
17067 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17068 sprintf(name, "%s Playback Volume", pfx);
17069 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17070 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17071 if (err < 0)
17072 return err;
17073 sprintf(name, "%s Playback Switch", pfx);
17074 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17075 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17076 if (err < 0)
17077 return err;
17078 } else if (alc880_is_multi_pin(pin)) {
17079 /* set manual connection */
17080 /* we have only a switch on HP-out PIN */
17081 sprintf(name, "%s Playback Switch", pfx);
17082 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17083 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17084 if (err < 0)
17085 return err;
17086 }
17087 return 0;
17088}
17089
Takashi Iwai2d864c42009-03-20 12:52:47 +010017090/* return the index of the src widget from the connection list of the nid.
17091 * return -1 if not found
17092 */
17093static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17094 hda_nid_t src)
17095{
17096 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17097 int i, conns;
17098
17099 conns = snd_hda_get_connections(codec, nid, conn_list,
17100 ARRAY_SIZE(conn_list));
17101 if (conns < 0)
17102 return -1;
17103 for (i = 0; i < conns; i++)
17104 if (conn_list[i] == src)
17105 return i;
17106 return -1;
17107}
17108
17109static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17110{
Takashi Iwai1327a322009-03-23 13:07:47 +010017111 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017112 return (pincap & AC_PINCAP_IN) != 0;
17113}
17114
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017115/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017116static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017117 const struct auto_pin_cfg *cfg)
17118{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017119 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017120 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017121 int i, err, idx;
17122
17123 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017124 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17125 idx = alc662_input_pin_idx(codec, 0x0b,
17126 cfg->input_pins[i]);
17127 if (idx >= 0) {
17128 err = new_analog_input(spec, cfg->input_pins[i],
17129 auto_pin_cfg_labels[i],
17130 idx, 0x0b);
17131 if (err < 0)
17132 return err;
17133 }
17134 idx = alc662_input_pin_idx(codec, 0x22,
17135 cfg->input_pins[i]);
17136 if (idx >= 0) {
17137 imux->items[imux->num_items].label =
17138 auto_pin_cfg_labels[i];
17139 imux->items[imux->num_items].index = idx;
17140 imux->num_items++;
17141 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017142 }
17143 }
17144 return 0;
17145}
17146
17147static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17148 hda_nid_t nid, int pin_type,
17149 int dac_idx)
17150{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017151 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017152 /* need the manual connection? */
17153 if (alc880_is_multi_pin(nid)) {
17154 struct alc_spec *spec = codec->spec;
17155 int idx = alc880_multi_pin_idx(nid);
17156 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17157 AC_VERB_SET_CONNECT_SEL,
17158 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17159 }
17160}
17161
17162static void alc662_auto_init_multi_out(struct hda_codec *codec)
17163{
17164 struct alc_spec *spec = codec->spec;
17165 int i;
17166
17167 for (i = 0; i <= HDA_SIDE; i++) {
17168 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017169 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017170 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017171 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017172 i);
17173 }
17174}
17175
17176static void alc662_auto_init_hp_out(struct hda_codec *codec)
17177{
17178 struct alc_spec *spec = codec->spec;
17179 hda_nid_t pin;
17180
17181 pin = spec->autocfg.hp_pins[0];
17182 if (pin) /* connect to front */
17183 /* use dac 0 */
17184 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017185 pin = spec->autocfg.speaker_pins[0];
17186 if (pin)
17187 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017188}
17189
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017190#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17191
17192static void alc662_auto_init_analog_input(struct hda_codec *codec)
17193{
17194 struct alc_spec *spec = codec->spec;
17195 int i;
17196
17197 for (i = 0; i < AUTO_PIN_LAST; i++) {
17198 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017199 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017200 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017201 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017202 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017203 snd_hda_codec_write(codec, nid, 0,
17204 AC_VERB_SET_AMP_GAIN_MUTE,
17205 AMP_OUT_MUTE);
17206 }
17207 }
17208}
17209
Takashi Iwaif511b012008-08-15 16:46:42 +020017210#define alc662_auto_init_input_src alc882_auto_init_input_src
17211
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017212static int alc662_parse_auto_config(struct hda_codec *codec)
17213{
17214 struct alc_spec *spec = codec->spec;
17215 int err;
17216 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17217
17218 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17219 alc662_ignore);
17220 if (err < 0)
17221 return err;
17222 if (!spec->autocfg.line_outs)
17223 return 0; /* can't find valid BIOS pin config */
17224
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017225 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17226 if (err < 0)
17227 return err;
17228 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17229 if (err < 0)
17230 return err;
17231 err = alc662_auto_create_extra_out(spec,
17232 spec->autocfg.speaker_pins[0],
17233 "Speaker");
17234 if (err < 0)
17235 return err;
17236 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17237 "Headphone");
17238 if (err < 0)
17239 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017240 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017241 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 return err;
17243
17244 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17245
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017246 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017247 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17248
Takashi Iwai603c4012008-07-30 15:01:44 +020017249 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017250 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017251
17252 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017253 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017254
Takashi Iwaid88897e2008-10-31 15:01:37 +010017255 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017256 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017257 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017258
17259 err = alc_auto_add_mic_boost(codec);
17260 if (err < 0)
17261 return err;
17262
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017263 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17264
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017265 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017266}
17267
17268/* additional initialization for auto-configuration model */
17269static void alc662_auto_init(struct hda_codec *codec)
17270{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017271 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017272 alc662_auto_init_multi_out(codec);
17273 alc662_auto_init_hp_out(codec);
17274 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017275 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017276 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017277 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017278}
17279
17280static int patch_alc662(struct hda_codec *codec)
17281{
17282 struct alc_spec *spec;
17283 int err, board_config;
17284
17285 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17286 if (!spec)
17287 return -ENOMEM;
17288
17289 codec->spec = spec;
17290
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017291 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17292
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017293 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17294 alc662_models,
17295 alc662_cfg_tbl);
17296 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017297 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17298 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017299 board_config = ALC662_AUTO;
17300 }
17301
17302 if (board_config == ALC662_AUTO) {
17303 /* automatic parse from the BIOS config */
17304 err = alc662_parse_auto_config(codec);
17305 if (err < 0) {
17306 alc_free(codec);
17307 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017308 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017309 printk(KERN_INFO
17310 "hda_codec: Cannot set up configuration "
17311 "from BIOS. Using base mode...\n");
17312 board_config = ALC662_3ST_2ch_DIG;
17313 }
17314 }
17315
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017316 err = snd_hda_attach_beep_device(codec, 0x1);
17317 if (err < 0) {
17318 alc_free(codec);
17319 return err;
17320 }
17321
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017322 if (board_config != ALC662_AUTO)
17323 setup_preset(spec, &alc662_presets[board_config]);
17324
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017325 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17326 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17327
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017328 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17329 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17330
Takashi Iwaie1406342008-02-11 18:32:32 +010017331 spec->adc_nids = alc662_adc_nids;
17332 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17333 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017335 if (!spec->cap_mixer)
17336 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017337 if (codec->vendor_id == 0x10ec0662)
17338 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17339 else
17340 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017341
Takashi Iwai2134ea42008-01-10 16:53:55 +010017342 spec->vmaster_nid = 0x02;
17343
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 codec->patch_ops = alc_patch_ops;
17345 if (board_config == ALC662_AUTO)
17346 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017347#ifdef CONFIG_SND_HDA_POWER_SAVE
17348 if (!spec->loopback.amplist)
17349 spec->loopback.amplist = alc662_loopbacks;
17350#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017351 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017352
17353 return 0;
17354}
17355
17356/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017357 * patch entries
17358 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017359static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017360 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017361 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017362 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017363 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017364 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017365 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017366 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017367 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017368 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17369 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17370 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017372 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17374 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017375 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017376 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017377 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017378 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017379 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017380 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017381 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017382 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017383 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017384 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017385 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017386 .patch = patch_alc882 },
17387 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17388 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017389 {} /* terminator */
17390};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017391
17392MODULE_ALIAS("snd-hda-codec-id:10ec*");
17393
17394MODULE_LICENSE("GPL");
17395MODULE_DESCRIPTION("Realtek HD-audio codec");
17396
17397static struct hda_codec_preset_list realtek_list = {
17398 .preset = snd_hda_preset_realtek,
17399 .owner = THIS_MODULE,
17400};
17401
17402static int __init patch_realtek_init(void)
17403{
17404 return snd_hda_add_codec_preset(&realtek_list);
17405}
17406
17407static void __exit patch_realtek_exit(void)
17408{
17409 snd_hda_delete_codec_preset(&realtek_list);
17410}
17411
17412module_init(patch_realtek_init)
17413module_exit(patch_realtek_exit)